XLAMath

This library provides functions for linear algebra transformations

This is very much still a work in progress, the functionality here has only been tested with a few sample cases.

StatusName
Filter.SavitzkyGolayParameters ( Vector ↑v, Number ↓fm, Matrix ↓dim, Number ↓dn, Vector ↓w, Vector ↑v )

Computes the coefficients for a Savitzky Golay filter given the parameters

Matrix Matrix.copyMatrix ( Matrix ↓A, Number ↓m, Number ↓n, Matrix ↑B )

Copies the contents of a m x n matrix A into another matrix B.

Number Matrix.determinant ( Matrix ↓A, Number ↓am )

Computes the determinant of square matrix A, using LU decomposition

Matrix Matrix.fillMatrix ( Matrix ⇅A, Number ↓m, Number ↓n, Number ↓val )

Given a m x n matrix A, fills all elements of the matrix with the specified value. This is a convenience method to initialise a matrix (e.g. fill with 0).

Matrix Matrix.identityMatrix ( Number ↓m, Matrix ↑mat )

Generates an identity matrix of size m x m.

Boolean Matrix.inverse ( Matrix ↓A, Number ↓am, Matrix ↑inverse )

Computes the inverse of square matrix A.

Boolean Matrix.isSymmetric ( Matrix ↓A, Number ↓m )

Given a m x m square matrix A, returns whether it is symmetrical, within tolerance

Matrix Matrix.multiplyMatrix ( Matrix ↓A, Number ↓am, Number ↓an, Matrix ↓B, Number ↓bm, Number ↓bn, Matrix ↑C )

Multiplies matrices A and B to output C.

Matrix Matrix.transposeMatrix ( Matrix ↓A, Number ↓m, Number ↓n, Matrix ↑AT )

Given a m x n matrix A, returns the transpose, n x m matrix A T.

Solver.cholSolve ( Matrix ↓A, Number ↓am, Matrix ↓B, Number ↓bm, Number ↓bn, Matrix ↑X )

For the symmetric positive definite matrix A, and matrices X and B, where AX = B, solve for X given A and B, using Cholesky Decomposition.

Boolean Solver.luSolve ( Matrix ↓A, Number ↓am, Matrix ↓B, Number ↓bm, Number ↓bn, Matrix ↑X )

For the square matrix A, and matrices X and B, where AX = B, solve for X given A and B, using LU Decomposition

Boolean Solver.qrSolve ( Matrix ↓A, Number ↓am, Number ↓an, Matrix ↓B, Number ↓bm, Number ↓bn, Matrix ↑X, Number ↓threshold )

For the matrices A, X and B, where AX = B, solve for X given A and B, using QR Decomposition

Solver.svdSolve ( Matrix ↓A, Number ↓am, Number ↓an, Matrix ↓B, Number ↓bm, Number ↓bn, Matrix ↑X )

For the matrix A, X and B, where AX = B, solve for X given A and B, using Singular Value Decomposition

Matrix Transformation.ATA ( Matrix ↓A, Number ↓m, Number ↓n, Matrix ↑ATA )

Given a m × n matrix A, computes and returns the n × n matrix, A T × A.

Transformation.chol ( Matrix ↓A, Number ↓m, Matrix ↑L, Matrix ↑LT, Number ↓relativeSymmetryThreshold, Number ↓absolutePositivityThreshold, Object ↑details )

Calculates the Cholesky decomposition of a matrix.

The Cholesky decomposition of a real symmetric positive-definite matrix A consists of a lower triangular matrix L with same size such that: A = LL T. In a sense, this is the square root of A.

Transformation.eigen ( Matrix ↓A, Number ↓m, Array ↑realEigenValues, Array ↑imagEigenValues, Matrix ↑eigenVectors )

Transforms the matrix A of size m × m to derive its eigenvalues and eigenvectors.

Transformation.hessenberg ( Matrix ↓A, Number ↓m, Matrix ↑P, Matrix ↑H )

Transforms the matrix A of size m × m to its Hessenberg form.

The m × m matrix A can be written as the product of three matrices: A = P × H × P T with P an orthogonal matrix and H a Hessenberg matrix. Both P and H are m × m matrices.

P is an orthogonal matrix, i.e. its inverse is also its transpose.

