JSci.maths.matrices
Class IntegerMatrix

java.lang.Object
  extended by JSci.maths.matrices.Matrix
      extended by JSci.maths.matrices.AbstractIntegerMatrix
          extended by JSci.maths.matrices.IntegerMatrix
All Implemented Interfaces:
java.io.Serializable, Algebra.Member, Module.Member, VectorSpace.Member, Ring.Member, AbelianGroup.Member, Member

public class IntegerMatrix
extends AbstractIntegerMatrix

The IntegerMatrix class provides an object for encapsulating integer matrices.

See Also:
Serialized Form

Field Summary
protected  int[][] matrix
          Array containing the elements of the matrix.
 
Fields inherited from class JSci.maths.matrices.Matrix
numCols, numRows
 
Constructor Summary
IntegerMatrix(AbstractIntegerVector[] array)
          Constructs a matrix from an array of vectors (columns).
IntegerMatrix(int[][] array)
          Constructs a matrix by wrapping an array.
IntegerMatrix(int rows, int cols)
          Constructs an empty matrix.
 
Method Summary
 AbstractIntegerMatrix add(AbstractIntegerMatrix m)
          Returns the addition of this matrix and another.
 AbstractIntegerMatrix directSum(AbstractIntegerMatrix m)
          Returns the direct sum of this matrix and another.
 boolean equals(AbstractIntegerMatrix m, double tol)
          Compares two ${nativeTyp} matrices for equality.
 double frobeniusNorm()
          Returns the Frobenius or Hilbert-Schmidt (l2) norm.
 int getElement(int i, int j)
          Returns an element of the matrix.
 int infNorm()
          Returns the linfinity-norm.
 AbstractIntegerMatrix multiply(AbstractIntegerMatrix m)
          Returns the multiplication of this matrix and another.
 AbstractIntegerVector multiply(AbstractIntegerVector v)
          Returns the multiplication of a vector by this matrix.
 AbstractIntegerMatrix multiply(IntegerMatrix m)
           
 AbelianGroup.Member negate()
          Returns the negative of this matrix.
 AbstractIntegerMatrix scalarMultiply(int x)
          Returns the multiplication of this matrix by a scalar.
 int scalarProduct(AbstractIntegerMatrix m)
          Returns the scalar product of this matrix and another.
 int scalarProduct(IntegerMatrix m)
           
 void setElement(int i, int j, int x)
          Sets the value of an element of the matrix.
 AbstractIntegerMatrix subtract(AbstractIntegerMatrix m)
          Returns the subtraction of this matrix by another.
 AbstractIntegerMatrix tensor(AbstractIntegerMatrix m)
          Returns the tensor product of this matrix and another.
 AbstractComplexMatrix toComplexMatrix()
          Converts this matrix to a complex matrix.
 AbstractDoubleMatrix toDoubleMatrix()
          Converts this matrix to a double matrix.
 java.lang.String toString()
          Returns a string representing this matrix.
 Matrix transpose()
          Returns the transpose of this matrix.
 
Methods inherited from class JSci.maths.matrices.AbstractIntegerMatrix
add, equals, equals, getSet, hashCode, multiply, scalarDivide, scalarMultiply, subtract
 
Methods inherited from class JSci.maths.matrices.Matrix
columns, getInvalidElementMsg, rows
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

matrix

protected final int[][] matrix
Array containing the elements of the matrix.

Constructor Detail

IntegerMatrix

public IntegerMatrix(int[][] array)
Constructs a matrix by wrapping an array.

Parameters:
array - an assigned value

IntegerMatrix

public IntegerMatrix(int rows,
                     int cols)
Constructs an empty matrix.


IntegerMatrix

public IntegerMatrix(AbstractIntegerVector[] array)
Constructs a matrix from an array of vectors (columns).

Parameters:
array - an assigned value
Method Detail

equals

public boolean equals(AbstractIntegerMatrix m,
                      double tol)
