Ask Your Question

Revision history [back]

There is no distinction between row vector and column vector in Sagemath

sage: v = vector((1,2,3))
sage: A = matrix(3, [1, -2, 3, 0, 1, -1, 2, 0, -2])
sage: A * v
(6, -1, -4)
sage: v * A
(7, 0, -5)

And vectors are different from 1 x n and n x 1 matrices which make a difference between rows and columns

sage: col_v = matrix(3, 1, [1, 2, 3])
sage: print(col_v)
[1]
[2]
[3]
sage: A * col_v
[ 6]
[-1]
[-4]

sage: row_v = matrix(1, 3, [1, 2, 3])
sage: print(row_v)
[1 2 3]
sage: row_v * A
[ 7  0 -5]

Of course both A * row_v and col_v * A will fail.

There is no distinction between row vector and column vector in Sagemath

sage: v = vector((1,2,3))
sage: A = matrix(3, [1, -2, 3, 0, 1, -1, 2, 0, -2])
sage: A * v
(6, -1, -4)
sage: v * A
(7, 0, -5)

And Sagemath vectors are different from objects than 1 x n and or n x 1 matrices which matrices. Matrices make a difference between rows and columns

sage: col_v = matrix(3, 1, [1, 2, 3])
sage: print(col_v)
[1]
[2]
[3]
sage: A * col_v
[ 6]
[-1]
[-4]

sage: row_v = matrix(1, 3, [1, 2, 3])
sage: print(row_v)
[1 2 3]
sage: row_v * A
[ 7  0 -5]

Of course both A * row_v and col_v * A will fail.