Ask Your Question

Can I define an n-dimensional matrix?

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

mudd1 gravatar image

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

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

assume(n, 'integer')
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

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

tmonteil gravatar image

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

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


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 +0200 )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 +0200 )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: 2013-06-15 15:52:18 +0200

Seen: 495 times

Last updated: Jun 16 '13