Boolean Transformation.lu ( Matrix ↓A, Number ↓m, Matrix ↑L, Matrix ↑U, Matrix ↑P, Array ↑pivot, Matrix ↑LU, Object ↑details )

Calculates the LUP-decomposition of a square matrix.

The LUP-decomposition of a matrix A consists of three matrices L, U and P that satisfy: P×A = L×U. L is lower triangular (with unit diagonal terms), U is upper triangular and P is a permutation matrix. All matrices are m×m.

As shown by the presence of the P matrix, this decomposition is implemented using partial pivoting.

This function uses 1e-11 as the singularity threshold.

Boolean Transformation.qr ( Matrix ↓A, Number ↓m, Number ↓n, Matrix ↑Q, Matrix ↑R, Matrix ↑H, Matrix ↑QT, Number ↓threshold )

Calculates the QR-decomposition of a matrix.

The QR-decomposition of a matrix A consists of two matrices Q and R that satisfy: A = QR, Q is orthogonal (Q TQ = I), and R is upper triangular. If A is m×n, Q is m×m and R m×n.

This function compute the decomposition using Householder reflectors.

Transformation.schur ( Matrix ↓A, Number ↓m, Matrix ↑P, Matrix ↑T )

Transforms the matrix A of size m × m to its Schur form.

The m × m matrix A can be written as the product of three matrices: A = P × T × P T with P an orthogonal matrix and T an quasi-triangular matrix. Both P and T are m × m matrices.

P is an orthogonal matrix, i.e. its inverse is also its transpose.

Transformation.svd ( Matrix ↓A, Number ↓m, Number ↓n, Matrix ↑U, Matrix ↑V, Array ↑singularValues, Array ↑S, Object ↑details )

Calculates the compact Singular Value Decomposition of a matrix.

The Singular Value Decomposition of matrix A is a set of three matrices: U, Σ and V such that A = U × Σ × V T. Let A be a m × n matrix, then U is a m × p orthogonal matrix, Σ is a p × p diagonal matrix with positive or null elements, V is a p × n orthogonal matrix (hence V T is also orthogonal) where p=min(m,n).

This implementation requires m > n. If that is not the case, instead pass in the transpose of A. The V and U matrices are swapped in this case.

Matrix Transformation.svdPseudoInverse ( Number ↓m, Number ↓n, Array ↓singularValues, Matrix ↓U, Matrix ↓V, Number ↓tol, Matrix ↑inv )

Calculates the pseudoinverse of a m × n matrix A based on the output of its SVD transformation.

Transformation.symmetricEigen ( Matrix ↓A, Number ↓m, Array ↑realEigenValues, Array ↑imagEigenValues, Matrix ↑eigenVectors )

Transforms the symmetric matrix A of size m × m to derive its eigenvalues and eigenvectors.

Transformation.tridiagonal ( Matrix ↓A, Number ↓m, Matrix ↑P, Matrix ↑T, Array ↑main, Array ↑secondary )

Transforms the symmetric matrix A of size m × m to a tridiagonal form.

The m × m matrix A can be written as the product of three matrices: A = Q × T × Q T with Q an orthogonal matrix and T a symmetrical tridiagonal matrix. Both Q and T are m × m matrices.

Q is an orthogonal matrix, i.e. its inverse is also its transpose. The function assumes that A is symmetric, only the upper part of the matrix is accessed.


Category: Filter

Methods for matrix filters

Lib.Filter.SavitzkyGolayParameters ( ↑v, ↓fm, ↓dim, ↓dn, ↓w, ↑v )

Computes the coefficients for a Savitzky Golay filter given the parameters

Parameters:
  • Vector ↑v - - output vector v, which is a vector sized frame size.
  • Number ↓fm - - frame size - must be a positive odd integer.
  • Matrix ↓dim - - order of polynomial for filter. Must be less than frame size - 1.
  • Number ↓dn - - derivative to compute. 0 = smoothing only. Must be less than or equal to order of polynomial.
  • Vector ↓w - - optional, weighting vector. If provided, must be sized frame size.
  • Vector ↑v - - output vector v, which is a vector sized frame size.

Category: Matrix

Methods for working with matrices The matrices in this library are represented by an array, with the elements of the matrix within the array in row-major format, e.g.:

[ 1 2 3 4 5 6 7 8 9 ]

