Maven module :un.api : api-math :
Class : un.impl.math.AbstractMatrix
Extends/Implements : un.api.math.transform.AbstractTransform un.api.math.MatrixRW
Subclasses : -

Abstract writable matrix.
author  Johann Sorel
aurhor  Bertrand COTE


Variables : nbRow, nbCol
Functions : AbstractMatrix, getNbRow, getNbCol, getInputDimensions, getOutputDimensions, getValuesCopy, getRow, getColumn, getColumnTuple, getLastColumn, getLastColumnTuple, getMatrix, getMatrix, getMatrix, getMatrix, set, set, set, setRow, setCol, setMatrix, setMatrix, setMatrix, setMatrix, setToIdentity, isIdentity, add, subtract, scale, multiply, invert, transpose, add, subtract, scale, multiply, invert, localInvert, localAdd, localSubtract, localScale, localScale, localMultiply, localTranslate, dot, transform, transform, transform, transform, transform, transform, transform, transform, transform, norm1, norm2, normInf, normF, lu, qr, chol, svd, eig, solve, solveTranspose, det, rank, cond, trace, toColumnPackedCopy, toRowPackedCopy, toArrayDouble, toArrayDoubleColOrder, toArrayFloat, toArrayFloatColOrder, toArrayFloatColOrder, toChars, getHash, allEquals, equals, dArray


protected int nbRow

protected int nbCol



Create a new abstract matrix of given size.
param  nbrow
param  nbcol
protected void AbstractMatrix (int nbrow, int nbcol)

public int getNbRow ()

public int getNbCol ()

public int getInputDimensions ()

public int getOutputDimensions ()



public double[][] getValuesCopy ()

public double[] getRow (int row)

public double[] getColumn (int col)

public Vector getColumnTuple (int col)

public double[] getLastColumn ()

public Vector getLastColumnTuple ()


Get a submatrix.
param  i0 Initial row index
param  i1 Final row index
param  j0 Initial column index
param  j1 Final column index
return  A(i0:i1,j0:j1)
exception  ArrayIndexOutOfBoundsException Submatrix indices
public MatrixRW getMatrix (int i0, int i1, int j0, int j1)


Get a submatrix.
param  r Array of row indices.
param  c Array of column indices.
return  A(r(:),c(:))
exception  ArrayIndexOutOfBoundsException Submatrix indices
public MatrixRW getMatrix (int[] r, int[] c)


Get a submatrix.
param  i0 Initial row index
param  i1 Final row index
param  c Array of column indices.
return  A(i0:i1,c(:))
exception  ArrayIndexOutOfBoundsException Submatrix indices
public MatrixRW getMatrix (int i0, int i1, int[] c)


Get a submatrix.
param  r Array of row indices.
param  j0 Initial column index
param  j1 Final column index
return  A(r(:),j0:j1)
exception  ArrayIndexOutOfBoundsException Submatrix indices
public MatrixRW getMatrix (int[] r, int j0, int j1)

public void set (Matrix toCopy)

public void set (double[] values)

public void set (double[][] values)

public void setRow (int row, double[] values)

public void setCol (int col, double[] values)


Set a submatrix.
param  i0 Initial row index
param  i1 Final row index
param  j0 Initial column index
param  j1 Final column index
param  X A(i0:i1,j0:j1)
exception  ArrayIndexOutOfBoundsException Submatrix indices
public void setMatrix (int i0, int i1, int j0, int j1, Matrix X)


Set a submatrix.
param  r Array of row indices.
param  c Array of column indices.
param  X A(r(:),c(:))
exception  ArrayIndexOutOfBoundsException Submatrix indices
public void setMatrix (int[] r, int[] c, Matrix X)


Set a submatrix.
param  r Array of row indices.
param  j0 Initial column index
param  j1 Final column index
param  X A(r(:),j0:j1)
exception  ArrayIndexOutOfBoundsException Submatrix indices
public void setMatrix (int[] r, int j0, int j1, Matrix X)


Set a submatrix.
param  i0 Initial row index
param  i1 Final row index
param  c Array of column indices.
param  X A(i0:i1,c(:))
exception  ArrayIndexOutOfBoundsException Submatrix indices
public void setMatrix (int i0, int i1, int[] c, Matrix X)


