Ask Your Question
0

Can I define an n-dimensional matrix?

asked 11 years ago

mudd1 gravatar image

updated 11 years ago

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
Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 11 years ago

tmonteil gravatar image

updated 11 years ago

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.

Preview: (hide)
link

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 ( 11 years ago )

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 ( 6 years ago )

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: 11 years ago

Seen: 723 times

Last updated: Jun 16 '13