Function in prelude::math auto-imported

matmul

fn matmul<A, B, C>(A a, B b) -> C
Source: compiler/src/builtin_docs/prelude/math.hy

Multiplies two matrices written as nested fixed-length arrays.

a is [[T; K]; M] and b is [[T; N]; K]; the result is the row-major product [[T; N]; M]. A mismatched inner dimension is a compile-time error. For * as matrix multiplication, wrap the data with matrix.

Parameters#

NameType
aA
bB

Returns#

C

Examples#

use tests::assert;
let p = matmul([[1, 2], [3, 4]], [[5, 6], [7, 8]]);
assert!(p[0][0] == 19);
assert!(p[0][1] == 22);
assert!(p[1][0] == 43);
assert!(p[1][1] == 50);

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