↑B = Lib.Matrix.copyMatrix ( ↓A, ↓m, ↓n, ↑B )

Copies the contents of a m x n matrix A into another matrix B.

Parameters:
  • Matrix ↓A - - input matrix A to transpose
  • Number ↓m - - row dimension of input matrix A.
  • Number ↓n - - col dimension of input matrix A.
  • Matrix ↑B - - output matrix B. Optional - if not provided a new array will be created and returned.
Returns: Matrix ↑B - - output matrix
↑determinant = Lib.Matrix.determinant ( ↓A, ↓am )

Computes the determinant of square matrix A, using LU decomposition

Parameters:
  • Matrix ↓A - - input square matrix A to multiply
  • Number ↓am - - row/col dimension of input matrix A.
Returns: Number ↑determinant - - determinant of matrix A
⇅A = Lib.Matrix.fillMatrix ( ⇅A, ↓m, ↓n, ↓val )

Given a m x n matrix A, fills all elements of the matrix with the specified value. This is a convenience method to initialise a matrix (e.g. fill with 0).

Parameters:
  • Matrix ⇅A - - input matrix A to fill
  • Number ↓m - - row dimension of input matrix A.
  • Number ↓n - - col dimension of input matrix A.
  • Number ↓val - - value to fill input matrix A.
Returns: Matrix ⇅A - - filled matrix A
↑mat = Lib.Matrix.identityMatrix ( ↓m, ↑mat )

Generates an identity matrix of size m x m.

Parameters:
  • Number ↓m - - row/col dimension of identity matrix to generate.
  • Matrix ↑mat - - identity matrix to generate. Optional - if not specified, a new array will be created and returned.
Returns: Matrix ↑mat - - identity matrix to generate.
↑solved = Lib.Matrix.inverse ( ↓A, ↓am, ↑inverse )

Computes the inverse of square matrix A.

Parameters:
  • Matrix ↓A - - input matrix A to compute inverse
  • Number ↓am - - row/col dimension of input matrix A.
  • Matrix ↑inverse - - output matrix inverse of A.
Returns: Boolean ↑solved - - true if solution is valid. false if solution not valid (i.e. A is singular).
↑isSymmetric = Lib.Matrix.isSymmetric ( ↓A, ↓m )

Given a m x m square matrix A, returns whether it is symmetrical, within tolerance

Parameters:
  • Matrix ↓A - - input matrix A to transpose
  • Number ↓m - - row/col dimension of input matrix A.
Returns: Boolean ↑isSymmetric - - whether the matrix A is symmetrical
↑C = Lib.Matrix.multiplyMatrix ( ↓A, ↓am, ↓an, ↓B, ↓bm, ↓bn, ↑C )

Multiplies matrices A and B to output C.

Parameters:
  • Matrix ↓A - - input matrix A to multiply
  • Number ↓am - - row dimension of input matrix A.
  • Number ↓an - - col dimension of input matrix A.
  • Matrix ↓B - - input matrix B to multiply
  • Number ↓bm - - row dimension of input matrix B.
  • Number ↓bn - - col dimension of input matrix B.
  • Matrix ↑C - - output matrix C. Optional - if not provided a new array will be created and returned. This is a am x bn matrix.
Returns: Matrix ↑C - - output matrix
↑AT = Lib.Matrix.transposeMatrix ( ↓A, ↓m, ↓n, ↑AT )

Given a m x n matrix A, returns the transpose, n x m matrix A T.

Parameters:
  • Matrix ↓A - - input matrix A to transpose
  • Number ↓m - - row dimension of input matrix A.
  • Number ↓n - - col dimension of input matrix A.
  • Matrix ↑AT - - output matrix AT. Optional - if not provided a new array will be created and returned.
Returns: Matrix ↑AT - - output matrix

Category: Solver

Methods for solving linear systems

Lib.Solver.cholSolve ( ↓A, ↓am, ↓B, ↓bm, ↓bn, ↑X )

For the symmetric positive definite matrix A, and matrices X and B, where AX = B, solve for X given A and B, using Cholesky Decomposition.

Parameters:
  • Matrix ↓A - - input matrix A
  • Number ↓am - - row/col dimension of input matrix A.
  • Matrix ↓B - - input matrix B
  • Number ↓bm - - row dimension of input matrix B.
  • Number ↓bn - - col dimension of input matrix B.
  • Matrix ↑X - - output matrix X (same size as B).
