Function in prelude::math auto-imported

matrix

fn matrix<D>(D rows) -> Matrix<D>
Source: compiler/src/builtin_docs/prelude/math.hy

Wraps nested fixed-length rows as a Matrix.

rows is nested numeric data such as [[int; 2]; 2] (or a tuple of equal-length rows). There is no runtime cost: the Matrix is the same data with a type that gives operators matrix meaning (see Matrix).

Parameters#

NameType
rowsD

Returns#

Matrix<D>

Examples#

use tests::assert;
let a = matrix([[1, 2], [3, 4]]);
let sq = a * a;
assert!(sq[0][0] == 7);
assert!(sq[1][1] == 22);

See also#

  • Matrix
  • sin: Returns the sine of x (in radians).
  • cos: Returns the cosine of x (in radians).
  • tan: Returns the tangent of x (in radians).
  • sqrt: Returns the square root of x.
  • floor: Returns the largest whole number less than or equal to x, as a float.
  • ceil: Returns the smallest whole number greater than or equal to x, as a float.
  • exp: Returns e raised to the power x.
↑ ↓ navigate ↵ open