torch.linalg.vander#
- torch.linalg.vander(x,N=None)→Tensor#
Generates a Vandermonde matrix.
Returns the Vandermonde matrix
forN > 1.If
N= None, thenN = x.size(-1) so that the output is a square matrix.Supports inputs of float, double, cfloat, cdouble, and integral dtypes.Also supports batches of vectors, and if
xis a batch of vectors thenthe output has the same batch dimensions.Differences withnumpy.vander:
Unlikenumpy.vander, this function returns the powers of
xin ascending order.To get them in the reverse order calllinalg.vander(x,N).flip(-1).
- Parameters
x (Tensor) – tensor of shape(*, n) where* is zero or more batch dimensionsconsisting of vectors.
- Keyword Arguments
N (int,optional) – Number of columns in the output. Default:x.size(-1)
Example:
>>>x=torch.tensor([1,2,3,5])>>>linalg.vander(x)tensor([[ 1, 1, 1, 1], [ 1, 2, 4, 8], [ 1, 3, 9, 27], [ 1, 5, 25, 125]])>>>linalg.vander(x,N=3)tensor([[ 1, 1, 1], [ 1, 2, 4], [ 1, 3, 9], [ 1, 5, 25]])