function mtimes
mtimes(
x: number,
y: number,
): number

Matrix multiplication.

Performs matrix multiplication of two matrices or arrays. For arrays, treats them as column vectors.

Examples

Multiply two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes(2, 3), 6);

Multiply matrix by scalar

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], 2), [[2, 4], [6, 8]]);

Multiply two matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [[5, 6], [7, 8]]), [[19, 22], [43, 50]]);

Multiply matrix by column vector (array)

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [5, 6]), [17, 39]);

Parameters

x: number

The first operand, can be a number, array (treated as column vector), or matrix

y: number

The second operand, can be a number, array (treated as column vector), or matrix

Return Type

number

The result of matrix multiplication of x and y

Throws

If matrix dimensions do not agree for multiplication or if no arguments are provided

mtimes(
x: number,
y: array,
): array

Matrix multiplication.

Performs matrix multiplication of two matrices or arrays. For arrays, treats them as column vectors.

Examples

Multiply two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes(2, 3), 6);

Multiply matrix by scalar

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], 2), [[2, 4], [6, 8]]);

Multiply two matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [[5, 6], [7, 8]]), [[19, 22], [43, 50]]);

Multiply matrix by column vector (array)

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [5, 6]), [17, 39]);

Parameters

x: number

The first operand, can be a number, array (treated as column vector), or matrix

The second operand, can be a number, array (treated as column vector), or matrix

Return Type

The result of matrix multiplication of x and y

Throws

If matrix dimensions do not agree for multiplication or if no arguments are provided

mtimes(
x: array,
y: number,
): array

Matrix multiplication.

Performs matrix multiplication of two matrices or arrays. For arrays, treats them as column vectors.

Examples

Multiply two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes(2, 3), 6);

Multiply matrix by scalar

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], 2), [[2, 4], [6, 8]]);

Multiply two matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [[5, 6], [7, 8]]), [[19, 22], [43, 50]]);

Multiply matrix by column vector (array)

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [5, 6]), [17, 39]);

Parameters

The first operand, can be a number, array (treated as column vector), or matrix

y: number

The second operand, can be a number, array (treated as column vector), or matrix

Return Type

The result of matrix multiplication of x and y

Throws

If matrix dimensions do not agree for multiplication or if no arguments are provided

mtimes(
x: array,
y: array,
): number

Matrix multiplication.

Performs matrix multiplication of two matrices or arrays. For arrays, treats them as column vectors.

Examples

Multiply two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes(2, 3), 6);

Multiply matrix by scalar

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], 2), [[2, 4], [6, 8]]);

Multiply two matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [[5, 6], [7, 8]]), [[19, 22], [43, 50]]);

Multiply matrix by column vector (array)

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [5, 6]), [17, 39]);

Parameters

The first operand, can be a number, array (treated as column vector), or matrix

The second operand, can be a number, array (treated as column vector), or matrix

Return Type

number

The result of matrix multiplication of x and y

Throws

If matrix dimensions do not agree for multiplication or if no arguments are provided

mtimes(
x: number,
y: matrix,
): matrix

Matrix multiplication.

Performs matrix multiplication of two matrices or arrays. For arrays, treats them as column vectors.

Examples

Multiply two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes(2, 3), 6);

Multiply matrix by scalar

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], 2), [[2, 4], [6, 8]]);

Multiply two matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [[5, 6], [7, 8]]), [[19, 22], [43, 50]]);

Multiply matrix by column vector (array)

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [5, 6]), [17, 39]);

Parameters

x: number

The first operand, can be a number, array (treated as column vector), or matrix

The second operand, can be a number, array (treated as column vector), or matrix

Return Type

The result of matrix multiplication of x and y

Throws

If matrix dimensions do not agree for multiplication or if no arguments are provided

mtimes(
x: matrix,
y: number,
): matrix

Matrix multiplication.

Performs matrix multiplication of two matrices or arrays. For arrays, treats them as column vectors.

Examples

Multiply two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes(2, 3), 6);

Multiply matrix by scalar

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], 2), [[2, 4], [6, 8]]);

Multiply two matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [[5, 6], [7, 8]]), [[19, 22], [43, 50]]);

Multiply matrix by column vector (array)

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [5, 6]), [17, 39]);

Parameters

The first operand, can be a number, array (treated as column vector), or matrix

y: number

The second operand, can be a number, array (treated as column vector), or matrix

Return Type

The result of matrix multiplication of x and y

Throws

If matrix dimensions do not agree for multiplication or if no arguments are provided

mtimes(
x: matrix,
y: array,
): array

Matrix multiplication.

Performs matrix multiplication of two matrices or arrays. For arrays, treats them as column vectors.

Examples

Multiply two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes(2, 3), 6);

Multiply matrix by scalar

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], 2), [[2, 4], [6, 8]]);

Multiply two matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [[5, 6], [7, 8]]), [[19, 22], [43, 50]]);

Multiply matrix by column vector (array)

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [5, 6]), [17, 39]);

Parameters

The first operand, can be a number, array (treated as column vector), or matrix

The second operand, can be a number, array (treated as column vector), or matrix

Return Type

The result of matrix multiplication of x and y

Throws

If matrix dimensions do not agree for multiplication or if no arguments are provided

mtimes(
x: array,
y: matrix,
): array

Matrix multiplication.

Performs matrix multiplication of two matrices or arrays. For arrays, treats them as column vectors.

Examples

Multiply two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes(2, 3), 6);

Multiply matrix by scalar

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], 2), [[2, 4], [6, 8]]);

Multiply two matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [[5, 6], [7, 8]]), [[19, 22], [43, 50]]);

Multiply matrix by column vector (array)

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [5, 6]), [17, 39]);

Parameters

The first operand, can be a number, array (treated as column vector), or matrix

The second operand, can be a number, array (treated as column vector), or matrix

Return Type

The result of matrix multiplication of x and y

Throws

If matrix dimensions do not agree for multiplication or if no arguments are provided

mtimes(
x: matrix,
y: matrix,
): matrix

Matrix multiplication.

Performs matrix multiplication of two matrices or arrays. For arrays, treats them as column vectors.

Examples

Multiply two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes(2, 3), 6);

Multiply matrix by scalar

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], 2), [[2, 4], [6, 8]]);

Multiply two matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [[5, 6], [7, 8]]), [[19, 22], [43, 50]]);

Multiply matrix by column vector (array)

import { assertEquals } from "jsr:@std/assert";

assertEquals(mtimes([[1, 2], [3, 4]], [5, 6]), [17, 39]);

Parameters

The first operand, can be a number, array (treated as column vector), or matrix

The second operand, can be a number, array (treated as column vector), or matrix

Return Type

The result of matrix multiplication of x and y

Throws

If matrix dimensions do not agree for multiplication or if no arguments are provided