Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Another way to understand @Max Alekseyev 's answer :

A vector is a vector is a vector, id est a rank 1 object (object having one dimension, its length). The so called "row" and "column" vectors are a delusion (or hallucination) imposed upon american undergraduates. Rank 2 objects are matrices, which have two dimensions.

(P.S. - that may explain why the vector object does not support the transpose operator ?)

Indeed : "transpose" means "swap dimensions", which is meaningful for rank 2 objects and meaningless for rank 1 objects...

Conformability : V is conformable at the left of M if its length is equal to, the number of columns of M ; it is conformable at the right of M if its length is equal to, the number of rows of M. Illustration :

sage: V=vector(var("v", n=3)) ; V
(v0, v1, v2)
sage: W=vector(var("w", n=2)) ; W
(w0, w1)
sage: M=matrix(var("m", n=6), ncols=2, nrows=3) ; M
[m0 m1]
[m2 m3]
[m4 m5]
sage: V*M # Conformant
(m0*v0 + m2*v1 + m4*v2, m1*v0 + m3*v1 + m5*v2)
sage: M*W # Also conformant
(m0*w0 + m1*w1, m2*w0 + m3*w1, m4*w0 + m5*w1)
sage: M*V # Non confomant : this raise a TypeError
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[27], line 1
----> 1 M*V

File /usr/local/sage-10/src/sage/structure/element.pyx:4099, in sage.structure.element.Matrix.__mul__()
   4097 
   4098         if BOTH_ARE_ELEMENT(cl):
-> 4099             return coercion_model.bin_op(left, right, mul)
   4100 
   4101         cdef long value

File /usr/local/sage-10/src/sage/structure/coerce.pyx:1278, in sage.structure.coerce.CoercionModel.bin_op()
   1276     # We should really include the underlying error.
   1277     # This causes so much headache.
-> 1278     raise bin_op_exception(op, x, y)
   1279 
   1280 cpdef canonical_coercion(self, x, y) noexcept:

TypeError: unsupported operand parent(s) for *: 'Full MatrixSpace of 3 by 2 dense matrices over Symbolic Ring' and 'Vector space of dimension 3 over Symbolic Ring'
sage: W*M # Also nonconformant ; ditto...
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[28], line 1
----> 1 W*M

File /usr/local/sage-10/src/sage/structure/element.pyx:3685, in sage.structure.element.Vector.__mul__()
   3683     if have_same_parent(left, right):
   3684         return (<Vector>left)._dot_product_(<Vector>right)
-> 3685     return coercion_model.bin_op(left, right, mul)
   3686 
   3687 cpdef _dot_product_(Vector left, Vector right) noexcept:

File /usr/local/sage-10/src/sage/structure/coerce.pyx:1278, in sage.structure.coerce.CoercionModel.bin_op()
   1276     # We should really include the underlying error.
   1277     # This causes so much headache.
-> 1278     raise bin_op_exception(op, x, y)
   1279 
   1280 cpdef canonical_coercion(self, x, y) noexcept:

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

Note :I never encountered the distinction during my initial education (in France, at a time where vectors were informally introduced in 9th grade (to allow their use in physics starting in 10t grade), and formally studied (along with elementary matrix algebra) in 11th grade). I met this silly distinction when reading american textbooks...

HTH,