Generate a Vandermonde matrix. 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
(x, N=None, increasing=False)
| 586 | # Originally borrowed from John Hunter and matplotlib |
| 587 | @array_function_dispatch(_vander_dispatcher) |
| 588 | def vander(x, N=None, increasing=False): |
| 589 | """ |
| 590 | Generate a Vandermonde matrix. |
| 591 | |
| 592 | The columns of the output matrix are powers of the input vector. The |
| 593 | order of the powers is determined by the `increasing` boolean argument. |
| 594 | Specifically, when `increasing` is False, the `i`-th output column is |
| 595 | the input vector raised element-wise to the power of ``N - i - 1``. Such |
| 596 | a matrix with a geometric progression in each row is named for Alexandre- |
| 597 | Theophile Vandermonde. |
| 598 | |
| 599 | Parameters |
| 600 | ---------- |
| 601 | x : array_like |
| 602 | 1-D input array. |
| 603 | N : int, optional |
| 604 | Number of columns in the output. If `N` is not specified, a square |
| 605 | array is returned (``N = len(x)``). |
| 606 | increasing : bool, optional |
| 607 | Order of the powers of the columns. If True, the powers increase |
| 608 | from left to right, if False (the default) they are reversed. |
| 609 | |
| 610 | Returns |
| 611 | ------- |
| 612 | out : ndarray |
| 613 | Vandermonde matrix. If `increasing` is False, the first column is |
| 614 | ``x^(N-1)``, the second ``x^(N-2)`` and so forth. If `increasing` is |
| 615 | True, the columns are ``x^0, x^1, ..., x^(N-1)``. |
| 616 | |
| 617 | See Also |
| 618 | -------- |
| 619 | polynomial.polynomial.polyvander |
| 620 | |
| 621 | Examples |
| 622 | -------- |
| 623 | >>> import numpy as np |
| 624 | >>> x = np.array([1, 2, 3, 5]) |
| 625 | >>> N = 3 |
| 626 | >>> np.vander(x, N) |
| 627 | array([[ 1, 1, 1], |
| 628 | [ 4, 2, 1], |
| 629 | [ 9, 3, 1], |
| 630 | [25, 5, 1]]) |
| 631 | |
| 632 | >>> np.column_stack([x**(N-1-i) for i in range(N)]) |
| 633 | array([[ 1, 1, 1], |
| 634 | [ 4, 2, 1], |
| 635 | [ 9, 3, 1], |
| 636 | [25, 5, 1]]) |
| 637 | |
| 638 | >>> x = np.array([1, 2, 3, 5]) |
| 639 | >>> np.vander(x) |
| 640 | array([[ 1, 1, 1, 1], |
| 641 | [ 8, 4, 2, 1], |
| 642 | [ 27, 9, 3, 1], |
| 643 | [125, 25, 5, 1]]) |
| 644 | >>> np.vander(x, increasing=True) |
| 645 | array([[ 1, 1, 1, 1], |
searching dependent graphs…