Dag Sverre Seljebotn wrote:
> I have a proposal about M * A, where M is a Sage matrix and A a NumPy 
> array. The current behaviour appears to be the Kronecker product; I'm 
> guessing that this is just be a side-effect of Python applying 
> element-wise __mul__ (if it is intentional and relied upon, this 
> proposal got harder).
>
> I don't know if you do code in custom behaviour with non-Sage objects, 
> but anyway:
>
> The suggestion is to have M (the Sage matrix) act as a linear 
> transformation on "stacked vectors", where the first axis of the array A 
> is used for right-mul and the last axis of A for left-mul. Example:
>
> sage: M=random_matrix(RDF, 3, 10)
> sage: A = numpy.ones((10, 23, 34), dtype=numpy.double)
> sage: type(M*A)
> <type 'numpy.ndarray'>
> sage: (M*A).shape
> (3, 23, 34)
> sage: (A*random_matrix(RDF, 34, 5)).shape
> (10, 23, 5)
>
> This maintains (S.transpose() * M.T).T = M*S, and is the matrix product 
>   
Sorry: (M.transpose() * A.T).T == A*M
> for 2-dimensional NumPy arrays. A doesn't represent anything in linear 
> algebra, it just causes (for convenience) repeated application of the 
> linear transformation to the rows/columns of A.
>
> I'd love to promise to implement it but I have no idea how hard it is to 
> pull off, so I'll promise two days of work if this is accepted and 
> somebody provides me with an attack plan.
>
> Dag Sverre
>
>   

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to