millionchart
فارسی

Matrices reference

The 49 functions and 0 values of matrix: signature, effects, phase, cost and tested examples.

A matrix is a table of numbers with rows and columns, with the usual linear algebra.

Functions#

matrix.add#

matrix.add([matrix], [other])

A new matrix where another matrix of the same size, or a number, is added to every element.

  • Effects: builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.
  • Returns: a matrix.

matrix.add_column#

matrix.add_column([matrix], [column], [array_id])

Inserts a column at an index (at the end without one), filled from an array or with na.

  • Effects: changes a collection in place; builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.

matrix.add_row#

matrix.add_row([matrix], [row], [array_id])

Inserts a row at an index (at the end without one), filled from an array or with na.

  • Effects: changes a collection in place; builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.

matrix.at#

matrix.at([matrix], [row], [column])

The element at a row and a column.

matrix.avg#

matrix.avg([matrix])

The average of all elements of the matrix.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.
  • Returns: a number.

matrix.column#

matrix.column([matrix], [column])

A copy of one column as an array.

  • Effects: builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.
  • Returns: an array.

matrix.columns#

matrix.columns([matrix])

The number of rows or columns.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.concat#

matrix.concat([matrix], [other])

Appends the rows of another matrix below the matrix; both need the same number of columns.

  • Effects: changes a collection in place; builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.
  • Returns: the matrix.

matrix.copy#

matrix.copy([matrix])

Makes a copy.

  • Effects: builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.

matrix.count#

matrix.count([matrix])

The number of elements of the matrix: rows times columns.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.
  • Returns: a whole number.

matrix.det#

matrix.det([matrix])

The determinant of a square matrix.

matrix.eigenvalues#

matrix.eigenvalues([matrix])

The eigenvalues of a square matrix.

  • Effects: builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.
  • Returns: an array of numbers.

matrix.eigenvectors#

matrix.eigenvectors([matrix])

The eigenvectors of a square matrix, one in each column.

  • Effects: builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.
  • Returns: a matrix.

matrix.fill#

matrix.fill([matrix], [value], [from_row], [to_row], [from_column], [to_column])

Sets a block of the matrix to one value; without a block it fills the whole matrix.

  • Effects: changes a collection in place.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.inv#

matrix.inv([matrix])

The inverse of a square matrix.

  • Effects: builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.

matrix.is_antidiagonal#

matrix.is_antidiagonal([matrix])

True when the matrix is antidiagonal.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.is_antisymmetric#

matrix.is_antisymmetric([matrix])

True when the matrix is antisymmetric.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.is_binary#

matrix.is_binary([matrix])

True when the matrix is binary.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.is_diagonal#

matrix.is_diagonal([matrix])

True when the matrix is diagonal.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.is_identity#

matrix.is_identity([matrix])

True when the matrix is identity.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.is_square#

matrix.is_square([matrix])

True when the matrix is square.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.is_stochastic#

matrix.is_stochastic([matrix])

True when the matrix is stochastic.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.is_symmetric#

matrix.is_symmetric([matrix])

True when the matrix is symmetric.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.is_triangular#

matrix.is_triangular([matrix])

True when the matrix is triangular.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.is_zero#

matrix.is_zero([matrix])

True when the matrix is zero.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.kron#

matrix.kron([matrix], [other])

The Kronecker product of two matrices.

  • Effects: builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.
  • Returns: a matrix.

matrix.max#

matrix.max([matrix])

The greatest element of the matrix.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.
  • Returns: a number.

matrix.median#

matrix.median([matrix])

The median of all elements of the matrix.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.
  • Returns: a number.

matrix.min#

matrix.min([matrix])

The smallest element of the matrix.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.
  • Returns: a number.

matrix.mode#

matrix.mode([matrix])

The most frequent element of the matrix.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.
  • Returns: a number.

matrix.multiply#

matrix.multiply([matrix], [other])

The product of two matrices, or of a matrix and a number.

  • Effects: builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.

matrix.new#

matrix.new([rows], [columns], [initial])

Makes a matrix of rows by columns, each element initial.

  • Effects: builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.

matrix.pinv#

matrix.pinv([matrix])

The pseudo-inverse of a matrix.

  • Effects: builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.
  • Returns: a matrix.

matrix.pow#

matrix.pow([matrix], [exponent])

The matrix multiplied by itself exponent times; the exponent is a whole number from 0 and the matrix is square.

  • Effects: builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.
  • Returns: a matrix.

matrix.rank#

matrix.rank([matrix])

The rank of the matrix: how many rows are independent of the others.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.
  • Returns: a whole number.

matrix.remove_column#

matrix.remove_column([matrix], [column])

Removes one column.

  • Effects: changes a collection in place; builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.

matrix.remove_row#

matrix.remove_row([matrix], [row])

Removes one row.

  • Effects: changes a collection in place; builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.

matrix.reshape#

matrix.reshape([matrix], [rows], [columns])

Gives the same elements a new number of rows and columns; the count of elements must not change.

  • Effects: changes a collection in place.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.reverse#

matrix.reverse([matrix])

Reverses the order of the elements in the same place.

  • Effects: changes a collection in place.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.row#

matrix.row([matrix], [row])

A copy of one row as an array.

matrix.rows#

matrix.rows([matrix])

The number of rows or columns.

  • Effects: none: the result depends on the arguments only.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.set#

matrix.set([matrix], [row], [column], [value])

Sets the element at a row and a column.

matrix.slice#

matrix.slice([matrix], [from_row], [to_row], [from_column], [to_column])

A new matrix with the rows from from_row up to, not including, to_row and the columns from from_column up to, not including, to_column.

  • Effects: builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.
  • Returns: a matrix.

matrix.sort#

matrix.sort([matrix], [column], [order])

Sorts the rows by the values of one column, ascending or descending.

  • Effects: changes a collection in place.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.subtract#

matrix.subtract([matrix], [other])

A new matrix where another matrix of the same size, or a number, is subtracted from every element.

  • Effects: builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.
  • Returns: a matrix.

matrix.swap_columns#

matrix.swap_columns([matrix], [column1], [column2])

Swaps two columns.

  • Effects: changes a collection in place.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.swap_rows#

matrix.swap_rows([matrix], [row1], [row2])

Swaps two rows.

  • Effects: changes a collection in place.
  • Phase: every bar.
  • Cost: a fixed number of operations.

matrix.trace#

matrix.trace([matrix])

The sum of the elements on the main diagonal of a square matrix.

matrix.transpose#

matrix.transpose([matrix])

The transposed matrix.

  • Effects: builds a new value whose size follows its arguments (counted in the memory ledger).
  • Phase: every bar.
  • Cost: allocates: the memory ledger counts what it builds.