1 | initial version |
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]