JSci.maths
Class IntegerMatrix

java.lang.Object
  extended by JSci.maths.Matrix
      extended by JSci.maths.IntegerMatrix
All Implemented Interfaces:
java.io.Serializable, Algebra.Member, Module.Member, VectorSpace.Member, Ring.Member, AbelianGroup.Member, Member
Direct Known Subclasses:
IntegerSquareMatrix

public class IntegerMatrix
extends Matrix

The IntegerMatrix class provides an object for encapsulating matrices containing integers.

Version:
2.1
Author:
Mark Hale
See Also:
Serialized Form

Field Summary
protected static int ARRAY_2D
          Storage format identifier.
protected  int[][] matrix
          Array containing the elements of the matrix.
 
Fields inherited from class JSci.maths.Matrix
CLASS_SPECIFIC, numCols, numRows, storageFormat
 
Constructor Summary
  IntegerMatrix(int[][] array)
          Constructs a matrix by wrapping an array.
  IntegerMatrix(IntegerVector[] array)
          Constructs a matrix from an array of vectors (columns).
  IntegerMatrix(int rows, int cols)
          Constructs an empty matrix.
protected IntegerMatrix(int rows, int cols, int storeID)
          Constructs a matrix.
 
Method Summary
 AbelianGroup.Member add(AbelianGroup.Member m)
          Returns the addition of this matrix and another.
 IntegerMatrix add(IntegerMatrix m)
          Returns the addition of this matrix and another.
 boolean equals(java.lang.Object m)
          Compares two integer matrices for equality.
protected  void finalize()
          Finalize.
 double frobeniusNorm()
          Returns the Frobenius (l2) norm.
 int getElement(int i, int j)
          Returns an element of the matrix.
 int hashCode()
          Returns a hashcode for this matrix.
 int infNorm()
          Returns the linfinity-norm.
 IntegerMatrix multiply(IntegerMatrix m)
          Returns the multiplication of this matrix and another.
 IntegerVector multiply(IntegerVector v)
          Returns the multiplication of a vector by this matrix.
 Ring.Member multiply(Ring.Member m)
          Returns the multiplication of this matrix and another.
 AbelianGroup.Member negate()
          Returns the negative of this matrix.
 VectorSpace.Member scalarDivide(Field.Member x)
          Returns the division of this matrix by a scalar.
 IntegerMatrix scalarMultiply(int x)
          Returns the multiplication of this matrix by a scalar.
 Module.Member scalarMultiply(Ring.Member x)
          Returns the multiplication of this matrix by a scalar.
 void setElement(int i, int j, int x)
          Sets the value of an element of the matrix.
 AbelianGroup.Member subtract(AbelianGroup.Member m)
          Returns the subtraction of this matrix by another.
 IntegerMatrix subtract(IntegerMatrix m)
          Returns the subtraction of this matrix by another.
 ComplexMatrix toComplexMatrix()
          Converts this matrix to a complex matrix.
 DoubleMatrix 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.Matrix
columns, getInvalidElementMsg, rows
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ARRAY_2D

protected static final int ARRAY_2D
Storage format identifier.

See Also:
Constant Field Values

matrix

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

Constructor Detail

IntegerMatrix

protected IntegerMatrix(int rows,
                        int cols,
                        int storeID)
Constructs a matrix.


IntegerMatrix

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

Parameters:
rows - the number of rows
cols - the number of columns

IntegerMatrix

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

Parameters:
array - an assigned value

IntegerMatrix

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

Parameters:
array - an assigned value
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Finalize.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - Any that occur.

equals

public boolean equals(java.lang.Object m)
Compares two integer matrices for equality.

Overrides:
equals in class java.lang.Object
Parameters:
m - an integer matrix

toString

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

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Returns a hashcode for this matrix.

Overrides:
hashCode in class java.lang.Object

toDoubleMatrix

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

Returns:
a double matrix

toComplexMatrix

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

Returns:
a complex matrix

getElement

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

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.

Parameters:
i - row index of the element
j - column index of the element
x - an integer
Throws:
MatrixDimensionException - If attempting to access an invalid element.

infNorm

public int infNorm()
Returns the linfinity-norm.


frobeniusNorm

public double frobeniusNorm()
Returns the Frobenius (l2) norm.


negate

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


add

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

Parameters:
m - a group member

add

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

Parameters:
m - an integer matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

subtract

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

Parameters:
m - a group member

subtract

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

Parameters:
m - an integer matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

scalarMultiply

public Module.Member scalarMultiply(Ring.Member x)
Returns the multiplication of this matrix by a scalar.

Parameters:
x - a ring member

scalarMultiply

public IntegerMatrix scalarMultiply(int x)
Returns the multiplication of this matrix by a scalar.

Parameters:
x - an integer
Returns:
an integer matrix

scalarDivide

public VectorSpace.Member scalarDivide(Field.Member x)
Returns the division of this matrix by a scalar.

Parameters:
x - a field member

multiply

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

Parameters:
v - an integer vector
Throws:
DimensionException - If the matrix and vector are incompatible.

multiply

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

Parameters:
m - a ring member

multiply

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

Parameters:
m - an integer matrix
Returns:
an IntegerMatrix or a IntegerSquareMatrix as appropriate
Throws:
MatrixDimensionException - If the matrices are incompatible.

transpose

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

Specified by:
transpose in class Matrix
Returns:
an integer matrix