Overview
Comment:Now does smx, smax smxax seperately.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 0cefd409e318c3462cec340b057b320349cc6dfc50852912e455658d99b327b5
User & Date: gawthrop@users.sourceforge.net on 2000-04-10 12:05:03
Other Links: branch diff | manifest | tags
Context
2000-04-10
12:08:08
removed echos check-in: 24bf94ae83 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
12:05:03
Now does smx, smax smxax seperately. check-in: 0cefd409e3 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
10:06:41
Sorted out implicit rules for p2oct conversion check-in: e6acee580b user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/cse2smx_lang from [9767a0d613] to [c2d4950465].

1
2
3
4
5
6
7
8



9
10
11
12
13
14


15
16

17
18

























19
20

21
22
23
24
25
26
27
28
29

30
31
32
33
34
35
36
1
2
3
4
5
6


7
8
9
10
11
12
13


14
15
16

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54

55
56
57
58
59
60
61
62






-
-
+
+
+




-
-
+
+

-
+


+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
+








-
+







#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: cse2csm_r
# Constrained-state equation to linear constrained-state matrices conversion
# Bourne shell script: cse2smx_r
# Constrained-state equation to state matrices with x vector
# Used for implicit integration
# Copyright (C) 2000 by Peter J. Gawthrop
## Modified from eailier version

# Language
if [ -n "$2" ]; then
    lang=$2
if [ -n "$3" ]; then
    lang=$3
else
    lang="r"
    lang="m"
fi

## Representation
if [ -z $2 ]; then
    rep=smx;
else
    rep=$2
fi

case $rep in
    smx)
	nrep=0;
        out='[mtta,mttax]';
	;;
    smxa)
	nrep=1;
        out='mtta';
	;;
    smxax)
	nrep=2
        out='mttax';
	;;
    *) echo Representation $2 not recognised;
       exit;;
esac


# Inform user
echo Creating $1_smx.$lang
echo Creating $1_$rep.$lang
#echo Creating $1_smxx.$lang
#echo Creating $1_smxtx.$lang

# Remove the old log file
rm -f cse2smx_r.log
rm -f $1_smx.$lang
rm -f $1_smxx.$lang
rm -f $1_smxtx.$lang
rm -f $1_smx.body
rm -f $1_$rep.body

# Use reduce to accomplish the transformation
reduce << EOF  >cse2smx_lang.log

lang := $lang;

in "$1_subs.r";
52
53
54
55
56
57
58
59

60
61
62
63
64
65
66
78
79
80
81
82
83
84

85
86
87
88
89
90
91
92







-
+








% Matrix output function
in"$MTTPATH/trans/lang_matrix.r";


%Set up output according to the language.
 OFF NAT;
 GENTRANOUT "$1_smx.body";
 GENTRANOUT "$1_$rep.body";

% Set up output according to the language.
    IF (lang = r) THEN 
    BEGIN
      write "matrix mtta(", mttnx, ",", mttnx, ");";    
      write "matrix mttb(", mttnx, ",", mttnu, ");";    
      write "matrix mttc(", mttny, ",", mttnx, ");";    
74
75
76
77
78
79
80



81
82







83
84
85

86

87
88
89
90

91
92
93
94
95
96

97
98

99
100

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

146
147
148
149
150
151
100
101
102
103
104
105
106
107
108
109


110
111
112
113
114
115
116
117
118
119
120

121
122
123
124

125


126
127
128

129
130

131
132

133











































134

135
136
137
138
139
140
141







+
+
+
-
-
+
+
+
+
+
+
+



+
-
+



-
+
-
-



-
+

-
+

-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

-
+






    FOR j := 1:MTTNx DO
    BEGIN
      ij := i + MTTNx*(j-1);
      xj := mkid(mttx,j);
      a_ij := df(MTTEdx(i,1), xj, 1);
      aa_ij := MTTE(i,j) - mttt*a_ij;
      IF (aa_ij NEQ 0) THEN
        IF ($nrep EQ 0) THEN
        BEGIN
          %% Write a and  with full indexing
%%%        GENTRAN mtta(i,j) ::=: aa_ij;
        GENTRAN mtta(ij) ::=: aa_ij;
          GENTRAN mtta(i,j) ::=: aa_ij;
        END;
        IF ($nrep EQ 1) THEN
        BEGIN
          %% Write a  with vector indexing
          GENTRAN mtta(ij) ::=: aa_ij;
        END;
        mttAAx_i := mttAAx_i + aa_ij*xj;
      END;
      IF (mttAAx_i NEQ 0) THEN
        IF (($nrep EQ 0) OR ($nrep EQ 2)) THEN
        GENTRAN mttax(i) ::=: mttAAx_i;
          GENTRAN mttax(i) ::=: mttAAx_i;
  END;

%Shut the  output according to the language.
 GENTRANSHUT "$1_smx.body";
 GENTRANSHUT "$1_$rep.body";


EOF

if [ "$lang" = "m" ]; then
  lang_header $1 smx m 'mttx,mttu,mttt,mttpar' '[mtta,mttax]' > $1_smx.m
  lang_header $1 rep m 'mttx,mttu,mttt,mttpar' $out > $1_$rep.m

  echo '#====== Start of code ======#' >> $1_smx.m
  echo '#====== Start of code ======#' >> $1_$rep.m

  cat $1_smx.body | mtt_p2m >> $1_smx.m
  cat $1_$rep.body | mtt_p2m >> $1_$rep.m

  ## Now do the separate files 
  ## smxa
  echo Creating $1_smxa.$lang
  lang_header $1 smxa m 'mttx,mttu,mttt,mttpar' '[mtta]' > $1_smxa.m

  echo '#====== Start of code ======#' >> $1_smxa.m

  ## This needs more work
  cat $1_smx.body | grep 'mtta\[' | mtt_p2m >> $1_smxa.m

  ## smxax
  echo Creating $1_smxax.$lang
  lang_header $1 smxax m 'mttx,mttu,mttt,mttpar' '[mttax]' > $1_smxax.m

  echo '#====== Start of code ======#' >> $1_smxax.m

  ## This needs more work
  cat $1_smx.body |\
  awk '{
    if (match($1,"mtt")) {
      printing=0
      if (match($1,"mttax\\["))
        printing=1;
     }
    if (printing) print $0 
  }' | mtt_p2m >> $1_smxax.m



  #rm -f $1_smx.body

#  mv $1_smxx.$lang  mtt_junk
#  lang_header $1 smxx m 'mttx,mttu,mttxx,mttdt' '[mttax]' > $1_smxx.m
#  cat mtt_junk | mtt_p2m >> $1_smxx.m
#  rm -f mtt_junk
#
#  mv $1_smxtx.$lang  mtt_junk
#  lang_header $1 smxtx m 'mttx,mttu,mttxx,mttdt' '[mttax]' > $1_smxtx.m
#  cat mtt_junk | mtt_p2m >> $1_smxtx.m
#  rm -f mtt_junk
#
#
fi

 
# Now invoke the standard error handling.
mtt_error_r cse2smx_lang.log





MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]