On Thu, Jun 5, 2008 at 4:32 PM, Robert Cimrman <[EMAIL PROTECTED]> wrote: > > Ondrej Certik wrote: >> I just discovered we probably need to think about this: >> >> In [1]: a = Matrix((1, x), (2, y)) >> >> In [2]: from numpy import array >> >> In [3]: a >> Out[3]: >> ⎡1 x⎤ >> ⎣2 y⎦ >> >> In [4]: Matrix(sin(array(a))) >> Out[4]: >> ⎡sin(1) sin(x)⎤ >> ⎣sin(2) sin(y)⎦ >> >> In [5]: sin(a) >> [...] >> >> AttributeError: 'Matrix' object has no attribute 'is_Number' >> >> >> What should [5] return? The same as [4] or the sin of a Matrix, which >> is defined as sin(A) = Q*sin(D)*Q^T if A = Q*D*Q^T and D is >> diagonal, so sin(D) is just the D with sin applied to the diagonal >> terms. > > This stuff generates neverending discussions on numpy lists. Numpy > currently solves this by having array (n-dimensional container) and > matrix (special 2d array w.r.t. multiplication and some functions). As
Well, not for sin: In [8]: from numpy import matrix, array, sin In [11]: a = matrix([[1,2],[3,0]]) In [12]: sin(a) Out[12]: matrix([[ 0.84147098, 0.90929743], [ 0.14112001, 0. ]]) In [13]: sin(array(a)) Out[13]: array([[ 0.84147098, 0.90929743], [ 0.14112001, 0. ]]) So that's not how I would like this to be. It should either work for all functions or for no functions. > Matrix in SymPy is a linear algebra matrix, it should IMHO behave as > such, i.e. sin(A) = Q*sin(D)*Q^T. Then maybe an Array would be usefull, > something like sympy version of list of lists [of lists...]. Yes, I think so too. Plus we could create some pure python arrray implementation, fully compatible with numpy. Ondrej --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---