jumbo.euclid
Class IntSquareMatrix

java.lang.Object
  |
  +--jumbo.euclid.Status
        |
        +--jumbo.euclid.IntMatrix
              |
              +--jumbo.euclid.IntSquareMatrix

public class IntSquareMatrix
extends IntMatrix

IntSquareMatrix - square matrix class

IntSquareMatrix 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.)


Fields inherited from class jumbo.euclid.IntMatrix
cols, flmat, rows
 
Constructor Summary
IntSquareMatrix()
          This gives a default matrix, with cols = rows = 0.
IntSquareMatrix(int rows)
          This gives a null matrix
IntSquareMatrix(int[][] matrix)
          form from a Java 2-D array (it holds row and column count)
IntSquareMatrix(int rows, int f)
          initalises all elements in the array with a given int[]
IntSquareMatrix(int rows, int[] array)
          Formed by feeding in an existing array to a colsXcols matrix.
IntSquareMatrix(IntMatrix m)
          assign a IntMatrix - i.e.
IntSquareMatrix(IntMatrix m, int lowrow, int lowcol, int rows)
          submatrix of another matrix
IntSquareMatrix(IntSquareMatrix m)
           
 
Method Summary
 IntSquareMatrix copyLowerToUpper()
          copy lower triangle into upper triangle (i.e.
 IntSquareMatrix copyUpperToLower()
          copy upper triangle into lower triangle (i.e.
 int determinant()
          determinant - only goes up to order 3 at present :-(
static IntSquareMatrix diagonal(IntArray f)
          make diagonal matrix
 boolean equals(IntSquareMatrix r)
          are two matrices identical?
 boolean isLowerTriangular()
          is matrix lower triangular (including diagonal)?
 boolean isSymmetric()
          is matrix symmetric?
 boolean isUnit()
          is it a unit matrix?
 boolean isUpperTriangular()
          is matrix UpperTriangular?
 IntArray lowerTriangle()
          copy lower triangle into linear array; order: 0,0; 1,0; 1,1; 2,0 ..
 IntSquareMatrix multiply(IntSquareMatrix m)
          matrix multiplication - multiplies conformable matrices; result is this*m
static IntSquareMatrix outerProduct(IntArray f)
          special types of matrix (Outerproduct, Diagonal, etc)
 IntSquareMatrix plus(IntSquareMatrix m)
          matrix addition - adds conformable matrices
 void shallowCopy(IntSquareMatrix m)
          shallowCopy an existing object
 IntSquareMatrix subtract(IntSquareMatrix m)
          matrix subtraction - subtracts conformable matrices
 int trace()
          trace
 void transpose()
          transpose - MODIFIES matrix
 
Methods inherited from class jumbo.euclid.IntMatrix
appendColumnData, appendColumnData, appendRowData, appendRowData, clearMatrix, clone, deleteColumn, deleteColumns, deleteRow, deleteRows, elementAt, elementAt, elementsInRange, equals, extractColumnData, extractRowData, extractSubMatrixData, getCols, getMatrix, getMatrixAsArray, getRows, getTranspose, indexOfLargestElement, indexOfLargestElementInColumn, indexOfLargestElementInRow, indexOfSmallestElement, indexOfSmallestElementInColumn, indexOfSmallestElementInRow, insertColumnData, insertColumnData, insertColumns, insertRowData, insertRowData, insertRows, isSquare, largestElement, largestElementInColumn, largestElementInRow, main, multiply, multiply, multiplyBy, negative, plus, reorderColumnsBy, reorderRowsBy, replaceColumnData, replaceColumnData, replaceColumnData, replaceRowData, replaceRowData, replaceRowData, replaceSubMatrixData, setAllElements, setElementAt, shallowCopy, smallestElement, smallestElementInColumn, smallestElementInRow, subtract, toString
 
Methods inherited from class jumbo.euclid.Status
NYI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntSquareMatrix

public IntSquareMatrix()
This gives a default matrix, with cols = rows = 0.

IntSquareMatrix

public IntSquareMatrix(int rows)
This gives a null matrix

IntSquareMatrix

public IntSquareMatrix(int rows,
                       int[] array)
                throws BadArgumentException
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:
BadArgumentException - array size must be multiple of rows

IntSquareMatrix

public IntSquareMatrix(int rows,
                       int f)
initalises all elements in the array with a given int[]

IntSquareMatrix

public IntSquareMatrix(IntMatrix m,
                       int lowrow,
                       int lowcol,
                       int rows)
                throws BadArgumentException
submatrix of another matrix
Throws:
BadArgumentException - lowrow, lowcol or rows are not consistent with size of m

IntSquareMatrix

public IntSquareMatrix(IntSquareMatrix m)

IntSquareMatrix

public IntSquareMatrix(IntMatrix m)
                throws NonSquareException
assign a IntMatrix - i.e. NOT copied
Throws:
NonSquareException - m must be square (i.e. cols = rows)

IntSquareMatrix

public IntSquareMatrix(int[][] 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!)
Method Detail

outerProduct

public static IntSquareMatrix outerProduct(IntArray f)
special types of matrix (Outerproduct, Diagonal, etc)

diagonal

public static IntSquareMatrix diagonal(IntArray f)
make diagonal matrix

shallowCopy

public void shallowCopy(IntSquareMatrix m)
                 throws UnequalMatricesException
shallowCopy an existing object
Throws:
UnequalMatricesException - m must have the same number of rows and cols as this

equals

public boolean equals(IntSquareMatrix r)
               throws UnequalMatricesException
are two matrices identical?
Throws:
UnequalMatricesException - m must have the same number of rows and cols as this

plus

public IntSquareMatrix plus(IntSquareMatrix m)
                     throws MatrixShapeException
matrix addition - adds conformable matrices
Throws:
MatrixShapeException - m must have the same number of rows and cols as this

subtract

public IntSquareMatrix subtract(IntSquareMatrix m)
                         throws MatrixShapeException
matrix subtraction - subtracts conformable matrices
Throws:
MatrixShapeException - m must have the same number of rows and cols as this

multiply

public IntSquareMatrix multiply(IntSquareMatrix 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 int 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 int trace()
trace

isUnit

public boolean isUnit()
is it a unit matrix?

isSymmetric

public boolean isSymmetric()
is matrix symmetric?

isUpperTriangular

public boolean isUpperTriangular()
is matrix UpperTriangular?

isLowerTriangular

public boolean isLowerTriangular()
is matrix lower triangular (including diagonal)?

copyUpperToLower

public IntSquareMatrix copyUpperToLower()
copy upper triangle into lower triangle (i.e. make symmetric)

copyLowerToUpper

public IntSquareMatrix copyLowerToUpper()
copy lower triangle into upper triangle (i.e. make symmetric)

lowerTriangle

public IntArray lowerTriangle()
copy lower triangle into linear array; order: 0,0; 1,0; 1,1; 2,0 ..

transpose

public void transpose()
transpose - MODIFIES matrix