↑solved = Lib.Solver.luSolve ( ↓A, ↓am, ↓B, ↓bm, ↓bn, ↑X )

For the square matrix A, and matrices X and B, where AX = B, solve for X given A and B, using LU Decomposition

Parameters:
  • Matrix ↓A - - input matrix A
  • Number ↓am - - row/col dimension of input matrix A.
  • Matrix ↓B - - input matrix B
  • Number ↓bm - - row dimension of input matrix B.
  • Number ↓bn - - col dimension of input matrix B.
  • Matrix ↑X - - output matrix X (same size as B).
Returns: Boolean ↑solved - - returns true if solution is valid. Returns false if solution is not valid (i.e. A is singular).
↑solved = Lib.Solver.qrSolve ( ↓A, ↓am, ↓an, ↓B, ↓bm, ↓bn, ↑X, ↓threshold )

For the matrices A, X and B, where AX = B, solve for X given A and B, using QR Decomposition

Parameters:
  • Matrix ↓A - - input matrix A
  • Number ↓am - - row dimension of input matrix A.
  • Number ↓an - - col dimension of input matrix A.
  • Matrix ↓B - - input matrix B
  • Number ↓bm - - row dimension of input matrix B.
  • Number ↓bn - - col dimension of input matrix B.
  • Matrix ↑X - - output matrix X (same size as B).
  • Number ↓threshold - - singularity threshold. Optional - defaults to zero if not specified.
Returns: Boolean ↑solved - - returns true if solution is valid. Returns false if solution is not valid (i.e. A is singular).
Lib.Solver.svdSolve ( ↓A, ↓am, ↓an, ↓B, ↓bm, ↓bn, ↑X )

For the matrix A, X and B, where AX = B, solve for X given A and B, using Singular Value Decomposition

Parameters:
  • Matrix ↓A - - input matrix A
  • Number ↓am - - row dimension of input matrix A.
  • Number ↓an - - col dimension of input matrix A.
  • Matrix ↓B - - input matrix B
  • Number ↓bm - - row dimension of input matrix B.
  • Number ↓bn - - col dimension of input matrix B.
  • Matrix ↑X - - output matrix X

Category: Transformation

Methods for working with transformations

↑ATA = Lib.Transformation.ATA ( ↓A, ↓m, ↓n, ↑ATA )

Given a m × n matrix A, computes and returns the n × n matrix, A T × A.

Parameters:
  • Matrix ↓A - - input matrix A.
  • Number ↓m - - row dimension of input matrix A.
  • Number ↓n - - col dimension of input matrix A.
  • Matrix ↑ATA - - output matrix. This is a n × n matrix. Specifying an output array is optional but recommended. If no output array is given, an array will be created and returned.
Returns: Matrix ↑ATA - - the output array.
Lib.Transformation.chol ( ↓A, ↓m, ↑L, ↑LT, ↓relativeSymmetryThreshold, ↓absolutePositivityThreshold, ↑details )

Calculates the Cholesky decomposition of a matrix.

The Cholesky decomposition of a real symmetric positive-definite matrix A consists of a lower triangular matrix L with same size such that: A = LL T. In a sense, this is the square root of A.

Parameters:
  • Matrix ↓A - - input matrix A.
  • Number ↓m - - row/col dimension of input matrix A.
  • Matrix ↑L - - output matrix L. L is a lower triangular, m × m matrix. Optional - this matrix is only computed if an output array is specified.
  • Matrix ↑LT - - output matrix LT. LT is the transpose of L. Optional - this matrix is only computed if an output array is specified.
  • Number ↓relativeSymmetryThreshold - - relative symmetry threshold. Optional - defaults to 1.0e-15 if not specified.
  • Number ↓absolutePositivityThreshold - - positive definite threshold. Optional - defaults to 1.0e-10 if not specified.
  • Object ↑details - - an output details object with the following element: determinant. Optional - this object is populated if it exists.
Lib.Transformation.eigen ( ↓A, ↓m, ↑realEigenValues, ↑imagEigenValues, ↑eigenVectors )

Transforms the matrix A of size m × m to derive its eigenvalues and eigenvectors.

