jsci.maths.matrices
Class IntegerDiagonalMatrix
- java.lang.Object
-
- jsci.maths.matrices.Matrix
-
- jsci.maths.matrices.AbstractIntegerMatrix
-
- jsci.maths.matrices.AbstractIntegerSquareMatrix
-
- jsci.maths.matrices.IntegerDiagonalMatrix
-
- All Implemented Interfaces:
- java.io.Serializable, Algebra.Member, Module.Member, VectorSpace.Member, Ring.Member, AbelianGroup.Member, DiagonalMatrix, SquareMatrix, TridiagonalMatrix, Member
public class IntegerDiagonalMatrix extends AbstractIntegerSquareMatrix implements DiagonalMatrix
The IntegerDiagonalMatrix class provides an object for encapsulating integer diagonal matrices.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description IntegerDiagonalMatrix(int size)Constructs an empty matrix.IntegerDiagonalMatrix(int[] array)Constructs a matrix by wrapping an array containing the diagonal elements.IntegerDiagonalMatrix(int[][] array)Constructs a matrix from an array.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description AbstractIntegerSquareMatrixadd(AbstractIntegerSquareMatrix m)Returns the addition of this matrix and another.IntegerDiagonalMatrixadd(IntegerDiagonalMatrix m)Returns the addition of this matrix and another.IntegerSquareMatrixadd(IntegerSquareMatrix m)IntegerTridiagonalMatrixadd(IntegerTridiagonalMatrix m)Returns the addition of this matrix and another.AbstractDoubleSquareMatrix[]choleskyDecompose()Returns the Cholesky decomposition of this matrix.intdet()Returns the determinant.booleanequals(AbstractIntegerMatrix m, double tol)Compares two ${nativeTyp} matrices for equality.doublefrobeniusNorm()Returns the Frobenius (l2) norm.intgetElement(int i, int j)Returns an element of the matrix.static IntegerDiagonalMatrixidentity(int size)Creates an identity matrix.intinfNorm()Returns the l
-norm.AbstractDoubleSquareMatrixinverse()Returns the inverse of this matrix.booleanisSymmetric()Returns true if this matrix is symmetric.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.IntegerDiagonalMatrixmultiply(IntegerDiagonalMatrix m)IntegerSquareMatrixmultiply(IntegerSquareMatrix m)IntegerTridiagonalMatrixmultiply(IntegerTridiagonalMatrix m)doubleoperatorNorm()Returns the operator norm.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(IntegerDiagonalMatrix m)intscalarProduct(IntegerSquareMatrix m)intscalarProduct(IntegerTridiagonalMatrix 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.IntegerDiagonalMatrixsubtract(IntegerDiagonalMatrix m)Returns the subtraction of this matrix and another.IntegerSquareMatrixsubtract(IntegerSquareMatrix m)IntegerTridiagonalMatrixsubtract(IntegerTridiagonalMatrix m)Returns the subtraction 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, directSum, isUnitary, negate, scalarProduct, subtract, tensor
-
Methods inherited from class jsci.maths.matrices.AbstractIntegerMatrix
add, directSum, equals, equals, getSet, hashCode, multiply, multiply, scalarDivide, scalarMultiply, subtract, tensor
-
-
-
-
Constructor Detail
-
IntegerDiagonalMatrix
public IntegerDiagonalMatrix(int size)
Constructs an empty matrix.- Parameters:
size- the number of rows/columns
-
IntegerDiagonalMatrix
public IntegerDiagonalMatrix(int[][] array)
Constructs a matrix from an array. Any non-diagonal elements in the array are ignored.- Parameters:
array- an assigned value- Throws:
MatrixDimensionException- If the array is not square.
-
IntegerDiagonalMatrix
public IntegerDiagonalMatrix(int[] array)
Constructs a matrix by wrapping an array containing the diagonal elements.- Parameters:
array- an assigned value
-
-
Method Detail
-
identity
public static IntegerDiagonalMatrix identity(int size)
Creates an identity matrix.- Parameters:
size- the number of rows/columns
-
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.
-
isSymmetric
public boolean isSymmetric()
Returns true if this matrix is symmetric.- Overrides:
isSymmetricin classAbstractIntegerSquareMatrix
-
det
public int det()
Returns the determinant.- Overrides:
detin classAbstractIntegerSquareMatrix
-
trace
public int trace()
Returns the trace.- Overrides:
tracein classAbstractIntegerSquareMatrix
-
infNorm
public int infNorm()
Returns the l
-norm.- Overrides:
infNormin classAbstractIntegerMatrix
-
frobeniusNorm
public double frobeniusNorm()
Returns the Frobenius (l2) norm.- Overrides:
frobeniusNormin classAbstractIntegerMatrix
-
operatorNorm
public double operatorNorm() throws MaximumIterationsExceededExceptionReturns the operator norm.- Throws:
MaximumIterationsExceededException- If it takes more than 50 iterations to determine an eigenvalue.
-
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)
-
add
public IntegerTridiagonalMatrix add(IntegerTridiagonalMatrix m)
Returns the addition of this matrix and another.- Parameters:
m- a int tridiagonal matrix- Throws:
MatrixDimensionException- If the matrices are different sizes.
-
add
public IntegerDiagonalMatrix add(IntegerDiagonalMatrix m)
Returns the addition of this matrix and another.- Parameters:
m- a int diagonal matrix- Throws:
MatrixDimensionException- If the matrices are different sizes.
-
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)
-
subtract
public IntegerTridiagonalMatrix subtract(IntegerTridiagonalMatrix m)
Returns the subtraction of this matrix and another.- Parameters:
m- a int tridiagonal matrix- Throws:
MatrixDimensionException- If the matrices are different sizes.
-
subtract
public IntegerDiagonalMatrix subtract(IntegerDiagonalMatrix m)
Returns the subtraction of this matrix and another.- Parameters:
m- a int diagonal matrix- Throws:
MatrixDimensionException- If the matrices are different sizes.
-
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 diagonal 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)
-
scalarProduct
public int scalarProduct(IntegerTridiagonalMatrix m)
-
scalarProduct
public int scalarProduct(IntegerDiagonalMatrix 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)
-
multiply
public IntegerTridiagonalMatrix multiply(IntegerTridiagonalMatrix m)
-
multiply
public IntegerDiagonalMatrix multiply(IntegerDiagonalMatrix m)
-
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 diagonal matrix
-
luDecompose
public 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 AbstractDoubleSquareMatrix[] luDecompose()
Returns the LU decomposition of this matrix.- 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.- 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.- 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