### numbers.matrix

Add two matrices, M1 and M2, together.

Parameters M1 : Array First matrix. M2 : Array Second matrix. M : Array Addition of M1, M2. An error is thrown if: the dimensions of M1 and M2 do not match

#### numbers.matrix.affine(v, tx, ty)

Perform an affine transformation 2D vector, v, by factors tx and ty.

Parameters v : Array A 2D vector. tx : Number The x-factor. ty : Number The y-factor. Vaff : Array Affined v. An error is thrown if: v is not 2D (v.length !== 2)

#### numbers.matrix.deepCopy(M)

Create a deep copy of a matrix, M.

Parameters M : Array The matrix to copy. Mnew : Array Deep copy of M. An error is thrown if: M is not a matrix

#### numbers.matrix.determinant(M)

Calculates the determinant of a square matrix, M.

Parameters M : Array A square matrix. num : Number The determinant of M. An error is thrown if: M is not a square matrix

#### numbers.matrix.dotproduct(vA, vB)

Calculate the dot product of two vectors, vA and vB.

Parameters vA : Array First vector. vB : Array Second vector. num : Array Dot product of vA,vB. An error is thrown if: The dimensions of vA and vB are not the same (vA.length !== vB.length).

#### numbers.matrix.GaussJordanEliminate(M, eps)

Performs Gauss-Jordan elimination on the matrix M with an error bound of eps. eps is an optional argument.

Parameters M : Array A matrix. eps : Number The error bound. Mnew : Array The row-reduced version of M. This function does not raise any errors.

#### numbers.matrix.getCol(M)

Gets the nth column of a matrix, M as a vector.

Parameters M : Array A matrix. col : Array nth column of M. An error is thrown if: n is less than zero n is greater than or equal to the number of columns of M

#### numbers.matrix.identity(n)

Creates a n-by-n identity matrix.

Parameters n : Int The size of the identity matrix. M : Array Identity matrix of size n. This function does not raise any errors.

#### numbers.matrix.inverse(M)

Calculates the inverse of a square matrix M.

Parameters M : Array A square matrix. Mnew : Array The inverse of M. An error is thrown if: M is not a square matrix.

#### numbers.matrix.isColumnDD(M)

Determines if a matrix, M, is (weak) column diagonally dominant.

Parameters M : Array The matrix to test. bool : Boolean true if M is column diagonally dominant, false otherwise. An error is thrown if: M is not a matrix. M is not square.

#### numbers.matrix.isRowDD(M)

Determines if a matrix, M, is (weak) row diagonally dominant.

Parameters M : Array The matrix to test. bool : Boolean true if M is row diagonally dominant, false otherwise. An error is thrown if: M is not a matrix. M is not square.

#### numbers.matrix.isSquare(M)

Determines if a matrix, M, is square.

Parameters M : Array The matrix to test. bool : Boolean true if M is square, false otherwise. An error is thrown if: M is not a matrix.

#### numbers.matrix.isStrictlyColumnDD(M)

Determines if a matrix, M, is strictly column diagonally dominant.

Parameters M : Array The matrix to test. bool : Boolean true if M is strictly column diagonally dominant, false otherwise. An error is thrown if: M is not a matrix. M is not square.

#### numbers.matrix.isStrictlyRowDD(M)

Determines if a matrix, M, is strictly row diagonally dominant.

Parameters M : Array The matrix to test. bool : Boolean true if M is strictly row diagonally dominant, false otherwise. An error is thrown if: M is not a matrix. M is not square.

#### numbers.matrix.lupDecomposition(M)

Calculates the LUP decomposition of a square matrix, M. An array containing the three matrices is returned.

Parameters M : Array A square matrix. LUP : Array An array containing L, U, P. An error is thrown if: M is not a square matrix.

#### numbers.matrix.map(M, f)

Applies a function, f, to every element in the matrix (or vector) M. f can only take one parameter.

Parameters M : Array A matrix or vector f : Function A one-parameter function. Mmapped : Array A copy of M, but with f applied to each element. This function does not raise any errors.

#### numbers.matrix.multiply(M1, M2)

Multiply two matrices, M1 and M2, together.

Parameters M1 : Array First matrix. M2 : Array Second matrix. M : Array Multiplication of M1, M2. An error is thrown if: The number of rows of M1 and the number of columns of M2 do not match.

#### numbers.matrix.outer(vA, vB)

Calculate the outer product of two vectors, vA and vB.

Parameters vA : Array First vector. vB : Array Second vector. M : Array Outer product of vA,vB. An error is thrown if: The dimensions of vA and vB are not the same (vA.length !== vB.length).

#### numbers.matrix.reorderCols(M, L)

Reorders the columns of a matrix M as specified by a set of column indices, L.

