First time here? Check out the FAQ!

Ask Your Question
0

How to generate a nonsquare Vandermonde matrix?

asked 5 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 5 years ago

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

Comments

Thank you for the answer.

qbyte gravatar imageqbyte ( 5 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: 5 years ago

Seen: 1,025 times

Last updated: Jul 11 '19