Class pmr.euclid.RealSquareMatrix
All Packages Class Hierarchy This Package Previous Next Index
Class pmr.euclid.RealSquareMatrix
java.lang.Object
|
+----pmr.euclid.Status
|
+----pmr.euclid.RealMatrix
|
+----pmr.euclid.RealSquareMatrix
- public class RealSquareMatrix
- extends RealMatrix
RealSquareMatrix - square matrix class
RealSquareMatrix represents a square m-x-m matrix.
The basic matrix algebra for square matrices is represented here
Check out the exciting member functions, which are supported by
Exceptions where appropriate. (NB. No attempt has been made to
provide numerical robustness and inversion, diagonalisation, etc
are as you find them.)
- Author:
- (C) P. Murray-Rust, 1996
-
RealSquareMatrix()
- This gives a default matrix, with cols = rows = 0.
-
RealSquareMatrix(double[][])
- form from a Java 2-D array (it holds row and column count)
-
RealSquareMatrix(int)
- This gives a null matrix
-
RealSquareMatrix(int, double)
- initalises all elements in the array with a given double[]
-
RealSquareMatrix(int, double[])
- Formed by feeding in an existing array to a colsXcols matrix.
-
RealSquareMatrix(RealMatrix)
- assign a RealMatrix - i.e.
-
RealSquareMatrix(RealMatrix, int, int, int)
- submatrix of another matrix
-
RealSquareMatrix(RealSquareMatrix)
-
-
copyLowerToUpper()
- copy lower triangle into upper triangle (i.e.
-
copyUpperToLower()
- copy upper triangle into lower triangle (i.e.
-
determinant()
- determinant - only goes up to order 3 at present :-(
-
diagonal(RealArray)
- make diagonal matrix
-
diagonaliseAndReturnRank(RealArray, RealSquareMatrix, IllConditionedMatrixException)
- diagonalisation - returns eigenvalues and vectors as MODIFIED arguments;
this is NOT affected
Note that IllConditionedMatrixException is RETURNED and not thrown
-
equals(RealSquareMatrix)
- are two matrices identical?
-
getInverse()
- inversion of matrix - creates NEW matrix
-
isImproperRotation()
- is matrix an improper rotation?
-
isLowerTriangular()
- is matrix lower triangular (including diagonal)?
-
isOrthogonal()
- is matrix orthogonal? (rowwise calculation)
-
isOrthonormal()
- is matrix unitary (orthonormal)? (synonym for isUnitary())
-
isSymmetric()
- is matrix symmetric?
-
isUnit()
- is it a unit matrix?
-
isUnitary()
-
-
isUpperTriangular()
- is matrix UpperTriangular?
-
lowerTriangle()
- copy lower triangle into linear array; order: 0,0; 1,0; 1,1; 2,0 ..
-
main(String[])
- tests RealSquareMatrix routines
-
multiply(RealSquareMatrix)
- matrix multiplication - multiplies conformable matrices;
result is this*m
-
orthogonalise()
- orthogonalise matrix (only works for 3x3 at present); MODIFIES
matrix
-
orthonormalise()
- orthonormalise matrix (only works for 3x3 at present)
-
outerProduct(RealArray)
- special types of matrix (Outerproduct, Diagonal, etc)
-
plus(RealSquareMatrix)
- matrix addition - adds conformable matrices
-
shallowCopy(RealSquareMatrix)
- shallowCopy an existing object
-
subtract(RealSquareMatrix)
- matrix subtraction - subtracts conformable matrices
-
trace()
- trace
-
transpose()
- transpose - MODIFIES matrix
RealSquareMatrix
public RealSquareMatrix()
- This gives a default matrix, with cols = rows = 0.
RealSquareMatrix
public RealSquareMatrix(int rows)
- This gives a null matrix
RealSquareMatrix
public RealSquareMatrix(int rows,
double array[]) throws InvalidArgumentException
- Formed by feeding in an existing array to a colsXcols matrix.
THE COLUMN IS THE FASTEST MOVING INDEX, i.e. the matrix is filled
as mat(0,0), mat(0,1) ... C-LIKE
- Throws: InvalidArgumentException
- array size must be multiple of rows
RealSquareMatrix
public RealSquareMatrix(int rows,
double f)
- initalises all elements in the array with a given double[]
RealSquareMatrix
public RealSquareMatrix(RealMatrix m,
int lowrow,
int lowcol,
int rows) throws InvalidArgumentException
- submatrix of another matrix
- Throws: InvalidArgumentException
- lowrow, lowcol or rows are not consistent with size of m
RealSquareMatrix
public RealSquareMatrix(RealSquareMatrix m)
RealSquareMatrix
public RealSquareMatrix(RealMatrix m) throws NonSquareMatrixException
- assign a RealMatrix - i.e. NOT copied
- Throws: NonSquareMatrixException
- m must be square (i.e. cols = rows)
RealSquareMatrix
public RealSquareMatrix(double matrix[][]) throws MatrixShapeException
- form from a Java 2-D array (it holds row and column count)
- Throws: MatrixShapeException
- matrix is not square (might even not be rectangular!)
outerProduct
public static RealSquareMatrix outerProduct(RealArray f)
- special types of matrix (Outerproduct, Diagonal, etc)
diagonal
public static RealSquareMatrix diagonal(RealArray f)
- make diagonal matrix
shallowCopy
public void shallowCopy(RealSquareMatrix m) throws UnconformableMatricesException
- shallowCopy an existing object
- Throws: UnconformableMatricesException
- m must have the same number of rows and cols as this
equals
public boolean equals(RealSquareMatrix r) throws UnconformableMatricesException
- are two matrices identical?
- Throws: UnconformableMatricesException
- m must have the same number of rows and cols as this
plus
public RealSquareMatrix plus(RealSquareMatrix m) throws MatrixShapeException
- matrix addition - adds conformable matrices
- Throws: MatrixShapeException
- m must have the same number of rows and cols as this
subtract
public RealSquareMatrix subtract(RealSquareMatrix m) throws MatrixShapeException
- matrix subtraction - subtracts conformable matrices
- Throws: MatrixShapeException
- m must have the same number of rows and cols as this
multiply
public RealSquareMatrix multiply(RealSquareMatrix m) throws MatrixShapeException
- matrix multiplication - multiplies conformable matrices;
result is this*m
- Throws: MatrixShapeException
- m must have the same number of rows as this has cols
determinant
public double determinant() throws UnimplementedException
- determinant - only goes up to order 3 at present :-(
- Throws: UnimplementedException
- I have only written this for this.rows up to 3. If anyone can find a determinant routine, this will disappear ... -(
trace
public double trace()
- trace
isUnit
public boolean isUnit()
- is it a unit matrix?
isSymmetric
public boolean isSymmetric()
- is matrix symmetric?
orthonormalise
public RealSquareMatrix orthonormalise() throws UnimplementedException
- orthonormalise matrix (only works for 3x3 at present)
- Throws: UnimplementedException
- I have only written this for this.rows up to 3. If anyone can find a routine, this will disappear ... -(
orthogonalise
public void orthogonalise() throws UnimplementedException
- orthogonalise matrix (only works for 3x3 at present); MODIFIES
matrix
- Throws: UnimplementedException
- I have only written this for this.rows up to 3. If anyone can find a routine, this will disappear ... -(
isOrthonormal
public boolean isOrthonormal()
- is matrix unitary (orthonormal)? (synonym for isUnitary())
isUnitary
public boolean isUnitary()
isImproperRotation
public boolean isImproperRotation()
- is matrix an improper rotation?
isUpperTriangular
public boolean isUpperTriangular()
- is matrix UpperTriangular?
isLowerTriangular
public boolean isLowerTriangular()
- is matrix lower triangular (including diagonal)?
isOrthogonal
public boolean isOrthogonal()
- is matrix orthogonal? (rowwise calculation)
- Overrides:
- isOrthogonal in class RealMatrix
copyUpperToLower
public RealSquareMatrix copyUpperToLower()
- copy upper triangle into lower triangle (i.e. make symmetric)
copyLowerToUpper
public RealSquareMatrix copyLowerToUpper()
- copy lower triangle into upper triangle (i.e. make symmetric)
lowerTriangle
public RealArray lowerTriangle()
- copy lower triangle into linear array; order: 0,0; 1,0; 1,1; 2,0 ..
transpose
public void transpose()
- transpose - MODIFIES matrix
diagonaliseAndReturnRank
public int diagonaliseAndReturnRank(RealArray eigenvalues,
RealSquareMatrix eigenvectors,
IllConditionedMatrixException illCond) throws ArrayTooSmallException
- diagonalisation - returns eigenvalues and vectors as MODIFIED arguments;
this is NOT affected
Note that IllConditionedMatrixException is RETURNED and not thrown
- Throws: ArrayTooSmallException
- must have at least order 2
getInverse
public RealSquareMatrix getInverse() throws SingularMatrixException
- inversion of matrix - creates NEW matrix
- Throws: SingularMatrixException
- singular matrix (or worse!)
main
public static void main(String args[])
- tests RealSquareMatrix routines
All Packages Class Hierarchy This Package Previous Next Index