simplifyAssertEq(x, x) |
${x} = {x}$
GOOD |
time: 0.390000ms stack: size: 7
|
simplifyAssertNe(x, y) |
${x} \ne {y}$
GOOD |
time: 0.576000ms stack: size: 7
|
|
| ||
assert(x:match(x)) | GOOD |
time: 0.028000ms stack: size: 0 |
assert(not x:match(y)) | GOOD |
time: 0.016000ms stack: size: 0 |
|
| ||
|
constants | ||
|
| ||
implicit mul by 1simplifyAssertAllEq({const(2):match(const(2)*W(1))}, {const(1)})
|
${1} = {1}$
${1} = {1}$ ${1} = {1}$ GOOD |
time: 2.232000ms stack: size: 7
|
simplifyAssertAllEq({const(2):match(const(1)*W(1))}, {const(2)})
|
${1} = {1}$
${2} = {2}$ ${2} = {2}$ GOOD |
time: 1.238000ms stack: size: 7
|
implicit divide by 1simplifyAssertAllEq({const(2):match(const(2)/W(1))}, {const(1)})
|
${1} = {1}$
lhs: 1=false rhs: 1=$1$ when comparing key 1 BAD [string "/home/chris/Projects/lua/symmath/Expression.lua"]:32: idk what this is: false stack traceback: /home/chris/Projects/lua/symmath/tests/unit/unit.lua:194: in function [C]: in function 'error' [string "/home/chris/Projects/lua/symmath/Expression.lua"]:32: in function 'init' [string "/home/chris/Projects/lua/symmath/op/Binary.lua"]:7: in function 'init' /home/chris/Projects/lua/ext/class.lua:7: in function 'eq' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:184: in function [C]: in function 'xpcall' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:180: in function 'simplifyAssertAllEq' [string "simplifyAssertAllEq({const(2):match(const(2)/..."]:1: in main chunk /home/chris/Projects/lua/symmath/tests/unit/unit.lua:252: in function [C]: in function 'xpcall' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:251: in function 'exec' match.lua:233: in function 'cb' [string "/home/chris/Projects/lua/ext/timer.lua"]:101: in function 'timer' match.lua:6: in main chunk [C]: at 0x641c16735390 16 BAD /home/chris/Projects/lua/symmath/tests/unit/unit.lua:196: failed stack traceback: /home/chris/Projects/lua/symmath/tests/unit/unit.lua:260: in function [C]: in function 'error' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:196: in function 'simplifyAssertAllEq' [string "simplifyAssertAllEq({const(2):match(const(2)/..."]:1: in main chunk /home/chris/Projects/lua/symmath/tests/unit/unit.lua:252: in function [C]: in function 'xpcall' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:251: in function 'exec' match.lua:233: in function 'cb' [string "/home/chris/Projects/lua/ext/timer.lua"]:101: in function 'timer' match.lua:6: in main chunk [C]: at 0x641c16735390 |
time: 0.695000ms stack: size: 7
|
implicit integer factoringsimplifyAssertAllEq({const(4):match(const(2)*W(1))}, {const(2)})
|
${1} = {1}$
lhs: 1=false rhs: 1=$2$ when comparing key 1 BAD [string "/home/chris/Projects/lua/symmath/Expression.lua"]:32: idk what this is: false stack traceback: /home/chris/Projects/lua/symmath/tests/unit/unit.lua:194: in function [C]: in function 'error' [string "/home/chris/Projects/lua/symmath/Expression.lua"]:32: in function 'init' [string "/home/chris/Projects/lua/symmath/op/Binary.lua"]:7: in function 'init' /home/chris/Projects/lua/ext/class.lua:7: in function 'eq' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:184: in function [C]: in function 'xpcall' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:180: in function 'simplifyAssertAllEq' [string "simplifyAssertAllEq({const(4):match(const(2)*..."]:1: in main chunk /home/chris/Projects/lua/symmath/tests/unit/unit.lua:252: in function [C]: in function 'xpcall' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:251: in function 'exec' match.lua:233: in function 'cb' [string "/home/chris/Projects/lua/ext/timer.lua"]:101: in function 'timer' match.lua:6: in main chunk [C]: at 0x641c16735390 16 BAD /home/chris/Projects/lua/symmath/tests/unit/unit.lua:196: failed stack traceback: /home/chris/Projects/lua/symmath/tests/unit/unit.lua:260: in function [C]: in function 'error' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:196: in function 'simplifyAssertAllEq' [string "simplifyAssertAllEq({const(4):match(const(2)*..."]:1: in main chunk /home/chris/Projects/lua/symmath/tests/unit/unit.lua:252: in function [C]: in function 'xpcall' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:251: in function 'exec' match.lua:233: in function 'cb' [string "/home/chris/Projects/lua/ext/timer.lua"]:101: in function 'timer' match.lua:6: in main chunk [C]: at 0x641c16735390 |
time: 0.851000ms stack: size: 7
|
|
| ||
|
functions | ||
|
| ||
simplifyAssertAllEq({sin(x):match(sin(W(1)))}, {x})
|
${1} = {1}$
${x} = {x}$ ${x} = {x}$ GOOD |
time: 1.293000ms stack: size: 7
|
|
| ||
|
functions and mul mixed | ||
simplifyAssertAllEq({sin(2*x):match(sin(W(1)))}, {2 * x})
|
${1} = {1}$
${{{2}} {{x}}} = {{{2}} {{x}}}$ ${{{2}} {{x}}} = {{{2}} {{x}}}$ GOOD |
time: 4.138000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq({sin(2*x):match(sin(2 * W(1)))}, {x})
|
${1} = {1}$
${x} = {x}$ ${x} = {x}$ GOOD |
time: 0.764000ms stack: size: 7
|
|
| ||
|
matching c*f(x) => c*sin(a*x) | ||
simplifyAssertAllEq({sin(2*x):match(W{1, dependsOn=x} * W{index=2, cannotDependOn=x})}, {sin(2*x), one})
|
${2} = {2}$
${\sin\left( {{{2}} {{x}}}\right)} = {\sin\left( {{{2}} {{x}}}\right)}$ ${\sin\left( {{{2}} {{x}}}\right)} = {\sin\left( {{{2}} {{x}}}\right)}$ ${1} = {1}$ ${1} = {1}$ GOOD |
time: 4.511000ms stack: size: 7
|
simplifyAssertAllEq({sin(2*x):match(sin(W{1, cannotDependOn=x} * x))}, {const(2)})
|
${1} = {1}$
${2} = {2}$ ${2} = {2}$ GOOD |
time: 0.865000ms stack: size: 7
|
|
| ||
|
add | ||
|
| ||
simplifyAssertAllEq({x:match(W{2, cannotDependOn=x} + W{1, dependsOn=x})}, {x, zero})
|
${2} = {2}$
${x} = {x}$ ${x} = {x}$ ${0} = {0}$ ${0} = {0}$ GOOD |
time: 1.153000ms stack: size: 8
|
simplifyAssertEq((x + y), (x + y)) |
${{x} + {y}} = {{x} + {y}}$
GOOD |
time: 2.183000ms stack: size: 8
|
assert((x + y):match(x + y)) | GOOD |
time: 0.204000ms stack: size: 0 |
|
| ||
|
add match to first term | ||
simplifyAssertAllEq({(x + y):match(W(1) + y)}, {x})
|
${1} = {1}$
${x} = {x}$ ${x} = {x}$ GOOD |
time: 0.713000ms stack: size: 7
|
|
| ||
|
add match to second term | ||
simplifyAssertAllEq({(x + y):match(x + W(1))}, {y})
|
${1} = {1}$
${y} = {y}$ ${y} = {y}$ GOOD |
time: 0.871000ms stack: size: 7
|
|
| ||
|
change order | ||
simplifyAssertAllEq({(x + y):match(y + W(1))}, {x})
|
${1} = {1}$
${x} = {x}$ ${x} = {x}$ GOOD |
time: 0.570000ms stack: size: 7
|
|
| ||
|
add match to zero, because nothing's left | ||
simplifyAssertAllEq({(x + y):match(x + y + W(1))}, {zero})
|
${1} = {1}$
${0} = {0}$ ${0} = {0}$ GOOD |
time: 0.572000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq({(x + y):match(W(1))}, {x + y})
|
${1} = {1}$
${{x} + {y}} = {{x} + {y}}$ ${{x} + {y}} = {{x} + {y}}$ GOOD |
time: 2.152000ms stack: size: 8
|
|
| ||
|
doubled-up matches should only work if they match | ||
assert(not (x + y):match(W(1) + W(1))) | GOOD |
time: 0.659000ms stack: size: 0 |
|
| ||
|
this too, this would work only if x + x and not x + y | ||
simplifyAssertAllEq({(x + x):match(W(1) + W(1))}, {x})
|
${1} = {1}$
${x} = {x}$ ${x} = {x}$ GOOD |
time: 0.575000ms stack: size: 7
|
|
| ||
|
this too | ||
simplifyAssertAllEq({(x + x):match(W{1, atMost=1} + W{2, atMost=1})}, {x, x})
|
${2} = {2}$
${x} = {x}$ ${x} = {x}$ ${x} = {x}$ ${x} = {x}$ GOOD |
time: 0.672000ms stack: size: 7
|
|
| ||
|
this should match (x+y), 0 | ||
simplifyAssertAllEq({(x + y):match(W(1) + W(2))}, {x + y, zero})
|
${2} = {2}$
${{x} + {y}} = {{x} + {y}}$ ${{x} + {y}} = {{x} + {y}}$ ${0} = {0}$ ${0} = {0}$ GOOD |
time: 2.824000ms stack: size: 8
|
|
| ||
simplifyAssertAllEq({(x + y):match(W{1, atMost=1} + W{2, atMost=1})}, {x, y})
|
${2} = {2}$
${x} = {x}$ ${x} = {x}$ ${y} = {y}$ ${y} = {y}$ GOOD |
time: 0.612000ms stack: size: 7
|
|
| ||
|
for these to work, I have to add the multi-wildcard stuff to the non-wildcard elements, handled in add.wildcardMatches | ||
simplifyAssertAllEq({x:match(W(1) + W(2))}, {x, zero})
|
${2} = {2}$
${x} = {x}$ ${x} = {x}$ ${0} = {0}$ ${0} = {0}$ GOOD |
time: 0.528000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq({x:match(x + W(1) + W(2))}, {zero, zero})
|
${2} = {2}$
${0} = {0}$ ${0} = {0}$ ${0} = {0}$ ${0} = {0}$ GOOD |
time: 0.611000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq({x:match(W(1) + x + W(2))}, {zero, zero})
|
${2} = {2}$
${0} = {0}$ ${0} = {0}$ ${0} = {0}$ ${0} = {0}$ GOOD |
time: 0.652000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq({(x * y):match(W(1) + W(2))}, {x * y, zero})
|
${2} = {2}$
${{{x}} {{y}}} = {{{x}} {{y}}}$ ${{{x}} {{y}}} = {{{x}} {{y}}}$ ${0} = {0}$ ${0} = {0}$ GOOD |
time: 1.878000ms stack: size: 7
|
|
| ||
|
make sure within add.wildcardMatches we greedy-match any wildcards with 'atLeast' before assigning the rest to zero | ||
simplifyAssertAllEq({x:match(W(1) + W{2,atLeast=1} + W(3))}, {zero, x, zero})
|
${3} = {3}$
${0} = {0}$ ${0} = {0}$ ${x} = {x}$ ${x} = {x}$ ${0} = {0}$ ${0} = {0}$ GOOD |
time: 0.793000ms stack: size: 7
|
|
| ||
|
now we match wildcards left-to-right, so the cannot-depend-on will match first | ||
simplifyAssertAllEq({(x + y):match(W{1, cannotDependOn=x} + W{2, dependsOn=x})}, {y, x})
|
${2} = {2}$
${y} = {y}$ ${y} = {y}$ ${x} = {x}$ ${x} = {x}$ GOOD |
time: 0.802000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq({(x + y):match(W{1, cannotDependOn=x, atLeast=1} + W{2, dependsOn=x})}, {y, x})
|
${2} = {2}$
${y} = {y}$ ${y} = {y}$ ${x} = {x}$ ${x} = {x}$ GOOD |
time: 0.805000ms stack: size: 7
|
|
| ||
|
| ||
|
same with mul | ||
|
| ||
simplifyAssertAllEq({(x * y):match(y * W(1))}, {x})
|
${1} = {1}$
${x} = {x}$ ${x} = {x}$ GOOD |
time: 0.398000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq({(x * y):match(x * y * W(1))}, {one})
|
${1} = {1}$
${1} = {1}$ ${1} = {1}$ GOOD |
time: 0.889000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq({ (x * y):match(W(1))}, {x * y})
|
${1} = {1}$
${{{x}} {{y}}} = {{{x}} {{y}}}$ ${{{x}} {{y}}} = {{{x}} {{y}}}$ GOOD |
time: 1.855000ms stack: size: 7
|
|
| ||
assert(not (x * y):match(W(1) * W(1))) | GOOD |
time: 0.707000ms stack: size: 0 |
|
| ||
simplifyAssertAllEq({(x * x):match(W(1) * W(1))}, {x})
|
${1} = {1}$
${x} = {x}$ ${x} = {x}$ GOOD |
time: 0.681000ms stack: size: 7
|
|
| ||
|
verify wildcards are greedy with multiple mul matching | ||
|
the first will take all expressions, the second gets the empty set | ||
simplifyAssertAllEq({(x * y):match(W(1) * W(2))}, {x * y, one})
|
${2} = {2}$
${{{x}} {{y}}} = {{{x}} {{y}}}$ ${{{x}} {{y}}} = {{{x}} {{y}}}$ ${1} = {1}$ ${1} = {1}$ GOOD |
time: 2.193000ms stack: size: 7
|
|
| ||
|
verify 'atMost' works - since both need at least 1 entry, it will only match when each gets a separate term | ||
simplifyAssertAllEq({(x * x):match(W{1, atMost=1} * W{2, atMost=1})}, {x, x})
|
${2} = {2}$
${x} = {x}$ ${x} = {x}$ ${x} = {x}$ ${x} = {x}$ GOOD |
time: 0.645000ms stack: size: 7
|
|
| ||
|
verify 'atMost' cooperates with non-atMost wildcards | ||
simplifyAssertAllEq({(x * y):match(W(1) * W{2, atLeast=1})}, {x, y})
|
${2} = {2}$
${x} = {x}$ ${x} = {x}$ ${y} = {y}$ ${y} = {y}$ GOOD |
time: 0.728000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq({(x * y):match(W{1, atMost=1} * W{2, atMost=1})}, {x, y})
|
${2} = {2}$
${x} = {x}$ ${x} = {x}$ ${y} = {y}$ ${y} = {y}$ GOOD |
time: 0.498000ms stack: size: 7
|
|
| ||
assert( not( Constant(0):match(x) ) ) | GOOD |
time: 0.038000ms stack: size: 0 |
assert( not( Constant(0):match(x * y) ) ) | GOOD |
time: 0.054000ms stack: size: 0 |
|
| ||
simplifyAssertEq( zero:match(W(1) * x), zero ) |
${0} = {0}$
GOOD |
time: 0.106000ms stack: size: 0 |
assert( not zero:match(W{1, dependsOn=x} * x) )
| GOOD |
time: 0.212000ms stack: size: 0 |
|
| ||
simplifyAssertEq( zero:match(W(1) * x * y), zero ) |
${0} = {0}$
GOOD |
time: 0.251000ms stack: size: 0 |
|
| ||
simplifyAssertEq( one:match(1 + W(1)), zero ) |
${0} = {0}$
GOOD |
time: 0.322000ms stack: size: 0 |
|
| ||
simplifyAssertEq( one:match(1 + W(1) * x), zero ) |
${0} = {0}$
GOOD |
time: 0.189000ms stack: size: 0 |
|
| ||
simplifyAssertEq( one:match(1 + W(1) * x * y), zero ) |
${0} = {0}$
GOOD |
time: 0.200000ms stack: size: 0 |
|
| ||
|
| ||
|
how can you take x*y and match only the 'x'? | ||
|
| ||
simplifyAssertAllEq({(x * y):match(W{index=2, cannotDependOn=x} * W{1, dependsOn=x})}, {x, y})
|
${2} = {2}$
${x} = {x}$ ${x} = {x}$ ${y} = {y}$ ${y} = {y}$ GOOD |
time: 0.662000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq({(x * y):match(W{1, dependsOn=x} * W{index=2, cannotDependOn=x})}, {x*y, 1})
|
${2} = {2}$
${{{x}} {{y}}} = {{{x}} {{y}}}$ ${{{x}} {{y}}} = {{{x}} {{y}}}$ ${1} = {1}$ ${1} = {1}$ GOOD |
time: 1.757000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq({(x * y):match(W{index=2, cannotDependOn=x} * W(1))}, {x, y})
|
${2} = {2}$
${x} = {x}$ ${x} = {x}$ ${y} = {y}$ ${y} = {y}$ GOOD |
time: 0.840000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq({(x * y):match(W(1) * W{index=2, cannotDependOn=x})}, {x*y, 1})
|
${2} = {2}$
${{{x}} {{y}}} = {{{x}} {{y}}}$ ${{{x}} {{y}}} = {{{x}} {{y}}}$ ${1} = {1}$ ${1} = {1}$ GOOD |
time: 1.940000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq({(x * y):match(W(1) * W(2))}, {x*y, 1})
|
${2} = {2}$
${{{x}} {{y}}} = {{{x}} {{y}}}$ ${{{x}} {{y}}} = {{{x}} {{y}}}$ ${1} = {1}$ ${1} = {1}$ GOOD |
time: 1.662000ms stack: size: 7
|
|
| ||
|
| ||
|
combinations of add and mul | ||
|
| ||
|
| ||
|
for this to work, add.wildcardMatches must call the wildcard-capable objects' own wildcard handlers correctly (and use push/pop match states, instead of assigning to wildcard indexes directly?) | ||
|
also, because add.wildcardMatches assigns the extra wildcards to zero, it will be assigning (W(2) * W(3)) to zero ... which means it must (a) handle mul.wildcardMatches and (b) pick who of mul's children gets the zero and who doesn't | ||
|
it also means that a situation like add->mul->add might have problems ... x:match(W(1) + (W(2) + W(3)) * (W(4) + W(5))) | ||
do local i,j,k = x:match(W(1) + W(2) * W(3)) assertEq(i, x) assert(j == zero or k == zero) end |
${x} = {x}$
GOOD |
time: 0.519000ms stack: size: 0 |
|
| ||
|
| ||
|
cross over add and mul ... not yet working | ||
|
local i = (x):match(W(1) + x) -- works | ||
do local i = (x * y):match(W(1) + x * y) assertEq(i, zero) end |
${0} = {0}$
GOOD |
time: 0.241000ms stack: size: 0 |
|
| ||
|
either 1 or 2 must be zero, and either 3 or 4 must be zero | ||
do local i,j,k,l = x:match(x + W(1) * W(2) + W(3) * W(4)) assert(i == zero or j == zero) assert(k == zero or l == zero) end | GOOD |
time: 0.254000ms stack: size: 0 |
|
| ||
do local c, f = (2 * x):match(W{1, cannotDependOn=x} * W{2, dependsOn=x}) assertEq(c, const(2)) assertEq(f, x) end
|
${2} = {2}$
${x} = {x}$ GOOD |
time: 1.091000ms stack: size: 0 |
|
| ||
do local c, f = (2 * x):match(W{1, cannotDependOn=x} * W{2, dependsOn=x}) assertEq(c, const(2)) assertEq(f, x) end
|
${2} = {2}$
${x} = {x}$ GOOD |
time: 0.521000ms stack: size: 0 |
|
| ||
|
Put the 'cannotDependOn' wildcard first (leftmost) in the mul for it to greedily match non-dep-on-x terms | ||
|
otherwise 'dependsOn' will match everything, since the mul of a non-dep and a dep itself is dep on 'x', so it will include non-dep-on-terms | ||
do local c, f = (2 * 1/x):factorDivision():match(W{index=1, cannotDependOn=x} * W{2, dependsOn=x}) assertEq(c, const(2)) assertEq(f, 1/x) end
|
${2} = {2}$
${\frac{1}{x}} = {\frac{1}{x}}$ GOOD |
time: 6.618000ms stack: size: 8
|
|
| ||
do local c, f = (2 * 1/x):factorDivision():match(W{1, cannotDependOn=x} * W(2)) assertEq(c, const(2)) assertEq(f, 1/x) end
|
${2} = {2}$
${\frac{1}{x}} = {\frac{1}{x}}$ GOOD |
time: 3.039000ms stack: size: 8
|
|
| ||
simplifyAssertAllEq({ (x + 2*y):match(W(1) + W(2) * y) }, {x,2})
|
${2} = {2}$
${x} = {x}$ ${x} = {x}$ ${2} = {2}$ ${2} = {2}$ GOOD |
time: 0.683000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq({ (x + 2*y):match(W(1) * x + W(2) * y) }, {1,2})
|
${2} = {2}$
${1} = {1}$ ${1} = {1}$ ${2} = {2}$ ${2} = {2}$ GOOD |
time: 1.141000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq( {x:match( W(1)*x + W(2))}, {1, 0})
|
${2} = {2}$
${1} = {1}$ ${1} = {1}$ ${0} = {0}$ ${0} = {0}$ GOOD |
time: 0.853000ms stack: size: 7
|
|
| ||
simplifyAssertAllEq( {x:match( W(1)*x + W(2)*y)}, {1, 0})
|
${2} = {2}$
${1} = {1}$ ${1} = {1}$ ${0} = {0}$ ${0} = {0}$ GOOD |
time: 0.712000ms stack: size: 7
|
|
| ||
|
div | ||
|
| ||
|
| ||
do local i = (1/x):match(1 / W(1)) assertEq(i, x) end |
${x} = {x}$
GOOD |
time: 0.075000ms stack: size: 0 |
|
| ||
do local i = (1/x):match(1 / (W(1) * x)) assertEq(i, one) end |
${1} = {1}$
GOOD |
time: 0.155000ms stack: size: 0 |
|
| ||
do local i = (1/x):match(1 / (W{1, cannotDependOn=x} * x)) assertEq(i, one) end
|
${1} = {1}$
GOOD |
time: 0.126000ms stack: size: 0 |
|
| ||
assert((2 * 1/x):match(2 * 1/x)) | GOOD |
time: 0.039000ms stack: size: 0 |
|
| ||
do local i = (2 * 1/x):match(2 * 1/W(1)) assertEq(i, x) end |
${x} = {x}$
GOOD |
time: 0.078000ms stack: size: 0 |
|
| ||
do local i = (2 * 1/x):match(2 * 1/(W(1) * x)) assertEq(i, one) end |
${1} = {1}$
GOOD |
time: 0.287000ms stack: size: 0 |
|
| ||
do local i, j = (2 * 1/x):factorDivision():match(W{1, atMost=1} * W{index=2, atMost=1}) assertEq(i, const(2)) assertEq(j, 1/x) end
|
${2} = {2}$
${\frac{1}{x}} = {\frac{1}{x}}$ GOOD |
time: 3.300000ms stack: size: 8
|
|
| ||
do local a, b = (1/(x*(3*x+4))):match(1 / (x * (W{1, cannotDependOn=x} * x + W{2, cannotDependOn=x}))) assertEq(a, const(3)) assertEq(b, const(4)) end
|
${3} = {3}$
${4} = {4}$ GOOD |
time: 0.384000ms stack: size: 0 |
|
| ||
do local a, b = (1/(x*(3*x+4))):factorDivision():match(1 / (W{1, cannotDependOn=x} * x * x + W{2, cannotDependOn=x} * x)) assertEq(a, const(3)) assertEq(b, const(4)) end
|
${3} = {3}$
${4} = {4}$ GOOD |
time: 22.606000ms stack: size: 9
|
|
| ||
|
pow | ||
|
| ||
simplifyAssertAllEq({(x^2):match(x^W(1))}, {const(2)})
|
${1} = {1}$
${2} = {2}$ ${2} = {2}$ GOOD |
time: 0.691000ms stack: size: 7
|
simplifyAssertAllEq({(x^2):match(W(1)^2)}, {x})
|
${1} = {1}$
${x} = {x}$ ${x} = {x}$ GOOD |
time: 0.665000ms stack: size: 7
|
simplifyAssertAllEq({(x^2):match(W(1)^W(2))}, {x, 2})
|
${2} = {2}$
${x} = {x}$ ${x} = {x}$ ${2} = {2}$ ${2} = {2}$ GOOD |
time: 0.615000ms stack: size: 7
|
|
defaults: | ||
simplifyAssertAllEq({(x):match(x^W(1))}, {const(1)})
|
${1} = {1}$
${1} = {1}$ ${1} = {1}$ GOOD |
time: 0.558000ms stack: size: 7
|
simplifyAssertAllEq({(x):match(W(1)^1)}, {x})
|
${1} = {1}$
${x} = {x}$ ${x} = {x}$ GOOD |
time: 0.339000ms stack: size: 7
|
simplifyAssertAllEq({(x):match(W(1)^W(2))}, {x, const(1)})
|
${2} = {2}$
${x} = {x}$ ${x} = {x}$ ${1} = {1}$ ${1} = {1}$ GOOD |
time: 0.739000ms stack: size: 7
|
|
| ||
|
etc | ||
|
| ||
do local expr = sin(2*x) + cos(3*x) local a,b = expr:match( sin(W(1)) + cos(W(2)) ) print(a[1], a[2] ,b) end | $2$ $x$ ${{3}} {{x}}$ GOOD |
time: 0.271000ms stack: size: 0 |
do local expr = sin(2*x) * cos(3*x) local a,b = expr:match( sin(W(1)) * cos(W(2)) ) print(a[1], a[2] ,b) end | $2$ $x$ ${{3}} {{x}}$ GOOD |
time: 0.170000ms stack: size: 0 |
|
| ||
do local expr = (3*x^2 + 1) printbr('expr', expr) local a, c = expr:match(W{1, cannotDependOn=x} * x^2 + W{2, cannotDependOn=x}) printbr('a', a) printbr('c', c) simplifyAssertAllEq({a, c}, {3, 1}) end
|
expr ${{{3}} {{{x}^{2}}}} + {1}$
a $3$ c $1$ ${2} = {2}$ ${3} = {3}$ ${3} = {3}$ ${1} = {1}$ ${1} = {1}$ GOOD |
time: 2.255000ms stack: size: 7
|
|
| ||
do local expr = (3*x^2 + 2*x + 1) printbr('expr', expr) local a, b, c = expr:match(W{1, cannotDependOn=x} * x^2 + W{2, cannotDependOn=x} * x + W{3, cannotDependOn=x}) printbr('a', a) printbr('b', b) printbr('c', c) simplifyAssertAllEq({a, b, c}, {3, 2, 1}) end
|
expr ${{{3}} {{{x}^{2}}}} + {{{2}} {{x}}} + {1}$
a $3$ b $2$ c $1$ ${3} = {3}$ ${3} = {3}$ ${3} = {3}$ ${2} = {2}$ ${2} = {2}$ ${1} = {1}$ ${1} = {1}$ GOOD |
time: 2.671000ms stack: size: 7
|
|
| ||
do local expr = (3*x^2 + 1):factorDivision() printbr('expr', expr) local a, b, c = expr:match(W{1, cannotDependOn=x} * x^2 + W{2, cannotDependOn=x} * x + W{3, cannotDependOn=x}) printbr('a', a) printbr('b', b) printbr('c', c) simplifyAssertAllEq({a, b, c}, {3, 0, 1}) end
|
expr ${1} + {{{3}} {{{x}^{2}}}}$
a false b nil c nil ${1} = {3}$ expected 1 to equal 3 found $1$ vs $3$ lhs stack Init $1$ 1 Prune $1$ 1 Expand $1$ 1 Prune $1$ 1 Factor $1$ 1 Prune $1$ 1 Tidy $1$ 1 rhs stack Init $3$ 3 Prune $3$ 3 Expand $3$ 3 Prune $3$ 3 Factor $3$ 3 Prune $3$ 3 Tidy $3$ 3 lhs: 1=false rhs: 1=3, 2=0, 3=1 BAD /home/chris/Projects/lua/symmath/tests/unit/unit.lua:138: failed stack traceback: /home/chris/Projects/lua/symmath/tests/unit/unit.lua:194: in function [C]: in function 'error' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:138: in function 'simplifyAssertEq' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:181: in function [C]: in function 'xpcall' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:180: in function 'simplifyAssertAllEq' [string "do local expr = (3*x^2 + 1):factorDivision() ..."]:1: in main chunk /home/chris/Projects/lua/symmath/tests/unit/unit.lua:252: in function [C]: in function 'xpcall' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:251: in function 'exec' match.lua:233: in function 'cb' [string "/home/chris/Projects/lua/ext/timer.lua"]:101: in function 'timer' match.lua:6: in main chunk [C]: at 0x641c16735390 14 BAD /home/chris/Projects/lua/symmath/tests/unit/unit.lua:196: failed stack traceback: /home/chris/Projects/lua/symmath/tests/unit/unit.lua:260: in function [C]: in function 'error' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:196: in function 'simplifyAssertAllEq' [string "do local expr = (3*x^2 + 1):factorDivision() ..."]:1: in main chunk /home/chris/Projects/lua/symmath/tests/unit/unit.lua:252: in function [C]: in function 'xpcall' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:251: in function 'exec' match.lua:233: in function 'cb' [string "/home/chris/Projects/lua/ext/timer.lua"]:101: in function 'timer' match.lua:6: in main chunk [C]: at 0x641c16735390 |
time: 7.404000ms stack: size: 7
|
do local expr = (3*x*x + 2*x + 1):factorDivision() printbr('expr', expr) local a, b, c = expr:match(W{1, cannotDependOn=x} * x^2 + W{2, cannotDependOn=x} * x + W{3, cannotDependOn=x}) printbr('a', a) printbr('b', b) printbr('c', c) simplifyAssertAllEq({a, b, c}, {3, 2, 1}) end
|
expr ${1} + {{{2}} {{x}}} + {{{3}} {{{x}^{2}}}}$
a $3$ b $2$ c $1$ ${3} = {3}$ ${3} = {3}$ ${3} = {3}$ ${2} = {2}$ ${2} = {2}$ ${1} = {1}$ ${1} = {1}$ GOOD |
time: 11.823000ms stack: size: 7
|
do local expr = (1/(3*x*x + 2*x + 1)):factorDivision() printbr('expr', expr) local a, b, c = expr:match(1 / (W{1, cannotDependOn=x} * x^2 + W{2, cannotDependOn=x} * x + W{3, cannotDependOn=x})) printbr('a', a) printbr('b', b) printbr('c', c) simplifyAssertAllEq({a, b, c}, {3, 2, 1}) end
|
expr $\frac{1}{{1} + {{{2}} {{x}}} + {{{3}} {{{x}^{2}}}}}$
a $3$ b $2$ c $1$ ${3} = {3}$ ${3} = {3}$ ${3} = {3}$ ${2} = {2}$ ${2} = {2}$ ${1} = {1}$ ${1} = {1}$ GOOD |
time: 16.068000ms stack: size: 7
|
do local expr = (x/(3*x*x + 2*x + 1)):factorDivision() printbr('expr', expr) local a, b, c = expr:match(1 / (W{1, cannotDependOn=x} * x^2 + W{2, cannotDependOn=x} * x + W{3, cannotDependOn=x})) printbr('a', a) printbr('b', b) printbr('c', c) simplifyAssertAllEq({a, b, c}, {3, 2, 1}) end
|
expr ${{x}} {{\frac{1}{{1} + {{{2}} {{x}}} + {{{3}} {{{x}^{2}}}}}}}$
a false b nil c nil ${1} = {3}$ expected 1 to equal 3 found $1$ vs $3$ lhs stack Init $1$ 1 Prune $1$ 1 Expand $1$ 1 Prune $1$ 1 Factor $1$ 1 Prune $1$ 1 Tidy $1$ 1 rhs stack Init $3$ 3 Prune $3$ 3 Expand $3$ 3 Prune $3$ 3 Factor $3$ 3 Prune $3$ 3 Tidy $3$ 3 lhs: 1=false rhs: 1=3, 2=2, 3=1 BAD /home/chris/Projects/lua/symmath/tests/unit/unit.lua:138: failed stack traceback: /home/chris/Projects/lua/symmath/tests/unit/unit.lua:194: in function [C]: in function 'error' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:138: in function 'simplifyAssertEq' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:181: in function [C]: in function 'xpcall' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:180: in function 'simplifyAssertAllEq' [string "do local expr = (x/(3*x*x + 2*x + 1)):factorD..."]:1: in main chunk /home/chris/Projects/lua/symmath/tests/unit/unit.lua:252: in function [C]: in function 'xpcall' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:251: in function 'exec' match.lua:233: in function 'cb' [string "/home/chris/Projects/lua/ext/timer.lua"]:101: in function 'timer' match.lua:6: in main chunk [C]: at 0x641c16735390 14 BAD /home/chris/Projects/lua/symmath/tests/unit/unit.lua:196: failed stack traceback: /home/chris/Projects/lua/symmath/tests/unit/unit.lua:260: in function [C]: in function 'error' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:196: in function 'simplifyAssertAllEq' [string "do local expr = (x/(3*x*x + 2*x + 1)):factorD..."]:1: in main chunk /home/chris/Projects/lua/symmath/tests/unit/unit.lua:252: in function [C]: in function 'xpcall' /home/chris/Projects/lua/symmath/tests/unit/unit.lua:251: in function 'exec' match.lua:233: in function 'cb' [string "/home/chris/Projects/lua/ext/timer.lua"]:101: in function 'timer' match.lua:6: in main chunk [C]: at 0x641c16735390 |
time: 21.083000ms stack: size: 7
|
|
| ||
|
TensorRef | ||
|
| ||
local a = x'^i':match(Tensor.Ref(x, W(1))) simplifyAssertEq(a, Tensor.Index{symbol='i', lower=false})
|
${^i} = {^i}$
GOOD |
time: 0.399000ms stack: size: 7
|