They don't work when the subexpressions aren't Exprs. For example the
iterable symbols defaults to be a list of Symbol objects.
In [1]: A, B = MatrixSymbol('A', n, n), MatrixSymbol('B', n, n)
In [2]: count_ops(A*B+A*B)
Out[2]: 0
In [3]: cse(A*B+A*B)
TypeError: object of type 'Symbol' has no len()
On Mon, Apr 8, 2013 at 2:46 PM, Chris Smith <[email protected]> wrote:
> both are implemented to work on Basic:
>
> >>> cse(Basic(exp(x), exp(x) + y, x/y))
> ([(x0, exp(x))], [Basic(x0, x0 + y, x/y)])
> >>> count_ops(Basic(exp(x), exp(x) + y, x/y))
> 4
>
>
> On Tue, Apr 9, 2013 at 1:27 AM, Matthew Rocklin <[email protected]>wrote:
>
>> Do we have implementations of tools like common subexpression elimination
>> (cse) and operation counting (count_ops) that aren't specific to Exprs?
>> What do we have that is designed to work on Basics?
>>
>> I want to collect some very basic data on some large MatrixExprs (common
>> subexprssions and number of operations in the graph) and want to make sure
>> I'm not reinventing some wheel.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sympy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/sympy?hl=en-US.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.