Ask Your Question
0

How to generate a nonsquare Vandermonde matrix?

asked 2019-07-11 10:13:46 +0100

qbyte gravatar image

According to the documentation, we can generate a Vandermonde matrix using the method matrix.vandermonde() or vandermonde().

But they generate only square matrix. How do we generate a Vandermonde matrix which is not a square matrix?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-07-11 11:16:33 +0100

rburing gravatar image

Enter matrix.vandermonde?? to see the source code (3 lines long). We can extend the functionality:

def my_vandermonde(v, ncols=None, ring=None):
    def entries(i, j):
        return v[i]**j
    if ncols is None:
        ncols = len(v)
    return matrix(entries, nrows=len(v), ncols=ncols, ring=ring)

The relative inefficiency here (taking powers instead of repeatedly multiplying) is copied from the original.

Then you can do for instance:

sage: my_vandermonde([2,3,4], 4)
[ 1  2  4  8]
[ 1  3  9 27]
[ 1  4 16 64]
edit flag offensive delete link more

Comments

Thank you for the answer.

qbyte gravatar imageqbyte ( 2019-07-12 15:09:53 +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: 2019-07-11 10:13:46 +0100

Seen: 843 times

Last updated: Jul 11 '19