Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Can I define an n-dimensional matrix?

I'm sure this is a basic question that has been asked before but I'm too stupid to find it.

What I'd like to do is something like this

k=var('n')
assume(n, 'integer')
assume(n>0)
VS = MatrixSpace(SR, n, 1)

to get the space of all n×1 matrices, i.e. column vectors. Is it at all possible to define a generalized n-dimensional vector or n×n matrix? Or am I just taking the completely wrong approach here?

click to hide/show revision 2
forgot to mention error message

Can I define an n-dimensional matrix?

I'm sure this is a basic question that has been asked before but I'm too stupid to find it.

What I'd like to do is something like this

k=var('n')
assume(n, 'integer')
assume(n>0)
VS = MatrixSpace(SR, n, 1)

to get the space of all n×1 matrices, i.e. column vectors. Is it at all possible to define a generalized n-dimensional vector or n×n matrix? Or am I just taking the completely wrong approach here?

Edit: Forgot to mention that the error I get is

ValueError: cannot convert k to int
click to hide/show revision 3
forgot to rename variable in error message

Can I define an n-dimensional matrix?

I'm sure this is a basic question that has been asked before but I'm too stupid to find it.

What I'd like to do is something like this

k=var('n')
assume(n, 'integer')
assume(n>0)
VS = MatrixSpace(SR, n, 1)

to get the space of all n×1 matrices, i.e. column vectors. Is it at all possible to define a generalized n-dimensional vector or n×n matrix? Or am I just taking the completely wrong approach here?

Edit: Forgot to mention that the error I get is

ValueError: cannot convert k n to int