Set Matrix value to identity matrix.
return  this matrix
public AbstractMatrix setToIdentity ()

public boolean isIdentity ()



public MatrixRW add (Matrix other)

public MatrixRW subtract (Matrix other)

public MatrixRW scale (double scale)

public MatrixRW multiply (Matrix other)

public MatrixRW invert ()

public MatrixRW transpose ()



public MatrixRW add (Matrix other, MatrixRW buffer)

public MatrixRW subtract (Matrix other, MatrixRW buffer)

public MatrixRW scale (double scale, MatrixRW buffer)

public MatrixRW multiply (Matrix other, MatrixRW buffer)


invert matrix
public MatrixRW invert (MatrixRW buffer)


invert matrix
public AbstractMatrix localInvert ()

public AbstractMatrix localAdd (MatrixRW other)

public AbstractMatrix localSubtract (MatrixRW other)

public AbstractMatrix localScale (double[] tuple)

public AbstractMatrix localScale (double scale)

public AbstractMatrix localMultiply (Matrix other)


Translate the matrix.
Add given tuple values in the last matrix column.
param  translation
public void localTranslate (Tuple translation)

public double dot (Matrix other)



public double[] transform (double[] vector)

public double[] transform (double[] vector, double fillValue)

public Tuple transform (Tuple vector)

public Tuple transform (Tuple vector, double fillValue)

public double[] transform (double[] source, int sourceOffset, double[] dest, int destOffset, int nbTuple)

public float[] transform (float[] source, int sourceOffset, float[] dest, int destOffset, int nbTuple)

public Tuple transform (Tuple vector, Tuple buffer)

public Tuple transform (Tuple vector, Tuple buffer, double fillValue)

protected void transform (double[] vector, double[] buffer, double fillValue)


One norm
return  maximum column sum.
public double norm1 ()


Two norm
return  maximum singular value.
public double norm2 ()


Infinity norm
return  maximum row sum.
public double normInf ()


Frobenius norm
return  sqrt of sum of squares of all elements.
public double normF ()


LU Decomposition
return  LUDecomposition
see  LUDecomposition
public LUDecomposition lu ()


QR Decomposition
return  QRDecomposition
see  QRDecomposition
public QRDecomposition qr ()


Cholesky Decomposition
return  CholeskyDecomposition
see  CholeskyDecomposition
public CholeskyDecomposition chol ()


Singular Value Decomposition
return  SingularValueDecomposition
see  SingularValueDecomposition
public SingularValueDecomposition svd ()


Eigenvalue Decomposition
return  EigenvalueDecomposition
see  EigenvalueDecomposition
public EigenvalueDecomposition eig ()


Solve A*X = B
param  B right hand side
return  solution if A is square, least squares solution otherwise
public MatrixRW solve (MatrixRW B)


Solve X*A = B, which is also A'*X' = B'
@param B right hand side
@return solution if A is square, least squares solution otherwise.
public MatrixRW solveTranspose (MatrixRW B)


Matrix determinant
return  determinant
public double det ()


Matrix rank
return  effective numerical rank, obtained from SVD.
public int rank ()


Matrix condition (2 norm)
return  ratio of largest to smallest singular value.
public double cond ()


Matrix trace.
return  sum of the diagonal elements.
public double trace ()


Make a one-dimensional column packed copy of the internal array.
return  Matrix elements packed in a one-dimensional array by columns.
public double[] toColumnPackedCopy ()


Make a one-dimensional row packed copy of the internal array.
return  Matrix elements packed in a one-dimensional array by rows.
public double[] toRowPackedCopy ()

public double[] toArrayDouble ()


Matrix as 1D double array, in column order.
return  1D double array, in column order.
public double[] toArrayDoubleColOrder ()


Matrix as 1D float array, in row order.
return  1D float array, in row order.
public float[] toArrayFloat ()


Matrix as 1D float array, in column order.
return  1D float array, in column order.
public float[] toArrayFloatColOrder ()

public float[] toArrayFloatColOrder (float[] array)

public Chars toChars ()

public int getHash ()


Test if all cells in the matrix equals given value.
param  scalar scalar
param  tolerance tolerance
return  true if all values match
public boolean allEquals (double scalar, double tolerance)

public boolean equals (Object obj)

protected double[][] dArray (Matrix matrix)