bundles / numpy 2.4.4 / numpy / ma / extras / vander
function
numpy.ma.extras:vander
source: /numpy/ma/extras.py :2216
Signature
def vander ( x , n = None ) Summary
Generate a Vandermonde matrix.
Extended Summary
The columns of the output matrix are powers of the input vector. The order of the powers is determined by the increasing boolean argument. Specifically, when increasing is False, the i-th output column is the input vector raised element-wise to the power of N - i - 1. Such a matrix with a geometric progression in each row is named for Alexandre- Theophile Vandermonde.
Parameters
x: array_like1-D input array.
N: int, optionalNumber of columns in the output. If N is not specified, a square array is returned (
N = len(x)).increasing: bool, optionalOrder of the powers of the columns. If True, the powers increase from left to right, if False (the default) they are reversed.
Returns
out: ndarrayVandermonde matrix. If increasing is False, the first column is
x^(N-1), the secondx^(N-2)and so forth. If increasing is True, the columns arex^0, x^1, ..., x^(N-1).
Notes
Masked values in the input array result in rows of zeros.
Examples
import numpy as np x = np.array([1, 2, 3, 5]) N = 3 np.vander(x, N)✓
np.column_stack([x**(N-1-i) for i in range(N)])
✓x = np.array([1, 2, 3, 5]) np.vander(x) np.vander(x, increasing=True)✓
np.linalg.det(np.vander(x))
✗(5-3)*(5-2)*(5-1)*(3-2)*(3-1)*(2-1)
✓See also
Aliases
-
numpy.ma.vander