Ask Your Question

Transpose of a column vector

asked 2015-01-12 12:04:10 -0500

Silvia gravatar image

Hi, I've got a column vector and I need to transpose it. But when i do: v=v.column() it says column() takes at least 1 positional argument (0 given)

I've also tried doing v=Matrix([[1, 0, 0],[0, 1, 0], [0, 0, 1],])*v.column() which worked before but still doesn't work.

What is the problem here?

Thank you

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2015-01-12 16:42:17 -0500

SL gravatar image

Note that you are trying to multiply a matrix by a list. Instead of using a list you should use another matrix. Here's a way you can do it:

m = Matrix([[1, 0, 0],[0, 1, 0], [0, 0, 1]])
v = Matrix(3,1,[1,2,3])
m * v

Note several things

  • m is the identity matrix, which you can create as m = Matrix.identity(3)
  • the vector v is created by giving the dimensions, 3x1 in this case, and then giving a list of entries read along the rows from left to right and from top to bottom.
edit flag offensive delete link more


Thank you for your reply. May I ask you what is the difference between a list and a vector?

Silvia gravatar imageSilvia ( 2015-01-14 03:41:20 -0500 )edit

Sage is written in the Python language. Python is an object-oriented programming language. You can think of an object as a way to store some data together with functions which operate on it an modify it. Everything in Python is an object; numbers are objects, lists are objects, etc. List is a very basic object which does not support many operations; you can index a list, you can join two lists, and you can do a few other things. Matrix is an object which supports many more operations. For example, you can compute the Jordan form of a matrix, you can multiply two matrices of appropriate sizes, etc. So a object of type Matrix corresponds better to the abstract mathematical notion of matrix than does an object of type list.

SL gravatar imageSL ( 2015-01-15 01:46:04 -0500 )edit

answered 2015-01-12 12:30:59 -0500

  1. Maybe you don't need to transpose your column vector. If A is a matrix and v is a vector, then A * v will use v as a column vector, and v * A will use v as a row vector.

  2. If you want to make v a row vector, you can do v.row().

  3. the column method is for extracting a column of a matrix. You need to specify the index of the column (from 0 to nrows - 1).


    sage: m = Matrix([[1, 1, 0],[0, 2, 0], [0, 0, 3],])
    sage: v = m.column(1)
    sage: v
    (1, 2, 0)
    sage: m * v
    (3, 4, 0)
    sage: v * m
    (1, 5, 0)
    sage: u = v.row()
    sage: u
    [1 2 0]
    sage: w = u.transpose()
    sage: w
    sage: u * w
    sage: w * u
    [1 2 0]
    [2 4 0]
    [0 0 0]
edit flag offensive delete link more


  1. I need to transpose the vector because when i use it in a sum it says unsupported operand parent(s) for '+': 'Full MatrixSpace of 3 by 1 dense matrices over Symbolic Ring' and 'Vector space of dimension 3 over Symbolic Ring' , so i thought maybe it was because it had to be a row vector.

    1. Why if i do v.row() it still says row() takes at least 1 positional argument (0 given) ?
Silvia gravatar imageSilvia ( 2015-01-12 16:17:55 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-01-12 12:04:10 -0500

Seen: 2,220 times

Last updated: Jan 12 '15