jsci.maths.matrices
Class DoubleSquareMatrix
- java.lang.Object
-
- jsci.maths.matrices.Matrix
-
- jsci.maths.matrices.AbstractDoubleMatrix
-
- jsci.maths.matrices.AbstractDoubleSquareMatrix
-
- jsci.maths.matrices.DoubleSquareMatrix
-
- All Implemented Interfaces:
- java.io.Serializable, Algebra.Member, Module.Member, VectorSpace.Member, Ring.Member, AbelianGroup.Member, SquareMatrix, Member
public class DoubleSquareMatrix extends AbstractDoubleSquareMatrix
The DoubleSquareMatrix class provides an object for encapsulating double square matrices.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description DoubleSquareMatrix(AbstractDoubleVector[] array)Constructs a matrix from an array of vectors (columns).DoubleSquareMatrix(double[][] array)Constructs a matrix by wrapping an array.DoubleSquareMatrix(int size)Constructs an empty matrix.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description AbstractDoubleSquareMatrixadd(AbstractDoubleSquareMatrix m)Returns the addition of this matrix and another.DoubleSquareMatrixadd(DoubleSquareMatrix m)AbstractDoubleSquareMatrix[]choleskyDecompose()Returns the Cholesky decomposition of this matrix.doubledet()Returns the determinant.AbstractDoubleSquareMatrixdirectSum(AbstractDoubleSquareMatrix m)Returns the direct sum of this matrix and another.booleanequals(AbstractDoubleMatrix m, double tol)Compares two ${nativeTyp} matrices for equality.doublefrobeniusNorm()Returns the Frobenius or Hilbert-Schmidt (l2) norm.doublegetElement(int i, int j)Returns an element of the matrix.doubleinfNorm()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.AbstractDoubleMatrixmapElements(Mapping f)Applies a function on all the matrix elements.AbstractDoubleSquareMatrixmultiply(AbstractDoubleSquareMatrix m)Returns the multiplication of this matrix and another.AbstractDoubleVectormultiply(AbstractDoubleVector v)Returns the multiplication of a vector by this matrix.DoubleSquareMatrixmultiply(DoubleSquareMatrix m)AbelianGroup.Membernegate()Returns the negative of this matrix.AbstractDoubleSquareMatrix[]polarDecompose()Returns the polar decomposition of this matrix.AbstractDoubleSquareMatrix[]qrDecompose()Returns the QR decomposition of this matrix.AbstractDoubleMatrixscalarDivide(double x)Returns the division of this matrix by a scalar.AbstractDoubleMatrixscalarMultiply(double x)Returns the multiplication of this matrix by a scalar.doublescalarProduct(AbstractDoubleSquareMatrix m)Returns the scalar product of this matrix and another.doublescalarProduct(DoubleSquareMatrix m)voidsetElement(int i, int j, double x)Sets the value of an element of the matrix.AbstractDoubleSquareMatrix[]singularValueDecompose()Returns the singular value decomposition of this matrix.AbstractDoubleSquareMatrixsubtract(AbstractDoubleSquareMatrix m)Returns the subtraction of this matrix by another.DoubleSquareMatrixsubtract(DoubleSquareMatrix m)AbstractDoubleSquareMatrixtensor(AbstractDoubleSquareMatrix m)Returns the tensor product of this matrix and another.AbstractComplexMatrixtoComplexMatrix()Converts this matrix to a complex matrix.AbstractIntegerMatrixtoIntegerMatrix()Converts this matrix to an integer matrix.java.lang.StringtoString()Returns a string representing this matrix.doubletrace()Returns the trace.Matrixtranspose()Returns the transpose of this matrix.-
Methods inherited from class jsci.maths.matrices.AbstractDoubleSquareMatrix
add, isSymmetric, isUnitary, operatorNorm, scalarProduct, subtract
-
Methods inherited from class jsci.maths.matrices.AbstractDoubleMatrix
add, directSum, equals, equals, getSet, hashCode, multiply, multiply, scalarDivide, scalarMultiply, subtract, tensor
-
-
-
-
Constructor Detail
-
DoubleSquareMatrix
public DoubleSquareMatrix(double[][] array)
Constructs a matrix by wrapping an array.- Parameters:
array- an assigned value
-
DoubleSquareMatrix
public DoubleSquareMatrix(int size)
Constructs an empty matrix.
-
DoubleSquareMatrix
public DoubleSquareMatrix(AbstractDoubleVector[] array)
Constructs a matrix from an array of vectors (columns).- Parameters:
array- an assigned value
-
-
Method Detail
-
equals
public boolean equals(AbstractDoubleMatrix m, double tol)
Compares two ${nativeTyp} matrices for equality.- Overrides:
equalsin classAbstractDoubleMatrix- Parameters:
m- a double matrix
-
toString
public java.lang.String toString()
Returns a string representing this matrix.- Overrides:
toStringin classAbstractDoubleMatrix
-
toIntegerMatrix
public AbstractIntegerMatrix toIntegerMatrix()
Converts this matrix to an integer matrix.- Overrides:
toIntegerMatrixin classAbstractDoubleSquareMatrix- Returns:
- an integer matrix
-
toComplexMatrix
public AbstractComplexMatrix toComplexMatrix()
Converts this matrix to a complex matrix.- Overrides:
toComplexMatrixin classAbstractDoubleSquareMatrix- Returns:
- a complex matrix
-
getElement
public double getElement(int i, int j)Returns an element of the matrix.- Specified by:
getElementin classAbstractDoubleMatrix- 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, double x)Sets the value of an element of the matrix. Should only be used to initialise this matrix.- Specified by:
setElementin classAbstractDoubleMatrix- 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 double infNorm()
Returns the l
-norm.- Overrides:
infNormin classAbstractDoubleMatrix
-
frobeniusNorm
public double frobeniusNorm()
Returns the Frobenius or Hilbert-Schmidt (l2) norm.- Overrides:
frobeniusNormin classAbstractDoubleMatrix
-
det
public double det()
Returns the determinant.- Overrides:
detin classAbstractDoubleSquareMatrix
-
trace
public double trace()
Returns the trace.- Overrides:
tracein classAbstractDoubleSquareMatrix
-
negate
public AbelianGroup.Member negate()
Returns the negative of this matrix.- Specified by:
negatein interfaceAbelianGroup.Member- Overrides:
negatein classAbstractDoubleSquareMatrix
-
add
public AbstractDoubleSquareMatrix add(AbstractDoubleSquareMatrix m)
Returns the addition of this matrix and another.- Overrides:
addin classAbstractDoubleSquareMatrix- Parameters:
m- a double matrix- Throws:
MatrixDimensionException- If the matrices are different sizes.
-
add
public DoubleSquareMatrix add(DoubleSquareMatrix m)
-
subtract
public AbstractDoubleSquareMatrix subtract(AbstractDoubleSquareMatrix m)
Returns the subtraction of this matrix by another.- Overrides:
subtractin classAbstractDoubleSquareMatrix- Parameters:
m- a double matrix- Throws:
MatrixDimensionException- If the matrices are different sizes.
-
subtract
public DoubleSquareMatrix subtract(DoubleSquareMatrix m)
-
scalarMultiply
public AbstractDoubleMatrix scalarMultiply(double x)
Returns the multiplication of this matrix by a scalar.- Overrides:
scalarMultiplyin classAbstractDoubleSquareMatrix- Parameters:
x- a double.- Returns:
- a double square matrix.
-
scalarDivide
public AbstractDoubleMatrix scalarDivide(double x)
Returns the division of this matrix by a scalar.- Overrides:
scalarDividein classAbstractDoubleSquareMatrix- Parameters:
x- a double.- Returns:
- a double square matrix.
-
scalarProduct
public double scalarProduct(AbstractDoubleSquareMatrix m)
Returns the scalar product of this matrix and another.- Overrides:
scalarProductin classAbstractDoubleSquareMatrix- Parameters:
m- a double matrix.- Throws:
MatrixDimensionException- If the matrices are different sizes.
-
scalarProduct
public double scalarProduct(DoubleSquareMatrix m)
-
multiply
public AbstractDoubleVector multiply(AbstractDoubleVector v)
Returns the multiplication of a vector by this matrix.- Overrides:
multiplyin classAbstractDoubleMatrix- Parameters:
v- a double vector.- Throws:
DimensionException- If the matrix and vector are incompatible.
-
multiply
public AbstractDoubleSquareMatrix multiply(AbstractDoubleSquareMatrix m)
Returns the multiplication of this matrix and another.- Overrides:
multiplyin classAbstractDoubleSquareMatrix- Parameters:
m- a double matrix- Returns:
- a AbstractDoubleMatrix or a AbstractDoubleSquareMatrix as appropriate
- Throws:
MatrixDimensionException- If the matrices are incompatible.
-
multiply
public DoubleSquareMatrix multiply(DoubleSquareMatrix m)
-
directSum
public AbstractDoubleSquareMatrix directSum(AbstractDoubleSquareMatrix m)
Returns the direct sum of this matrix and another.- Overrides:
directSumin classAbstractDoubleSquareMatrix
-
tensor
public AbstractDoubleSquareMatrix tensor(AbstractDoubleSquareMatrix m)
Returns the tensor product of this matrix and another.- Overrides:
tensorin classAbstractDoubleSquareMatrix
-
transpose
public Matrix transpose()
Returns the transpose of this matrix.- Overrides:
transposein classAbstractDoubleSquareMatrix- Returns:
- a double matrix
-
inverse
public AbstractDoubleSquareMatrix inverse()
Returns the inverse of this matrix.- Overrides:
inversein classAbstractDoubleSquareMatrix- Returns:
- a double square matrix.
-
luDecompose
public final AbstractDoubleSquareMatrix[] luDecompose(int[] pivot)
Returns the LU decomposition of this matrix.- Overrides:
luDecomposein classAbstractDoubleSquareMatrix- 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 classAbstractDoubleSquareMatrix- 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 classAbstractDoubleSquareMatrix- 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 classAbstractDoubleSquareMatrix- 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 classAbstractDoubleSquareMatrix- Returns:
- an array with [0] containing the U-matrix, [1] containing the S-matrix and [2] containing the V-matrix.
-
polarDecompose
public AbstractDoubleSquareMatrix[] polarDecompose()
Returns the polar decomposition of this matrix.- Overrides:
polarDecomposein classAbstractDoubleSquareMatrix
-
mapElements
public AbstractDoubleMatrix mapElements(Mapping f)
Applies a function on all the matrix elements.- Overrides:
mapElementsin classAbstractDoubleSquareMatrix- Parameters:
f- a user-defined function- Returns:
- a double matrix
-
-
DMelt 3.0 © DataMelt by jWork.ORG