Parameters M : Array The matrix to reorder. L : Array The set of column indices. Mnew : Array Reordered M. An error is thrown if: L is not defined the number of columns in Mreorder will have a different number of columns as M (L.length !== M.length). an element of L is less than zero or greater than or equal to the number of columns of M

#### numbers.matrix.reorderRows(M, L)

Reorders the rows of a matrix M as specified by a set of integers, L.

Parameters M : Array The matrix to reorder. L : Array The set of row indices. Mnew : Array Reordered M. An error is thrown if: L is not defined the number of rows in Mreorder will have a different number of rows as M (L.length !== M.length). an element of L is less than zero or greater than or equal to the number of rows of M

#### numbers.matrix.reverseCols(M)

Reverses the order the of columns of a matrix M.

Parameters M : Array The matrix to reverse. Mnew : Array Reversed M. This function does not raise any errors.

#### numbers.matrix.reverseRows(M)

Reverses the order the of rows of a matrix M.

Parameters M : Array The matrix to reverse. Mnew : Array Reversed M. This function does not raise any errors.

#### numbers.matrix.rotate(v, angle, dir)

Rotate a 2D vector, v, by angle degrees in a direction dir. dir is an optional argument.

Parameters v : Array A 2D vector. angle : Number An angle in degrees. dir : String A direction. Options are clockwise and counterclockwise. Default value is counterclockwise. Vnew : Array Rotated v. An error is thrown if: v is not 2D (v.length !== 2).

Add the multiple of a row, scale*fromRow, to another row, toRow, both of matrix M.

Parameters M : Array A matrix. fromRow : Int Row to be multiplied. toRow : Int Row to be added to. scale : Number Scaling factor. Mnew : Array Altered M. This function does not raise any errors.

#### numbers.matrix.rowReduce(M, eps)

Row-reduces the matrix M with an error bound of eps. eps is an optional argument. Identical to matrix.GaussJordanElimination.

Parameters M : Array A matrix. eps : Number The error bound. Mnew : Array The row-reduced version of M. This function does not raise any errors.

#### numbers.matrix.rowScale(M, row, k)

Scale row row of a matrix M by a factor k.

Parameters M : Array A matrix. row : Int The row number. k : Number Scaling factor. Mnew : Array Scaled M. This function does not raise any errors.

#### numbers.matrix.rowSwitch(M, row1, row2)

Switch rows row1 and row2 of a matrix M with each other.

Parameters M : Array A matrix. row1 : Int First row number. row2 : Int Second row number. Mnew : Array Swapped M. This function does not raise any errors.

#### numbers.matrix.scalar(M, a)

Multiply a matrix, M, by a scalar, a.

Parameters M : Array The matrix to multiply. a : Number The scalar value. M : Array Multiplication of a, M1. This function does not raise any errors.

#### numbers.matrix.scale(v, x, y)

Scale a 2D vector, v, by scale factors x and y.

Parameters v : Array A 2D vector. x : Number The x-scaling. y : Number The y-scaling. Vsca : Array Scaled v. An error is thrown if: v is not 2D (v.length !== 2).

#### numbers.matrix.shear(v, k, dir)

Shear a 2D vector, v, by a shear factor k in a direction (x or y) dir.

Parameters v : Array A 2D vector. k : Number The shear factor. dir : String A direction. Options are 'xaxis' and 'yaxis'. Vsh : Array Sheared v. An error is thrown if: v is not 2D (v.length !== 2).

#### numbers.matrix.subtraction(M1, M2)

Subtract two matrices, M1 and M2, from one another.

Parameters M1 : Array First matrix. M2 : Array Second matrix. M : Array Subtraction of M2 from M1. An error is thrown if: the dimensions of M1 and M2 do not match

#### numbers.matrix.trace(M)

Calculates the trace of a square matrix, M.

Parameters M : Array A square matrix. tr : Number The trace of M. An error is thrown if: M is not a square matrix.

#### numbers.matrix.zeros(n, m)

Creates a n-by-m matrix filled with zeros.

Parameters n : Int Number of rows. m : Int Number of columns. M : Array A matrix of zeros. An error is thrown if: Either matrix dimension is less than 1.

#### numbers.matrix.zigzag(n, point, dir)

Creates a n-by-n zigzag matrix starting at a corner, point, and moving in an initial direction dir.

Parameters n : Int Dimension of zigzag matrix. point : String Corner to start at. Options are top-left ('TR'), top-right ('TR'), bottom-left ('BL') and bottom-right ('BR'). dir : String Direction to start iterating. Options are vertical ('v') or horizontal ('H'). M : Array A zigzag matrix. An error is thrown if: Matrix dimension is less than 2.