Ask Your Question
0

Can I define an n-dimensional matrix?

asked 2013-06-15 15:52:18 +0100

mudd1 gravatar image

updated 2013-06-15 16:09:28 +0100

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 n to int
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2013-06-16 08:41:07 +0100

tmonteil gravatar image

updated 2013-06-16 08:51:19 +0100

There is no way to define a MatrixSpace without fixing the number of columns and rows. You can see this by looking into the code:

sage: MatrixSpace??
    [...]
    def __init__(self,...
    [...]
        nrows = int(nrows)
        ncols = int(ncols)

Hence, Sage can not accept a symbolic variable n as the number of columns/rows.

A question remains : what do you want to ask to Sage about such a general matrix space where entries are not determined ? There maybe a workaround for a precise question.

edit flag offensive delete link more

Comments

Well, generally what I'd like to do is some linear algebra without specifying the number of dimensions but just getting results that are true for arbitrary *n*. Guess that was to general an answer? I figured out my current problems by hand but it'd still be nice to have a software that can do such things.

mudd1 gravatar imagemudd1 ( 2013-06-16 19:43:51 +0100 )edit

I have the same issue. I want to compute an expression, similar to: sum{K_i * sen(alpha_i)} where i goes from 1 to n, being n also a variable.

clon gravatar imageclon ( 2019-03-05 15:09:24 +0100 )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

Stats

Asked: 2013-06-15 15:52:18 +0100

Seen: 670 times

Last updated: Jun 16 '13