Comment: | Trying to get optimisation to work with maxima. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | origin/optimise-algebraic-equations | trunk |
Files: | files | file ages | folders |
SHA3-256: |
878c50922822726267fc7d914d12efb8 |
User & Date: | geraint@users.sourceforge.net on 2002-06-18 16:56:51 |
Other Links: | branch diff | manifest | tags |
2002-06-21
| ||
13:30:59 | Reformat input line for rates and outputs as well as algebraic equations. check-in: a5d8bcd452 user: geraint@users.sourceforge.net tags: origin/optimise-algebraic-equations, trunk | |
2002-06-18
| ||
16:56:51 | Trying to get optimisation to work with maxima. check-in: 878c509228 user: geraint@users.sourceforge.net tags: origin/optimise-algebraic-equations, trunk | |
2002-06-06
| ||
17:10:25 | Added a couple more simplification rules for pow. check-in: 697e0dcbed user: geraint@users.sourceforge.net tags: origin/optimise-algebraic-equations, trunk | |
Modified mttroot/mtt/bin/trans/mtt_optimise.sh from [3b8f7df6f9] to [a08246f929].
1 2 3 4 5 6 | 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 | + - - - - - + - - + + - - + + - + + + + + + + + + + + + + + + + + | #! /bin/sh set -e set -x filename="$1" |
Added mttroot/mtt/bin/trans/optimise_max2r.awk version [d3a19e1a09].
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 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | #! /usr/bin/awk -f # Maxima optimized expression format: # (C1) DISPLAY2D:FALSE$ # (C2) OPTIMIZE(x); # (D2) x # (C3) OPTIMIZE((1.0+a*b)/(2.0+a*b)); # (D3) BLOCK([%1],%1:a*b,(%1+1.0)/(%1+2.0)) function decipher_block(lhs,rhs) { s=rhs; s=gensub(/BLOCK/, "", "1", s); # strip BLOCK keyword s=gensub(/\(/, "", "1", s); # strip leading ( s=gensub(/\)$/, "", "1", s); # strip trailing ) s=gensub(/\[.*\],/, "", "g", s); # strip declarations s=gensub(/%/, "mtt_tmp", "g", s); # rename tmp variables s=gensub(/:/, " := ", "g", s); # fix assignment operator # commas delimit statements in maxima, so # preserve commas within function calls # replace remaining commas with semi-colons # then put commas back in functions and reinstate parentheses while (match(s, (/\(([^()]*),([^()]*)\)/))) { s=gensub(/\(([^()]*),([^()]*)\)/, "(\\1__MTT_COMMA__\\2)", "g", s); s=gensub(/\(([^,()]*)\)/, "__MTT_LPAREN__\\1__MTT_RPAREN__", "g", s); } s=gensub(/,/, ";\n", "g", s); s=gensub(/__MTT_COMMA__/, ",", "g", s); s=gensub(/__MTT_LPAREN__/, "(", "g", s); s=gensub(/__MTT_RPAREN__/, ")", "g", s); # separate statements rhs=gensub(/.*;([^;]*)\n/, "\\1", 1, s); s=gensub(/;([^;]*)$/, ";", 1, s); print s; # print intermediate statements printf "%s := %s;\n", lhs, rhs; # print final assignment } # pattern matching: (! /.* BLOCK.*/ ) { # unoptimised statement print $1" := "$2";"; } ( /.* BLOCK.*/ ) { # optimised statement decipher_block($1,$2) } |