Parameters:
  • Matrix ↓A - - input square matrix
  • Number ↓m - - row/col dimension of input square matrix A.
  • Array ↑realEigenValues - - output array of size m, containing the real components of the eigenvalues of A
  • Array ↑imagEigenValues - - output array of size m, containing the imaginary components of the eigenvalues of A
  • Matrix ↑eigenVectors - - output matrix, where the eigenvectors of A are the rows of this matrix. This is an matrix of size m x m.
Lib.Transformation.hessenberg ( ↓A, ↓m, ↑P, ↑H )

Transforms the matrix A of size m × m to its Hessenberg form.

The m × m matrix A can be written as the product of three matrices: A = P × H × P T with P an orthogonal matrix and H a Hessenberg matrix. Both P and H are m × m matrices.

P is an orthogonal matrix, i.e. its inverse is also its transpose.

Parameters:
  • Matrix ↓A - - input square matrix
  • Number ↓m - - row/col dimension of input square matrix A.
  • Matrix ↑P - - output matrix
  • Matrix ↑H - - output matrix
↑singular = Lib.Transformation.lu ( ↓A, ↓m, ↑L, ↑U, ↑P, ↑pivot, ↑LU, ↑details )

Calculates the LUP-decomposition of a square matrix.

The LUP-decomposition of a matrix A consists of three matrices L, U and P that satisfy: P×A = L×U. L is lower triangular (with unit diagonal terms), U is upper triangular and P is a permutation matrix. All matrices are m×m.

As shown by the presence of the P matrix, this decomposition is implemented using partial pivoting.

This function uses 1e-11 as the singularity threshold.

Parameters:
  • Matrix ↓A - - input matrix A.
  • Number ↓m - - row/col dimension of input matrix A.
  • Matrix ↑L - - output matrix L. L is a lower-triangular, m × m matrix. Optional - this matrix is only computed if an output array is specified.
  • Matrix ↑U - - output matrix U. U is an upper-triangular matrix, m × m matrix. Optional - this matrix is only computed if an output array is specified.
  • Matrix ↑P - - output matrix P - rows permutation matrix. This is a m × m matrix. P is a sparse matrix with exactly one element set to 1.0 in each row and each column, all other elements being set to 0.0. The positions of the 1 elements are given by the pivot permutation vector. Optional - this matrix is only computed if an output array is specified.
  • Array ↑pivot - - output pivot permutation vector of size m. Optional - this vector is only returned if an output array is specified.
  • Matrix ↑LU - - output matrix LU. This is a m × m matrix combining aspects of L and U. Optional - this matrix is only computed if an output array is specified.
  • Object ↑details - - an output details object with the following elements: singular, even, determinant. Optional - this object is populated if it exists.
Returns: Boolean ↑singular - - whether the specified matrix is singular or not.
↑singular = Lib.Transformation.qr ( ↓A, ↓m, ↓n, ↑Q, ↑R, ↑H, ↑QT, ↓threshold )

Calculates the QR-decomposition of a matrix.

The QR-decomposition of a matrix A consists of two matrices Q and R that satisfy: A = QR, Q is orthogonal (Q TQ = I), and R is upper triangular. If A is m×n, Q is m×m and R m×n.

This function compute the decomposition using Householder reflectors.

Parameters:
  • Matrix ↓A - - input matrix A.
  • Number ↓m - - row dimension of input matrix A.
  • Number ↓n - - col dimension of input matrix A.
  • Matrix ↑Q - - output matrix Q. Q is an orthogonal, m × m matrix. Optional - this matrix is only computed if an output array is specified.
  • Matrix ↑R - - output matrix R. R is an upper-triangular matrix, m × n matrix. Optional - this matrix is only computed if an output array is specified.
  • Matrix ↑H - - output matrix H - Householder reflector vectors. H is a lower trapezoidal matrix, m × n whose columns represent each successive Householder reflector vector. This matrix is used to compute Q. Optional - this matrix is only computed if an output array is specified.
  • Matrix ↑QT - - output matrix QT. This is the transpose of Q. Optional - this matrix is only computed if an output array is specified.
  • Number ↓threshold - - singularity threshold. Optional - defaults to zero if not specified.
Returns: Boolean ↑singular - - whether the specified matrix is singular or not.
Lib.Transformation.schur ( ↓A, ↓m, ↑P, ↑T )

Transforms the matrix A of size m × m to its Schur form.

