On Thu, Dec 10, 2009 at 4:54 AM, Dag Sverre Seljebotn <da...@student.matnat.uio.no> 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 think that is right, and I don't think this is intentional. > I don't know if you do code in custom behaviour with non-Sage objects, > but anyway: We do... > 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 > 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. I think the above makes a lot of sense to me, at least. -- William -- 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