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: