Hi,

I got the following error in a Sage program I wrote:

TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of 2 by 1 
dense matrices over Integer Ring' and 'Full MatrixSpace of 2 by 2 dense 
matrices over Rational Field'

for the following instruction:

--> 152     vA = v.transpose() * invA

Here, v is a vector of dimension n, and invA is a n x n matrix.

In mathematics, a vector of dimension n is usually considered as a n x 1
matrix, thus to multiply it to the left of a n x n matrix, one has first
to transpose it.

sage: m = matrix(SR,[[a,b],[c,d]]); m

[a b]
[c d]

sage: v = vector(SR, [d,e]); v
(d, e)

sage: m * v
(a*d + e*b, c*d + e*d)

sage: v.transpose() * m
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/users/cacao/zimmerma/.sage/temp/patate.loria.fr/9803/_users_cacao_zimmerma_Adm_Cacao_ANC_Hadamard_algo2_sage_6.py
 in <module>()

/usr/local/sage-3.4-core2/sage/local/lib/python2.5/site-packages/sage/structure/element.so
 in sage.structure.element.Matrix.__mul__ (sage/structure/element.c:11263)()

/usr/local/sage-3.4-core2/sage/local/lib/python2.5/site-packages/sage/structure/coerce.so
 in sage.structure.coerce.CoercionModel_cache_maps.bin_op 
(sage/structure/coerce.c:5848)()

TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of 2 by 1 
dense matrices over Symbolic Ring' and 'Full MatrixSpace of 2 by 2 dense 
matrices over Symbolic Ring'

but v * m works:

sage: v * m
(a*d + e*c, b*d + e*d)

I find this rather counter-intuitive wrt mathematics. Is there any rationale?

Paul Zimmermann

--~--~---------~--~----~------------~-------~--~----~
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/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to