jsci.maths.matrices
Class IntegerSquareMatrix
- java.lang.Object
-
- jsci.maths.matrices.Matrix
-
- jsci.maths.matrices.AbstractIntegerMatrix
-
- jsci.maths.matrices.AbstractIntegerSquareMatrix
-
- jsci.maths.matrices.IntegerSquareMatrix
-
- All Implemented Interfaces:
- java.io.Serializable, Algebra.Member, Module.Member, VectorSpace.Member, Ring.Member, AbelianGroup.Member, SquareMatrix, Member
public class IntegerSquareMatrix extends AbstractIntegerSquareMatrix
The IntegerSquareMatrix class provides an object for encapsulating integer square matrices.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description IntegerSquareMatrix(AbstractIntegerVector[] array)Constructs a matrix from an array of vectors (columns).IntegerSquareMatrix(int size)Constructs an empty matrix.IntegerSquareMatrix(int[][] array)Constructs a matrix by wrapping an array.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description AbstractIntegerSquareMatrixadd(AbstractIntegerSquareMatrix m)Returns the addition of this matrix and another.IntegerSquareMatrixadd(IntegerSquareMatrix m)AbstractDoubleSquareMatrix[]choleskyDecompose()Returns the Cholesky decomposition of this matrix.intdet()Returns the determinant.AbstractIntegerSquareMatrixdirectSum(AbstractIntegerSquareMatrix m)Returns the direct sum of this matrix and another.booleanequals(AbstractIntegerMatrix m, double tol)Compares two ${nativeTyp} matrices for equality.doublefrobeniusNorm()Returns the Frobenius or Hilbert-Schmidt (l2) norm.intgetElement(int i, int j)Returns an element of the matrix.intinfNorm()Returns the l
-norm.AbstractDoubleSquareMatrixinverse()Returns the inverse of this matrix.AbstractDoubleSquareMatrix[]luDecompose()Returns the LU decomposition of this matrix.AbstractDoubleSquareMatrix[]luDecompose(int[] pivot)Returns the LU decomposition of this matrix.AbstractIntegerSquareMatrixmultiply(AbstractIntegerSquareMatrix m)Returns the multiplication of this matrix and another.AbstractIntegerVectormultiply(AbstractIntegerVector v)Returns the multiplication of a vector by this matrix.IntegerSquareMatrixmultiply(IntegerSquareMatrix m)AbelianGroup.Membernegate()Returns the negative of this matrix.AbstractDoubleSquareMatrix[]qrDecompose()Returns the QR decomposition of this matrix.AbstractIntegerMatrixscalarMultiply(int x)Returns the multiplication of this matrix by a scalar.intscalarProduct(AbstractIntegerSquareMatrix m)Returns the scalar product of this matrix and another.intscalarProduct(IntegerSquareMatrix m)voidsetElement(int i, int j, int x)Sets the value of an element of the matrix.AbstractDoubleSquareMatrix[]singularValueDecompose()Returns the singular value decomposition of this matrix.AbstractIntegerSquareMatrixsubtract(AbstractIntegerSquareMatrix m)Returns the subtraction of this matrix by another.IntegerSquareMatrixsubtract(IntegerSquareMatrix m)AbstractIntegerSquareMatrixtensor(AbstractIntegerSquareMatrix m)Returns the tensor product of this matrix and another.AbstractComplexMatrixtoComplexMatrix()Converts this matrix to a complex matrix.AbstractDoubleMatrixtoDoubleMatrix()Converts this matrix to a double matrix.java.lang.StringtoString()Returns a string representing this matrix.inttrace()Returns the trace.Matrixtranspose()Returns the transpose of this matrix.-
Methods inherited from class jsci.maths.matrices.AbstractIntegerSquareMatrix
add, isSymmetric, isUnitary, scalarProduct, subtract
-
Methods inherited from class jsci.maths.matrices.AbstractIntegerMatrix
add, directSum, equals, equals, getSet, hashCode, multiply, multiply, scalarDivide, scalarMultiply, subtract, tensor
-
-
-
-
Constructor Detail
-
IntegerSquareMatrix
public IntegerSquareMatrix(int[][] array)
Constructs a matrix by wrapping an array.- Parameters:
array- an assigned value
-
IntegerSquareMatrix
public IntegerSquareMatrix(int size)
Constructs an empty matrix.
-
IntegerSquareMatrix
public IntegerSquareMatrix(AbstractIntegerVector[] array)
Constructs a matrix from an array of vectors (columns).- Parameters:
array- an assigned value
-
-
Method Detail
-
equals
public boolean equals(AbstractIntegerMatrix m, double tol)
Compares two ${nativeTyp} matrices for equality.- Overrides:
equalsin classAbstractIntegerMatrix- Parameters:
m- a int matrix
-
toString
public java.lang.String toString()
Returns a string representing this matrix.- Overrides:
toStringin classAbstractIntegerMatrix
-
toDoubleMatrix
public AbstractDoubleMatrix toDoubleMatrix()
Converts this matrix to a double matrix.- Overrides:
toDoubleMatrixin classAbstractIntegerSquareMatrix- Returns:
- a double matrix
-
toComplexMatrix
public AbstractComplexMatrix toComplexMatrix()
Converts this matrix to a complex matrix.- Overrides:
toComplexMatrixin classAbstractIntegerSquareMatrix- Returns:
- a complex matrix
-
getElement
public int getElement(int i, int j)Returns an element of the matrix.- Specified by:
getElementin classAbstractIntegerMatrix- Parameters:
i- row index of the elementj- column index of the element- Throws:
MatrixDimensionException- If attempting to access an invalid element.
-
setElement
public void setElement(int i, int j, int x)Sets the value of an element of the matrix. Should only be used to initialise this matrix.- Specified by:
setElementin classAbstractIntegerMatrix- Parameters:
i- row index of the elementj- column index of the elementx- a number- Throws:
MatrixDimensionException- If attempting to access an invalid element.
-
infNorm
public int infNorm()
Returns the l
-norm.- Overrides:
infNormin classAbstractIntegerMatrix
-
frobeniusNorm
public double frobeniusNorm()
Returns the Frobenius or Hilbert-Schmidt (l2) norm.- Overrides:
frobeniusNormin classAbstractIntegerMatrix
-
det
public int det()
Returns the determinant.- Overrides:
detin classAbstractIntegerSquareMatrix
-
trace
public int trace()
Returns the trace.- Overrides:
tracein classAbstractIntegerSquareMatrix
-
negate
public AbelianGroup.Member negate()
Returns the negative of this matrix.- Specified by:
negatein interfaceAbelianGroup.Member- Overrides:
negatein classAbstractIntegerSquareMatrix
-
add
public AbstractIntegerSquareMatrix add(AbstractIntegerSquareMatrix m)
Returns the addition of this matrix and another.- Overrides:
addin classAbstractIntegerSquareMatrix- Parameters:
m- a int matrix- Throws:
MatrixDimensionException- If the matrices are different sizes.
-
add
public IntegerSquareMatrix add(IntegerSquareMatrix m)
-
subtract
public AbstractIntegerSquareMatrix subtract(AbstractIntegerSquareMatrix m)
Returns the subtraction of this matrix by another.- Overrides:
subtractin classAbstractIntegerSquareMatrix- Parameters:
m- a int matrix- Throws:
MatrixDimensionException- If the matrices are different sizes.
-
subtract
public IntegerSquareMatrix subtract(IntegerSquareMatrix m)
-
scalarMultiply
public AbstractIntegerMatrix scalarMultiply(int x)
Returns the multiplication of this matrix by a scalar.- Overrides:
scalarMultiplyin classAbstractIntegerSquareMatrix- Parameters:
x- a int.- Returns:
- a int square matrix.
-
scalarProduct
public int scalarProduct(AbstractIntegerSquareMatrix m)
Returns the scalar product of this matrix and another.- Overrides:
scalarProductin classAbstractIntegerSquareMatrix- Parameters:
m- a int matrix.- Throws:
MatrixDimensionException- If the matrices are different sizes.
-
scalarProduct
public int scalarProduct(IntegerSquareMatrix m)
-
multiply
public AbstractIntegerVector multiply(AbstractIntegerVector v)
Returns the multiplication of a vector by this matrix.- Overrides:
multiplyin classAbstractIntegerMatrix- Parameters:
v- a int vector.- Throws:
DimensionException- If the matrix and vector are incompatible.
-
multiply
public AbstractIntegerSquareMatrix multiply(AbstractIntegerSquareMatrix m)
Returns the multiplication of this matrix and another.- Overrides:
multiplyin classAbstractIntegerSquareMatrix- Parameters:
m- a int matrix- Returns:
- a AbstractIntegerMatrix or a AbstractIntegerSquareMatrix as appropriate
- Throws:
MatrixDimensionException- If the matrices are incompatible.
-
multiply
public IntegerSquareMatrix multiply(IntegerSquareMatrix m)
-
directSum
public AbstractIntegerSquareMatrix directSum(AbstractIntegerSquareMatrix m)
Returns the direct sum of this matrix and another.- Overrides:
directSumin classAbstractIntegerSquareMatrix
-
tensor
public AbstractIntegerSquareMatrix tensor(AbstractIntegerSquareMatrix m)
Returns the tensor product of this matrix and another.- Overrides:
tensorin classAbstractIntegerSquareMatrix
-
transpose
public Matrix transpose()
Returns the transpose of this matrix.- Overrides:
transposein classAbstractIntegerSquareMatrix- Returns:
- a int matrix
-
inverse
public AbstractDoubleSquareMatrix inverse()
Returns the inverse of this matrix.- Overrides:
inversein classAbstractIntegerSquareMatrix- Returns:
- a double square matrix.
-
luDecompose
public final AbstractDoubleSquareMatrix[] luDecompose(int[] pivot)
Returns the LU decomposition of this matrix.- Overrides:
luDecomposein classAbstractIntegerSquareMatrix- Parameters:
pivot- an empty array of lengthrows()+1to hold the pivot information (null if not interested). The last array element will contain the parity.- Returns:
- an array with [0] containing the L-matrix and [1] containing the U-matrix.
-
luDecompose
public final AbstractDoubleSquareMatrix[] luDecompose()
Returns the LU decomposition of this matrix. Warning: no pivoting.- Overrides:
luDecomposein classAbstractIntegerSquareMatrix- Returns:
- an array with [0] containing the L-matrix and [1] containing the U-matrix.
-
choleskyDecompose
public AbstractDoubleSquareMatrix[] choleskyDecompose()
Returns the Cholesky decomposition of this matrix. Matrix must be symmetric and positive definite.- Overrides:
choleskyDecomposein classAbstractIntegerSquareMatrix- Returns:
- an array with [0] containing the L-matrix and [1] containing the U-matrix.
-
qrDecompose
public AbstractDoubleSquareMatrix[] qrDecompose()
Returns the QR decomposition of this matrix. Based on the code from JAMA (public domain).- Overrides:
qrDecomposein classAbstractIntegerSquareMatrix- Returns:
- an array with [0] containing the Q-matrix and [1] containing the R-matrix.
-
singularValueDecompose
public AbstractDoubleSquareMatrix[] singularValueDecompose()
Returns the singular value decomposition of this matrix. Based on the code from JAMA (public domain).- Overrides:
singularValueDecomposein classAbstractIntegerSquareMatrix- Returns:
- an array with [0] containing the U-matrix, [1] containing the S-matrix and [2] containing the V-matrix.
-
-
DMelt 3.0 © DataMelt by jWork.ORG