1 | initial version |
First, you should notice that when you typed xT = x.transpose()
, you got the following deprecation warning :
DeprecationWarning: The transpose() method for vectors has been deprecated, use column() instead
(or check to see if you have a vector when you really want a matrix)
See http://trac.sagemath.org/10541 for details.
exec(code_obj, self.user_global_ns, self.user_ns)
In particular, x.transpose()
leads to a column matrix:
sage: x.transpose()
[x1]
[x2]
[x3]
[x4]
So it is OK if you multiply on the right, not on the left (which explains why xT*A
did not work):
sage: A * (x.transpose())
[2*x1 + x2 + 2*x3 - 6*x4]
[ -x1 + 2*x2 + x3 + 7*x4]
[ 3*x1 - x2 - 3*x3 - x4]
[ x1 + 5*x2 + 6*x3]
If you want to multiply on the left, you should use x.row()
:
sage: x.row()
[x1 x2 x3 x4]
sage: (x.row()) * A
[ 2*x1 - x2 + 3*x3 + x4 x1 + 2*x2 - x3 + 5*x4 2*x1 + x2 - 3*x3 + 6*x4 -6*x1 + 7*x2 - x3]
That said, vectors are not matrices, they are vertical/horizontal agnostic and adapt themselves to the situation:
sage: A*x
(2*x1 + x2 + 2*x3 - 6*x4, -x1 + 2*x2 + x3 + 7*x4, 3*x1 - x2 - 3*x3 - x4, x1 + 5*x2 + 6*x3)
sage: x*A
(2*x1 - x2 + 3*x3 + x4, x1 + 2*x2 - x3 + 5*x4, 2*x1 + x2 - 3*x3 + 6*x4, -6*x1 + 7*x2 - x3)
which explains why A*x
worked.