I think the real question here is, do we want most functions in sympy
to automatically vectorize over matrices (or similar objects)? And I
think the answer is no. Consider for example if we had an unevaluated
Matrix type that didn't multiply through by default (what
ImmutableMatrix used to be). We might want something like
simplify(A*B + A*C) to give A*(B + C), where A, B, and C are all
explicit unevaluated matrices.
It's similar to the reason that solve() does not automatically call
dsolve() on ODEs. It's useful to be able solve for the function
algebraically, i.e., both
>>> dsolve(f(x).diff(x, x) + f(x) - 1, f(x))
f(x) == C1*sin(x) + C2*cos(x) + 1
and
>>> solve(f(x).diff(x, x) + f(x) - 1, f(x))
[-Derivative(f(x), x, x) + 1]
can be useful.
Another good argument for matrices is exp(). We want exp(Matrix) to
give the exponential of a Matrix, which is not the matrix of
exponentials. And actually you can define f(Matrix) for any analytic
f. Won't it be a little confusing if math_function(Matrix) works
different from simplify_function(Matrix)? And again, what if you have
simplify_function(combination_of_math_functions(unevaluated_matrices))?
And aside from that, automatic vectorization would be a mess, because
only the most popular functions would support it, and the rest
wouldn't. So we would end up with a situation where function `a`
works as expected, but very similar function `b` doesn't, and it's not
clear why (and even if `b` doesn't support it, it doesn't mean that
Matrix defines `_b`). It's similar to automatic sympification of
strings that some but not all SymPy functions support.
Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To post to this group, send email to
sy...@googlegroups.com.
> To unsubscribe from this group, send email to
>
sympy+un...@googlegroups.com.
> For more options, visit this group at
>
http://groups.google.com/group/sympy?hl=en.