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

Constructor Index

 o RealSquareMatrix()
This gives a default matrix, with cols = rows = 0.
 o RealSquareMatrix(double[][])
form from a Java 2-D array (it holds row and column count)
 o RealSquareMatrix(int)
This gives a null matrix
 o RealSquareMatrix(int, double)
initalises all elements in the array with a given double[]
 o RealSquareMatrix(int, double[])
Formed by feeding in an existing array to a colsXcols matrix.
 o RealSquareMatrix(RealMatrix)
assign a RealMatrix - i.e.
 o RealSquareMatrix(RealMatrix, int, int, int)
submatrix of another matrix
 o RealSquareMatrix(RealSquareMatrix)

Method Index

 o copyLowerToUpper()
copy lower triangle into upper triangle (i.e.
 o copyUpperToLower()
copy upper triangle into lower triangle (i.e.
 o determinant()
determinant - only goes up to order 3 at present :-(
 o diagonal(RealArray)
make diagonal matrix
 o diagonaliseAndReturnRank(RealArray, RealSquareMatrix, IllConditionedMatrixException)
diagonalisation - returns eigenvalues and vectors as MODIFIED arguments; this is NOT affected

Note that IllConditionedMatrixException is RETURNED and not thrown

 o equals(RealSquareMatrix)
are two matrices identical?
 o getInverse()
inversion of matrix - creates NEW matrix
 o isImproperRotation()
is matrix an improper rotation?
 o isLowerTriangular()
is matrix lower triangular (including diagonal)?
 o isOrthogonal()
is matrix orthogonal? (rowwise calculation)
 o isOrthonormal()
is matrix unitary (orthonormal)? (synonym for isUnitary())
 o isSymmetric()
is matrix symmetric?
 o isUnit()
is it a unit matrix?
 o isUnitary()
 o isUpperTriangular()
is matrix UpperTriangular?
 o lowerTriangle()
copy lower triangle into linear array; order: 0,0; 1,0; 1,1; 2,0 ..
 o main(String[])
tests RealSquareMatrix routines
 o multiply(RealSquareMatrix)
matrix multiplication - multiplies conformable matrices; result is this*m
 o orthogonalise()
orthogonalise matrix (only works for 3x3 at present); MODIFIES matrix
 o orthonormalise()
orthonormalise matrix (only works for 3x3 at present)
 o outerProduct(RealArray)
special types of matrix (Outerproduct, Diagonal, etc)
 o plus(RealSquareMatrix)
matrix addition - adds conformable matrices
 o shallowCopy(RealSquareMatrix)
shallowCopy an existing object
 o subtract(RealSquareMatrix)
matrix subtraction - subtracts conformable matrices
 o trace()
trace
 o transpose()
transpose - MODIFIES matrix

Constructors

 o RealSquareMatrix
  public RealSquareMatrix()
This gives a default matrix, with cols = rows = 0.
 o RealSquareMatrix
  public RealSquareMatrix(int rows)
This gives a null matrix
 o 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
 o RealSquareMatrix
  public RealSquareMatrix(int rows,
                          double f)
initalises all elements in the array with a given double[]
 o 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
 o RealSquareMatrix
  public RealSquareMatrix(RealSquareMatrix m)
 o RealSquareMatrix
  public RealSquareMatrix(RealMatrix m) throws NonSquareMatrixException
assign a RealMatrix - i.e. NOT copied
Throws: NonSquareMatrixException
m must be square (i.e. cols = rows)
 o 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!)

Methods

 o outerProduct
  public static RealSquareMatrix outerProduct(RealArray f)
special types of matrix (Outerproduct, Diagonal, etc)
 o diagonal
  public static RealSquareMatrix diagonal(RealArray f)
make diagonal matrix
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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 ... -(
 o trace
  public double trace()
trace
 o isUnit
  public boolean isUnit()
is it a unit matrix?
 o isSymmetric
  public boolean isSymmetric()
is matrix symmetric?
 o 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 ... -(
 o 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 ... -(
 o isOrthonormal
  public boolean isOrthonormal()
is matrix unitary (orthonormal)? (synonym for isUnitary())
 o isUnitary
  public boolean isUnitary()
 o isImproperRotation
  public boolean isImproperRotation()
is matrix an improper rotation?
 o isUpperTriangular
  public boolean isUpperTriangular()
is matrix UpperTriangular?
 o isLowerTriangular
  public boolean isLowerTriangular()
is matrix lower triangular (including diagonal)?
 o isOrthogonal
  public boolean isOrthogonal()
is matrix orthogonal? (rowwise calculation)
Overrides:
isOrthogonal in class RealMatrix
 o copyUpperToLower
  public RealSquareMatrix copyUpperToLower()
copy upper triangle into lower triangle (i.e. make symmetric)
 o copyLowerToUpper
  public RealSquareMatrix copyLowerToUpper()
copy lower triangle into upper triangle (i.e. make symmetric)
 o lowerTriangle
  public RealArray lowerTriangle()
copy lower triangle into linear array; order: 0,0; 1,0; 1,1; 2,0 ..
 o transpose
  public void transpose()
transpose - MODIFIES matrix
 o 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
 o getInverse
  public RealSquareMatrix getInverse() throws SingularMatrixException
inversion of matrix - creates NEW matrix
Throws: SingularMatrixException
singular matrix (or worse!)
 o main
  public static void main(String args[])
tests RealSquareMatrix routines

All Packages  Class Hierarchy  This Package  Previous  Next  Index