Arrays Functions ================= .. py:function:: argmax(A) The index or indexes of the largest element in an array A. :param array A: An Array :rtype: float, array .. topic:: example .. math:: \text{argmax} \left( \begin{bmatrix} 2 & 1 \\ 3 & 4 \end{bmatrix} \right)= \begin{bmatrix} 1 \\ 1 \end{bmatrix} .. math:: \text{argmax} \left( \begin{bmatrix} 2 \\ 3 \\ 1 \end{bmatrix} \right)= 1 .. py:function:: argmin(A) The index or indexes of the smallest element in an array A. :param array A: An Array :rtype: float, array .. topic:: example .. math:: \text{argmin} \left( \begin{bmatrix} 2 & 1 \\ 3 & 4 \end{bmatrix} \right)= \begin{bmatrix} 0 \\ 1 \end{bmatrix} .. math:: \text{argmin} \left( \begin{bmatrix} 2 \\ 3 \\ 1 \end{bmatrix} \right)= 2 .. py:function:: cols(A) The number of columns of an array A. :param array A: An Array :rtype: integer .. topic:: example .. math:: \text{cols} \left( \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} \right)=2 .. py:function:: csort(A, j) The rows of A in the increasing order of its column j :param array A: An Array of numbers :param integer j: A number :rtype: array .. topic:: example .. math:: \text{csort} \left(\begin{bmatrix} 2 & 5 \\ 3 & 4 \end{bmatrix}, 1 \right)= \begin{bmatrix} 3 & 4 \\ 2 & 5 \end{bmatrix} .. py:function:: cumprod(A, [axis = 0|1]) cumulative products, of the same size, without units: of the elements of a vector, v₀, v₀·v₁…; of a matrix down its columns (axis 0, by default) or along its rows (axis 1) :param array A: An array of numbers :param integer axix: An integer :rtype: array .. topic:: example .. math:: \text{cumprod} \left(\begin{bmatrix} 4 & 2 & 3 \\ 2 & 4 & 2 \\ 3 & 2 & 4 \end{bmatrix}, 0 \right) = \begin{bmatrix} 4 & 2 & 3 \\ 8 & 8 & 6 \\ 24 & 16 & 24 \end{bmatrix} .. math:: \text{cumprod} \left(\begin{bmatrix} 4 & 2 & 3 \\ 2 & 4 & 2 \\ 3 & 2 & 4 \end{bmatrix}, 1 \right) = \begin{bmatrix} 4 & 8 & 24 \\ 2 & 8 & 16 \\ 3 & 6 & 24 \end{bmatrix} .. py:function:: cumsum(A, [axis = 0|1]) Cumulative sums, of the same size: of the elements of a vector, v₀, v₀ + v₁…; of a matrix down its columns (axis 0, by default) or along its rows (axis 1) :param array A: An array of numbers :param integer axix: An integer :rtype: array .. topic:: example .. math:: \text{cumsum} \left(\begin{bmatrix} 4 & 2 & 3 \\ 2 & 4 & 2 \\ 3 & 2 & 4 \end{bmatrix}, 0 \right) = \begin{bmatrix} 4 & 2 & 3 \\ 6 & 6 & 5 \\ 9 & 8 & 9 \end{bmatrix} .. py:function:: diag(A) Diagonal matrix of the vector A, or diagonal of the square matrix A :param array/integer A: An array of numbers or an integer :rtype: array .. topic:: example .. math:: \text{diag} \left(\begin{bmatrix} 4 \\ 2 \\ 3 \end{bmatrix} \right) = \begin{bmatrix} 4 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 3 \end{bmatrix} .. math:: \text{diag} \left( 3 \right)= \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} .. py:function:: identity(n) Creates identity matrix :param integer n: An integer :rtype: array .. topic:: example .. math:: \text{identity} \left( 3 \right) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} .. py:function:: last(v) Index of the last element of the vector v or of a list of texts, from ORIGIN :param array A: An array of numbers :rtype: integer .. topic:: example .. math:: \text{last} \left( \begin{bmatrix} 2 \\ 3 \\ 1 \end{bmatrix} \right) = 2 .. tip:: find the definition of ORIGIN :ref:`here ` .. py:function:: length(A) Number of elements of A, or of a list of texts :param array A: An array of numbers :rtype: integer .. topic:: example .. math:: \text{last} \left( \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} \right) = 9 .. py:function:: lookup(z, A, B) Number of elements of A, or of a list of texts :param float z: A float value :param array A: An array of numbers :param array B: An array of numbers :rtype: integer .. topic:: example .. math:: \text{lookup} \left(1, \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}, \begin{bmatrix} 3 & 4 & 5 \\ 6 & 7 & 8 \\ 9 & 10 & 11 \end{bmatrix} \right) = \begin{bmatrix} 3 \\ 7 \\ 11 \end{bmatrix} .. py:function:: match(z, A) Indices of the elements of the vector A, or of the list of texts, equal to z; of a matrix, a row (i, j) for each :param float z: A float value :param array A: An array of numbers :rtype: integer .. topic:: example .. math:: \text{match} \left(1, \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} \right) = \begin{bmatrix} 0 & 0 \\ 1 & 1 \\ 2 & 2 \end{bmatrix} .. py:function:: max(A, ..., [axis=0|1]) Greatest value of the numbers and arrays; with axis, of each column (0) or row (1) of A :param array A: An array of numbers :param integer axis: An integer value :rtype: integer .. topic:: example .. math:: \text{max} \left(\begin{bmatrix} 3 & 4 & 5 \\ 6 & 7 & 8 \\ 9 & 10 & 11 \end{bmatrix} \right) = 11 .. math:: \text{max} \left(\begin{bmatrix} 3 & 4 & 5 \\ 6 & 7 & 8 \\ 9 & 10 & 11 \end{bmatrix}, axis = 1 \right) = \begin{bmatrix} 5 \\ 8 \\ 11 \end{bmatrix} .. math:: \text{max} \left(\begin{bmatrix} 3 & 4 & 5 \\ 6 & 7 & 8 \\ 9 & 10 & 11 \end{bmatrix}, axis = 0 \right) = \begin{bmatrix} 9 & 10 & 11 \end{bmatrix} .. py:function:: min(A, ..., [axis=0|1]) Greatest value of the numbers and arrays; with axis, of each column (0) or row (1) of A :param array A: An array of numbers :param integer axis: An integer value :rtype: integer .. topic:: example .. math:: \text{min} \left(\begin{bmatrix} 3 & 4 & 5 \\ 6 & 7 & 8 \\ 9 & 10 & 11 \end{bmatrix} \right) = 3 .. math:: \text{min} \left(\begin{bmatrix} 3 & 4 & 5 \\ 6 & 7 & 8 \\ 9 & 10 & 11 \end{bmatrix}, axis = 1 \right) = \begin{bmatrix} 3 \\ 6 \\ 9 \end{bmatrix} .. math:: \text{min} \left(\begin{bmatrix} 3 & 4 & 5 \\ 6 & 7 & 8 \\ 9 & 10 & 11 \end{bmatrix}, axis = 0 \right) = \begin{bmatrix} 3 & 4 & 5 \end{bmatrix} .. py:function:: ones(m, [n]) m×n matrix of ones, square by default :param integer m: An integer value :param integer n: An integer value :rtype: integer .. topic:: example .. math:: \text{ones} \left(2,3 \right) = \begin{bmatrix} 1 & 1 & 1 \\ 1 & 1 & 1 \end{bmatrix} .. py:function:: range(n) Vector of 0, 1, …, n − 1 param integer n: An integer value :rtype: integer .. topic:: example .. math:: \text{range} \left(3 \right) = \begin{bmatrix} 0 \\ 1 \\ 2 \end{bmatrix} .. py:function:: reverse(V) elements of the vector v in reverse order :param array V: An array in the form of a vector :rtype: integer .. topic:: example .. math:: \text{reverse} \left( \text{range} (3) \right) = \begin{bmatrix} 2 \\ 1 \\ 0 \end{bmatrix} .. py:function:: rows(A) The number of rows of an array A. :param array A: An Array :rtype: integer .. topic:: example .. math:: \text{rows} \left( \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} \right)=2 .. py:function:: rsort(A, j) The cols of A in the increasing order of its row j, from ORIGIN :param array A: An Array of numbers :param integer j: A number :rtype: array .. tip:: find the definition of ORIGIN :ref:`here ` .. topic:: example .. math:: \text{rsort} \left(\begin{bmatrix} 2 & 5 \\ 6 & 4 \end{bmatrix}, 1 \right)= \begin{bmatrix} 5 & 2 \\ 4 & 6 \end{bmatrix} .. py:function:: sort(V) Elements of the vector V in increasing order :param array V: An Array of numbers in vector form :rtype: array .. topic:: example .. math:: \text{sort} \left(\begin{bmatrix} 2 & 5 & 6 & 4 \end{bmatrix} \right)= \begin{bmatrix} 2 & 4 & 5 & 6 \end{bmatrix} .. py:function:: stack(A, B) the arrays one above the other, with the same number of columns :param array V: An Array of numbers in vector form :rtype: array .. topic:: example .. math:: \text{sort} \left(\begin{bmatrix} 2 & 5 & 6 & 4 \end{bmatrix} \right)= \begin{bmatrix} 2 & 4 & 5 & 6 \end{bmatrix} .. py:function:: submatrix(A, ir, jr, ic, jc) Rows ir to jr and columns ic to jc of A, from ORIGIN :param array A: An Array of numbers in vector form :param integer ir: A number :param integer jr: A number :param integer ic: A number :param integer jc: A number :rtype: array .. tip:: find the definition of ORIGIN :ref:`here ` .. topic:: example .. math:: M := \text{diag}(\text{range(5} + 2) + 1 = \begin{bmatrix} 3 & 1 & 1 & 1 & 1 \\ 1 & 4 & 1 & 1 & 1 \\ 1 & 1 & 5 & 1 & 1 \\ 1 & 1 & 1 & 6 & 1 \\ 1 & 1 & 1 & 1 & 7 \end{bmatrix} .. math:: \text{submatrix}(M,1,3,2,4) = \begin{bmatrix} 1 & 1 & 1 \\ 5 & 1 & 1 \\ 1 & 6 & 1 \end{bmatrix} .. py:function:: sum(A, ..., [axis=0|1|] sum of all the elements of the numbers and arrays; with axis, of each column (0) or row (1) of A :param array A: An array of numbers :param integer axis: An integer value :rtype: integer .. topic:: example .. math:: \text{sum} \left(\begin{bmatrix} 3 & 4 & 5 \\ 6 & 7 & 8 \\ 9 & 10 & 11 \end{bmatrix} \right) = 63 .. math:: \text{sum} \left(\begin{bmatrix} 3 & 4 & 5 \\ 6 & 7 & 8 \\ 9 & 10 & 11 \end{bmatrix}, axis = 1 \right) = \begin{bmatrix} 12 \\ 21 \\ 30 \end{bmatrix} .. math:: \text{sum} \left(\begin{bmatrix} 3 & 4 & 5 \\ 6 & 7 & 8 \\ 9 & 10 & 11 \end{bmatrix}, axis = 0 \right) = \begin{bmatrix} 18 & 21 & 24 \end{bmatrix} .. py:function:: zeros(m, [n]) m×n matrix of zeros, square without n :param integer m: An integer value :param integer n: An integer value