Overview
Comment:Tests for existence of matrix before entering shell loop.
Tests for existence of expression before attempting to write or optimise.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: e8b2ec8b7049f5520fcecf927dc078ecfc8483e541fe18480d17178633c4ecf8
User & Date: geraint@users.sourceforge.net on 2002-08-29 15:45:20
Other Links: branch diff | manifest | tags
Context
2002-08-30
15:39:04
Read fix_c.r before ese.r and explicitly overload ** operator with pow().
These changes are required for the Codemist version of Reduce.
check-in: cbecb36981 user: geraint@users.sourceforge.net tags: origin/master, trunk
2002-08-29
15:45:20
Tests for existence of matrix before entering shell loop.
Tests for existence of expression before attempting to write or optimise.
check-in: e8b2ec8b70 user: geraint@users.sourceforge.net tags: origin/master, trunk
2002-08-28
15:48:01
Updated mttrc to make standalone C++ compilation configuration clearer. check-in: c26e5d9934 user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/def2write_r from [cb41fd29d7] to [c9ea406b2d].

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.14  2002/08/09 14:34:45  geraint
## Fix to prevent numbers being formed with a decimal point in the exponent, Reduce cannot handle these.
##
## Revision 1.13  2002/07/10 17:43:05  geraint
## Added feature [ 562453 ] Optimisation of algebraic equations.
##
## Revision 1.12  2002/06/28 10:13:40  geraint
## Includes fix_c.r in ese2rdae and def2write_r to eliminate occurrances of x**y.
##
## Revision 1.11.2.1  2002/06/05 11:14:51  geraint
165
166
167
168
169
170
171
172
173
174

175
176
177





178
179


180
181
182
183
184
185
186
187
188
189

190
191

192
193

194
195
196
197
198


199
200

201
202
203
204
205
206
207







208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226


227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245




















246
247
168
169
170
171
172
173
174

175
176
177
178
179
180
181
182
183
184
185


186
187
188
189
190
191
192
193
194
195
196
197
198
199

200


201





202
203

204
205
206






207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234



















235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256







-


+



+
+
+
+
+
-
-
+
+










+

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

+

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



















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



mtt_optimise ()
{
    sys="$1"
    lhs="$2"
    rhs="$3"
    
    crr="${sys}_cr.r"
    dae="${sys}_dae.r"
    tmp="mtt_optimise.tmp"
    tmp1="mtt_optimise1.tmp"
    tmp2="mtt_optimise2.tmp"
    tmp3="mtt_optimise3.tmp"
    
    grep -i -e "^$lhs" $dae |\
	sed -e 's/;/\ INAME\ mtt_tmp/g' |\
	sed -e 's/:=/:=/g' > $tmp1
    nlines=`wc -l $tmp1 | gawk '{print $1}'`
    if [ $nlines -gt 0 ]; then
    {
	cat <<EOF
	{
	    cat <<EOF
off echo$
load scope$
on double$
on noconvert$
on rounded$
off int$
off nat$
$include

out "$tmp2"$
optimize
EOF
    } > $tmp
	} > $tmp
    
    echo "optimize" >> $tmp
	cat $tmp1 >> $tmp
    grep -i -e "^$lhs" $dae |\
	sed -e 's/;/\ INAME\ mtt_tmp/g' |\
	sed -e 's/:=/:=/g' >> $tmp
    {
	cat <<EOF
	{
	    cat <<EOF

shut "$tmp2"$
$end$
EOF
    } >> $tmp
    echo "%%% $lhs %%%" >> def2write_r1.log
    ${SYMBOLIC:-reduce} < $tmp >> def2write_r1.log 2>> def2write_r2.log
    cat $tmp2 | gawk -v RS=';' '($2 == ":=") {print $0}' > $tmp3
    cat $tmp3 | mtt_fix_integers
    rm -f $tmp $tmp2 $tmp3
	} >> $tmp
	echo "%%% $lhs %%%" >> def2write_r1.log
	${SYMBOLIC:-reduce} < $tmp >> def2write_r1.log 2>> def2write_r2.log
	cat $tmp2 | gawk -v RS=';' '($2 == ":=") {print $0}' > $tmp3
	cat $tmp3 | mtt_fix_integers
    fi
    rm -f $tmp $tmp1 $tmp2 $tmp3
    return
}


# Remove log files
rm -f def2write_r1.log def2write_r2.log

# Write out the code
echo "" > $1_$2_write.r

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

for matrix in $matrices; do
    matrix_exists=`grep -i MTT${matrix} ${sys}_dae.r | wc -l | gawk '{print $1}'`
    if [ $matrix_exists -gt 0 ]; then
    n=`first "$ns"`; ns=`rest "$ns"` 
    m=`first "$ms"`; ms=`rest "$ms"`
    is=`n2m 1 $n`; 
    js=`n2m 1 $m`; 
    if [ $n -ge 1 ]; then
	for i in $is; do
	    for j in $js; do
		if [ ${opt:-""} = "-optimise" ]; then
		    name=`echo MTT$matrix'('$i','$j')'`
		    mtt_optimise $1 "$comma$name" "$name"
		    comma=''
		else
		    echo 'write'
		    name=`echo MTT$matrix'('$i','$j')'`
		    echo '  '$comma$name ':=' $name '$'
		fi >> $1_$2_write.r
	    done
	done
    fi
	n=`first "$ns"`; ns=`rest "$ns"` 
	m=`first "$ms"`; ms=`rest "$ms"`
	is=`n2m 1 $n`; 
	js=`n2m 1 $m`; 
	if [ $n -ge 1 ]; then
	    for i in $is; do
		for j in $js; do
		    if [ ${opt:-""} = "-optimise" ]; then
			name=`echo MTT$matrix'('$i','$j')'`
			mtt_optimise $1 "$comma$name" "$name"
			comma=''
		    else
			echo 'write'
			name=`echo MTT$matrix'('$i','$j')'`
			echo '  '$comma$name ':=' $name '$'
		    fi >> $1_$2_write.r
		done
	    done
	fi
    fi
done
echo ';END;'                           >>$1_$2_write.r


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