Jump to navigation

Namespace: matrixmath

Numbas.matrixmath

Matrix operations.

These operations are very lax about the dimensions of vectors - they stick zeros in when pairs of matrices don't line up exactly.

Source:

Methods

(static) abs(m) → {number}

Matrix determinant. Only works up to 3x3 matrices.

Parameters:
Name Type Description
m matrix
Throws:

"matrixmath.abs.too big" if the matrix has more than 3 rows.

Type
Numbas.Error
Returns:
Type Description
number
Source:

(static) add(a, b) → {matrix}

Add two matrices.

Parameters:
Name Type Description
a matrix
b matrix
Returns:
Type Description
matrix
Source:

(static) eq(a, b) → {boolean}

Are two matrices equal? True if each pair of corresponding elements is equal.

Parameters:
Name Type Description
a matrix
b matrix
Returns:
Type Description
boolean
Source:

(static) id(n) → {matrix}

Make an NxN identity matrix.

Parameters:
Name Type Description
n number
Returns:
Type Description
matrix
Source:

(static) map(m, fn) → {matrix}

Apply given function to each element.

Parameters:
Name Type Description
m matrix
fn function
Returns:
Type Description
matrix
Source:

(static) mul(a, b) → {matrix}

Multiply two matrices.

Parameters:
Name Type Description
a matrix
b matrix
Throws:

"matrixmath.mul.different sizes" if a doesn't have as many columns as b has rows.

Type
Numbas.Error
Returns:
Type Description
matrix
Source:

(static) negate(m) → {matrix}

Negate a matrix - negate each of its elements .

Parameters:
Name Type Description
m matrix
Returns:
Type Description
matrix
Source:

(static) neq(a, b) → {boolean}

Are two matrices unequal?

Parameters:
Name Type Description
a matrix
b matrix
Returns:
Type Description
boolean
Source:
See:

(static) precround(m, dp) → {matrix}

Round each element to given number of decimal places.

Parameters:
Name Type Description
m matrix
dp number

Number of decimal places.

Returns:
Type Description
matrix
Source:

(static) scalardiv(m, k) → {matrix}

Divide a matrix by a scalar.

Parameters:
Name Type Description
m matrix
k number
Returns:
Type Description
matrix
Source:

(static) scalarmul(k, m) → {matrix}

Multiply a matrix by a scalar.

Parameters:
Name Type Description
k number
m matrix
Returns:
Type Description
matrix
Source:

(static) siground(m, sf) → {matrix}

Round each element to given number of significant figures.

Parameters:
Name Type Description
m matrix
sf number

Number of decimal places.

Returns:
Type Description
matrix
Source:

(static) sub(a, b) → {matrix}

Subtract one matrix from another.

Parameters:
Name Type Description
a matrix
b matrix
Returns:
Type Description
matrix
Source:

(static) sum_cells(m) → {number}

Sum of every cell.

Parameters:
Name Type Description
m matrix
Returns:
Type Description
number
Source:

(static) transpose(m) → {matrix}

Matrix transpose.

Parameters:
Name Type Description
m matrix
Returns:
Type Description
matrix
Source: