1 | initial version |
There already is a way of constructing an object from a matrix that is callable and gives as a result a matrix-vector product:
sage: V=VectorSpace(QQ,2)
sage: M=matrix(QQ,2,2,[1,2,3,4])
sage: h=V.hom(M)
sage: h(V.0)
(1, 2)
sage: h(V.1)
(3, 4)
Note that vector spaces in sage are row vector spaces for most purposes, so you're getting the result of multiplying the vector to the right by the matrix. Judicious use of transposes should get you what you want.