Ask Your Question

# Revision history [back]

First, you can see of which kind are v and vC as follows:

sage: v.parent()
Ambient free module of rank 2 over the principal ideal domain Integer Ring

sage: vC.parent()
Full MatrixSpace of 2 by 1 dense matrices over Integer Ring


So, if you want v to be understood as a row matrix, you have to convert it as follows:

sage: Matrix(v)
[3 4]


Then, your product becomes valid:

sage: vC * Matrix(v)
[ 9 12]
[12 16]


First, you can see of which kind are v and vC as follows:

sage: v.parent()
Ambient free module of rank 2 over the principal ideal domain Integer Ring

sage: vC.parent()
Full MatrixSpace of 2 by 1 dense matrices over Integer Ring


So, if you want v to be understood as a row matrix, you have to convert it as follows:

sage: Matrix(v)
[3 4]


Then, your product becomes valid:

sage: vC * Matrix(v)
[ 9 12]
[12 16]


Note that you could work with matrices from the beginning:

sage: v = Matrix([[3, 4]]) ; v
[3 4]
sage: vC = v.transpose() ; vC
[3]
[4]
sage: vC * v
[ 9 12]
[12 16]


First, you can see of When multiplied to the right, a vector behaves like a column, when multiplied to the left, a vector behaves like a row. So your product is like multipliying a 21 by a 21 matrix, which kind are v and vC as follows:is invalid.

sage: v.parent()
Ambient free module of rank 2 over the principal ideal domain Integer Ring

sage: vC.parent()
Full MatrixSpace of 2 by 1 dense matrices over Integer Ring


So, if you want v to be understood as a row matrix, you have to convert it as follows:

sage: Matrix(v)
[3 4]


Then, your product becomes valid:

sage: vC * Matrix(v)
[ 9 12]
[12 16]


Note that you could work with matrices from the beginning:

sage: v = Matrix([[3, 4]]) ; v
[3 4]
sage: vC = v.transpose() ; vC
[3]
[4]
sage: vC * v
[ 9 12]
[12 16]


When multiplied to the right, a vector behaves like a column, column matrix, when multiplied to the left, a vector behaves like a row. row matrix. So your product is like multipliying a 21 by a 21 matrix, which is invalid.

So, if you want v to be understood as a row matrix, you have to convert it as follows:

sage: Matrix(v)
[3 4]


Then, your product becomes valid:

sage: vC * Matrix(v)
[ 9 12]
[12 16]


Note that you could work with matrices from the beginning:

sage: v = Matrix([[3, 4]]) ; v
[3 4]
sage: vC = v.transpose() ; vC
[3]
[4]
sage: vC * v
[ 9 12]
[12 16]


When multiplied to the right, a vector behaves like a column matrix, when multiplied to the left, a vector behaves like a row matrix. So your product is like multipliying a 21 $2\times 1$ by a 21 another $2\times 1$ matrix, which is invalid.

So, if you want v to be understood as a row matrix, you have to convert it as follows:

sage: Matrix(v)
[3 4]


Then, your product becomes valid:

sage: vC * Matrix(v)
[ 9 12]
[12 16]


Note that you could work with matrices from the beginning:

sage: v = Matrix([[3, 4]]) ; v
[3 4]
sage: vC = v.transpose() ; vC
[3]
[4]
sage: vC * v
[ 9 12]
[12 16]