Compares two ${nativeTyp} matrices for equality.

Overrides:
equals in class AbstractIntegerMatrix
Parameters:
m - a int matrix

toString

public java.lang.String toString()
Returns a string representing this matrix.

Overrides:
toString in class AbstractIntegerMatrix

toDoubleMatrix

public AbstractDoubleMatrix toDoubleMatrix()
Converts this matrix to a double matrix.

Overrides:
toDoubleMatrix in class AbstractIntegerMatrix
Returns:
a double matrix

toComplexMatrix

public AbstractComplexMatrix toComplexMatrix()
Converts this matrix to a complex matrix.

Overrides:
toComplexMatrix in class AbstractIntegerMatrix
Returns:
a complex matrix

getElement

public int getElement(int i,
                      int j)
Returns an element of the matrix.

Specified by:
getElement in class AbstractIntegerMatrix
Parameters:
i - row index of the element
j - 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:
setElement in class AbstractIntegerMatrix
Parameters:
i - row index of the element
j - column index of the element
x - a number
Throws:
MatrixDimensionException - If attempting to access an invalid element.

infNorm

public int infNorm()
Returns the linfinity-norm.

Overrides:
infNorm in class AbstractIntegerMatrix

frobeniusNorm

public double frobeniusNorm()
Returns the Frobenius or Hilbert-Schmidt (l2) norm.

Overrides:
frobeniusNorm in class AbstractIntegerMatrix
PlanetMath references:
FrobeniusMatrixNorm

negate

public AbelianGroup.Member negate()
Returns the negative of this matrix.

Specified by:
negate in interface AbelianGroup.Member
Overrides:
negate in class AbstractIntegerMatrix

add

public AbstractIntegerMatrix add(AbstractIntegerMatrix m)
Returns the addition of this matrix and another.

Overrides:
add in class AbstractIntegerMatrix
Parameters:
m - a int matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

subtract

public AbstractIntegerMatrix subtract(AbstractIntegerMatrix m)
Returns the subtraction of this matrix by another.

Overrides:
subtract in class AbstractIntegerMatrix
Parameters:
m - a int 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:
scalarMultiply in class AbstractIntegerMatrix
Parameters:
x - a int.
Returns:
a int matrix.

scalarProduct

public int scalarProduct(AbstractIntegerMatrix m)
Returns the scalar product of this matrix and another.

Overrides:
scalarProduct in class AbstractIntegerMatrix
Parameters:
m - a int matrix.
Throws:
MatrixDimensionException - If the matrices are different sizes.

scalarProduct

public int scalarProduct(IntegerMatrix m)

multiply

public AbstractIntegerVector multiply(AbstractIntegerVector v)
Returns the multiplication of a vector by this matrix.

Overrides:
multiply in class AbstractIntegerMatrix
Parameters:
v - a int vector.
Throws:
DimensionException - If the matrix and vector are incompatible.

multiply

public AbstractIntegerMatrix multiply(AbstractIntegerMatrix m)
Returns the multiplication of this matrix and another.

Overrides:
multiply in class AbstractIntegerMatrix
Parameters:
m - a int matrix
Returns:
a AbstractIntegerMatrix or a AbstractIntegerSquareMatrix as appropriate
Throws:
MatrixDimensionException - If the matrices are incompatible.

multiply

public AbstractIntegerMatrix multiply(IntegerMatrix m)

directSum

public AbstractIntegerMatrix directSum(AbstractIntegerMatrix m)
Returns the direct sum of this matrix and another.

Overrides:
directSum in class AbstractIntegerMatrix

tensor

public AbstractIntegerMatrix tensor(AbstractIntegerMatrix m)
Returns the tensor product of this matrix and another.

Overrides:
tensor in class AbstractIntegerMatrix

transpose

public Matrix transpose()
Returns the transpose of this matrix.

Overrides:
transpose in class AbstractIntegerMatrix
Returns:
a int matrix