You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you look carefully at the expressions in the two matrices you'll see repeated expressions. These are not ideal in the sense that the computer has to repeat the exact same calculation multiple times. For large expressions this can be a major issue. Compilers, such as gcc, can often eliminate common subexpressions on their own when different optimization flags are invoked but for complex expressions the algorithms in some compilers do not do a thorough job or compilation can take an extremely long time. SymPy has tools to perform common subexpression elimination which is both thorough and reasonably efficient. In particular if gcc is run with the lowest optimization setting -O0, cse can give large speedups.
slel
changed the title
Is there any equivalante to sympy cse method? (Common Subexpression Elimination)
Provide common subexpression elimination, cf. SymPy's cseFeb 9, 2022
Explanation copied from:
Common Subexpression Elimination
If you look carefully at the expressions in the two matrices you'll see repeated expressions. These are not ideal in the sense that the computer has to repeat the exact same calculation multiple times. For large expressions this can be a major issue. Compilers, such as gcc, can often eliminate common subexpressions on their own when different optimization flags are invoked but for complex expressions the algorithms in some compilers do not do a thorough job or compilation can take an extremely long time. SymPy has tools to perform common subexpression elimination which is both thorough and reasonably efficient. In particular if
gcc
is run with the lowest optimization setting-O0
,cse
can give large speedups.For example if you have two expressions:
you can convert this to these three expressions:
and
x*y
only has to be computed once.The
cse()
function in SymPy returnsz = x*y
, anda = z + 5
,b = z + 6
.Here is how it works:
Is there something like this in SageMath?
CC: @slel
Component: symbolics
Issue created by migration from https://trac.sagemath.org/ticket/33315
The text was updated successfully, but these errors were encountered: