vander¶
- paddle. vander ( x, n=None, increasing=False, name=None ) [source]
-
Generate a Vandermonde matrix.
The columns of the output matrix are powers of the input vector. Order of the powers is determined by the increasing Boolean parameter. Specifically, when the increment is “false”, the ith output column is a step-up in the order of the elements of the input vector to the N - i - 1 power. Such a matrix with a geometric progression in each row is named after Alexandre-Theophile Vandermonde.
- Parameters
-
x (Tensor) – The input tensor, it must be 1-D Tensor, and it’s data type should be [‘complex64’, ‘complex128’, ‘float32’, ‘float64’, ‘int32’, ‘int64’].
n (int) – Number of columns in the output. If n is not specified, a square array is returned (n = len(x)).
increasing (bool) – Order of the powers of the columns. If True, the powers increase from left to right, if False (the default) they are reversed.
name (str, optional) – For details, please refer to Name. Generally, no setting is required. Default: None.
- Returns
-
Tensor, A vandermonde matrix with shape (len(x), N). If increasing is False, the first column is \(x^{(N-1)}\), the second \(x^{(N-2)}\) and so forth. If increasing is True, the columns are \(x^0\), \(x^1\), …, \(x^{(N-1)}\).
Examples
>>> import paddle >>> x = paddle.to_tensor([1., 2., 3.], dtype="float32") >>> out = paddle.vander(x) >>> out Tensor(shape=[3, 3], dtype=float32, place=Place(cpu), stop_gradient=True, [[1., 1., 1.], [4., 2., 1.], [9., 3., 1.]]) >>> out1 = paddle.vander(x,2) >>> out1 Tensor(shape=[3, 2], dtype=float32, place=Place(cpu), stop_gradient=True, [[1., 1.], [2., 1.], [3., 1.]]) >>> out2 = paddle.vander(x, increasing = True) >>> out2 Tensor(shape=[3, 3], dtype=float32, place=Place(cpu), stop_gradient=True, [[1., 1., 1.], [1., 2., 4.], [1., 3., 9.]]) >>> real = paddle.to_tensor([2., 4.]) >>> imag = paddle.to_tensor([1., 3.]) >>> complex = paddle.complex(real, imag) >>> out3 = paddle.vander(complex) >>> out3 Tensor(shape=[2, 2], dtype=complex64, place=Place(cpu), stop_gradient=True, [[(2+1j), (1+0j)], [(4+3j), (1+0j)]])