The m × m matrix A can be written as the product of three matrices: A = P × T × P T with P an orthogonal matrix and T an quasi-triangular matrix. Both P and T are m × m matrices.

P is an orthogonal matrix, i.e. its inverse is also its transpose.

Parameters:
  • Matrix ↓A - - input square matrix
  • Number ↓m - - row/col dimension of input square matrix A.
  • Matrix ↑P - - output matrix
  • Matrix ↑T - - output matrix
Lib.Transformation.svd ( ↓A, ↓m, ↓n, ↑U, ↑V, ↑singularValues, ↑S, ↑details )

Calculates the compact Singular Value Decomposition of a matrix.

The Singular Value Decomposition of matrix A is a set of three matrices: U, Σ and V such that A = U × Σ × V T. Let A be a m × n matrix, then U is a m × p orthogonal matrix, Σ is a p × p diagonal matrix with positive or null elements, V is a p × n orthogonal matrix (hence V T is also orthogonal) where p=min(m,n).

This implementation requires m > n. If that is not the case, instead pass in the transpose of A. The V and U matrices are swapped in this case.

Parameters:
  • Matrix ↓A - - input matrix
  • Number ↓m - - row dimension of input matrix A.
  • Number ↓n - - col dimension of input matrix A. This implementation requires that m > n.
  • Matrix ↑U - - output array U
  • Matrix ↑V - - output array V
  • Array ↑singularValues - - output singular values. They are ranked in descending order.
  • Array ↑S - - optional. If supplied, the Σ matrix is returned (a matrix with the singular values as its main diagonal).
  • Object ↑details - - optional. If supplied as a hash or array, the method populates two properties: 'rank' denoting rank of the matrix, and 'tol' denoting the tolerance of the output matrices.
↑inv = Lib.Transformation.svdPseudoInverse ( ↓m, ↓n, ↓singularValues, ↓U, ↓V, ↓tol, ↑inv )

Calculates the pseudoinverse of a m × n matrix A based on the output of its SVD transformation.

Parameters:
  • Number ↓m - - row dimension of input matrix A.
  • Number ↓n - - col dimension of input matrix A.
  • Array ↓singularValues - - singular values of A as returned by svd()
  • Matrix ↓U - - matrix U as returned by svd()
  • Matrix ↓V - - matrix V as returned by svd()
  • Number ↓tol - - tolerance as returned by svd(). Set to 0 if the input does not come from svd().
  • Matrix ↑inv - - output pseudo inverse of A. This is a n × m matrix. Specifying an output array is optional but recommended. If no output array is given, an array will be created and returned.
Returns: Matrix ↑inv - - the output array.
Lib.Transformation.symmetricEigen ( ↓A, ↓m, ↑realEigenValues, ↑imagEigenValues, ↑eigenVectors )

Transforms the symmetric matrix A of size m × m to derive its eigenvalues and eigenvectors.

Parameters:
  • Matrix ↓A - - input square matrix
  • Number ↓m - - row/col dimension of input square matrix A.
  • Array ↑realEigenValues - - output array of size m, containing the real components of the eigenvalues of A
  • Array ↑imagEigenValues - - output array of size m, containing the imaginary components of the eigenvalues of A. A symmetric matrix A yields only real eigen values, so this should be an all-zero output.
  • Matrix ↑eigenVectors - - output matrix, where the eigenvectors of A are the rows of this matrix. This is an matrix of size m x m.
Lib.Transformation.tridiagonal ( ↓A, ↓m, ↑P, ↑T, ↑main, ↑secondary )

Transforms the symmetric matrix A of size m × m to a tridiagonal form.

The m × m matrix A can be written as the product of three matrices: A = Q × T × Q T with Q an orthogonal matrix and T a symmetrical tridiagonal matrix. Both Q and T are m × m matrices.

Q is an orthogonal matrix, i.e. its inverse is also its transpose. The function assumes that A is symmetric, only the upper part of the matrix is accessed.

Parameters:
  • Matrix ↓A - - input square matrix
  • Number ↓m - - row/col dimension of input square matrix A.
  • Matrix ↑P - - output matrix
  • Matrix ↑T - - output matrix
  • Array ↑main - - optional. output main diagonal of matrix T. This is an array of size m.
  • Array ↑secondary - - optional. output secondary diagonal of matrix T. This is an array of size m - 1.