Differences From Artifact [4a06362261]:

To Artifact [6639ce8c03]:


9
10
11
12
13
14
15



16
17
18
19
20
21
22
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25







+
+
+







# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.8  2001/07/13 04:54:04  geraint
## Branch merge: numerical-algebraic-solution back to main.
##
## Revision 1.7.2.1  2001/05/04 04:07:24  geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.7  2001/04/11 09:44:26  gawthrop
## Fixed cc and c problems to do with pow(x,y) and integers
38
39
40
41
42
43
44












45
46
47
48
49
50

51
52
53
54
55
56
57
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

65
66
67
68
69
70
71
72







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





-
+







## Revision 1.2  2000/10/10 21:02:17  peterg
## Added cse reps
##
## Revision 1.1  2000/10/10 09:07:32  peterg
## Initial revision
##
###############################################################

optimise=''
while [ -n "`echo $1 | grep '^-'`" ]; do
    case $1 in
	-optimise)
	    opt='-optimise'
	    optimise_msg=' with optimisation' ;;
	*)
	    echo "$1 is an invalid argument - ignoring" ;;
    esac
    shift
done

sys=$1 # System name
rep=$2 # System representation

# Inform User
echo Creating $1_$2_write.r
echo Creating $1_$2_write.r $optimise_msg

# Find system constants
Nx=`mtt_getsize $sys x` # States
Nxx=`mtt_getsize $sys xx` # States x States
Nu=`mtt_getsize $sys u` # Inputs 
Ny=`mtt_getsize $sys y` # Outputs 
Nyz=`mtt_getsize $sys yz` # Zero outputs
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
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
152







-
+
+
+
+
+
+
+








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




	;;
    *)
        echo def2write_r: representation $rep not recognised
        exit
esac

# Write out the code
echo 'off echo$ load scope$'                    >$1_$2_write.r
echo 'off echo$'                    >$1_$2_write.r

if [ ${opt:-""} = "-optimise" ]; then
    echo 'load scope$'
else
    echo 'load gentran$'
fi >> $1_$2_write.r

for matrix in $matrices; do
    n=`first "$ns"`; ns=`rest "$ns"` 
    m=`first "$ms"`; ms=`rest "$ms"`
    is=`n2m 1 $n`; 
    js=`n2m 1 $m`; 
    for i in $is; do
      for j in $js; do
	if [ ${opt:-""} = "-optimise" ]; then
        echo 'optimize'                      >>$1_$2_write.r
        name=`echo MTT$matrix'('$i','$j')'`
        echo '  '$comma$name ':=:' $name >>$1_$2_write.r
        echo 'INAME mtt_tmp$'                 >>$1_$2_write.r
        comma=''
       	    echo 'optimize'
	    name=`echo MTT$matrix'('$i','$j')'`
	    echo '  '$comma$name ':=:' $name
	    echo 'INAME mtt_tmp$'
	    comma=''
	else
	    echo 'write'
	    name=`echo MTT$matrix'('$i','$j')'`
	    echo '  '$comma$name ':=' $name '$'
	fi >> $1_$2_write.r
      done
    done
done
echo 'END$'                           >>$1_$2_write.r

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