On Sun, Mar 11, 2012 at 3:55 PM, Matthew Rocklin <[email protected]> wrote:
> Right i**2 is a MatrixExpr. At some point someone suggested that we have
> unevaluated dense matrix expressions. This choice was made to satisfy that
> desire. We can change things around though.
>
> In [1]: X = ImmutableMatrix(3,3, range(9))
> In [4]: Y = ImmutableMatrix(ones(3, 3))
>
> In [6]: X*Y
> Out[6]:
> ⎡0  1  2⎤⋅⎡1  1  1⎤
> ⎢       ⎥ ⎢       ⎥
> ⎢3  4  5⎥ ⎢1  1  1⎥
> ⎢       ⎥ ⎢       ⎥
> ⎣6  7  8⎦ ⎣1  1  1⎦
>
> In [7]: (X*Y)[0,0] # indexing works
> Out[7]: 3
>
> In [8]: (X*Y).as_explicit()
> Out[8]:
> ⎡3   3   3 ⎤
> ⎢          ⎥
> ⎢12  12  12⎥
> ⎢          ⎥
> ⎣21  21  21⎦
>
> This isn't necessarily the way that things should be done though. One could
> imagine a number of alternatives. This conversation ties in well to the
> container vs. canonicalizer idea happening in this thread.

I added stub sections for MatrixExpr and ImmutableMatrix at
https://github.com/sympy/sympy/wiki/canonicalization.  It would be
great if you could write some stuff there, as I really don't have a
good idea of what it should be able to do.

Aaron Meurer

>
> -Matt
>
> On Sun, Mar 11, 2012 at 1:18 PM, [email protected]
> <[email protected]> wrote:
>>
>> Actually one can use as_explicit. I did not saw it in the
>> documentations, only when I checked the code I found about it.
>>
>> On 11 March 2012 21:14, [email protected]
>> <[email protected]> wrote:
>> > n [8]: i = ImmutableMatrix(eye(3))
>> >
>> > In [9]: i**2
>> > Out[9]:
>> >
>> >         2
>> > ⎡1  0  0⎤
>> > ⎢         ⎥
>> > ⎢0  1  0⎥
>> > ⎢         ⎥
>> > ⎣0  0  1⎦
>> >
>> > In [10]: _.doit()
>> > TypeError
>> >
>> > Casting to Matrix does not work either. How to actually calculate the
>> > product with Immutable matrices?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sympy" group.
>> To post to this group, send email to [email protected].
>> 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.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To post to this group, send email to [email protected].
> 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.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
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.

Reply via email to