JSci.maths.matrices
Class AbstractDoubleMatrix

java.lang.Object
  extended by JSci.maths.matrices.Matrix
      extended by JSci.maths.matrices.AbstractDoubleMatrix
All Implemented Interfaces:
java.io.Serializable, Algebra.Member, Module.Member, VectorSpace.Member, Ring.Member, AbelianGroup.Member, Member
Direct Known Subclasses:
AbstractDoubleSquareMatrix, DoubleMatrix, DoubleSparseMatrix

public abstract class AbstractDoubleMatrix
extends Matrix

The AbstractDoubleMatrix class provides an object for encapsulating double matrices.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class JSci.maths.matrices.Matrix
numCols, numRows
 
Constructor Summary
protected AbstractDoubleMatrix(int rows, int cols)
          Constructs a matrix.
 
Method Summary
 AbelianGroup.Member add(AbelianGroup.Member m)
          Returns the addition of this matrix and another.
 AbstractDoubleMatrix add(AbstractDoubleMatrix m)
          Returns the addition of this matrix and another.
 AbstractDoubleMatrix directSum(AbstractDoubleMatrix m)
          Returns the direct sum of this matrix and another.
 boolean equals(AbstractDoubleMatrix m)
          Compares two ${nativeTyp} matrices for equality.
 boolean equals(AbstractDoubleMatrix m, double tol)
           
 boolean equals(java.lang.Object obj)
          Compares two ${nativeTyp} matrices for equality.
 double frobeniusNorm()
          Returns the Frobenius or Hilbert-Schmidt (l2) norm.
abstract  double getElement(int i, int j)
          Returns an element of the matrix.
 java.lang.Object getSet()
           
 int hashCode()
          Returns a hashcode for this matrix.
 double infNorm()
          Returns the linfinity-norm.
 AbstractDoubleMatrix mapElements(Mapping f)
          Applies a function on all the matrix elements.
 AbstractDoubleMatrix multiply(AbstractDoubleMatrix m)
          Returns the multiplication of this matrix and another.
 AbstractDoubleVector multiply(AbstractDoubleVector 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.
 AbstractDoubleMatrix scalarDivide(double x)
          Returns the division of this matrix by a scalar.
 VectorSpace.Member scalarDivide(Field.Member x)
          Returns the division of this matrix by a scalar.
 AbstractDoubleMatrix scalarMultiply(double 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.
 double scalarProduct(AbstractDoubleMatrix m)
          Returns the scalar product of this matrix and another.
abstract  void setElement(int i, int j, double x)
          Sets the value of an element of the matrix.
 AbelianGroup.Member subtract(AbelianGroup.Member m)
          Returns the subtraction of this matrix by another.
 AbstractDoubleMatrix subtract(AbstractDoubleMatrix m)
          Returns the subtraction of this matrix by another.
 AbstractDoubleMatrix tensor(AbstractDoubleMatrix m)
          Returns the tensor product of this matrix and another.
 AbstractComplexMatrix toComplexMatrix()
          Converts this matrix to a complex matrix.
 AbstractIntegerMatrix toIntegerMatrix()
          Converts this matrix to an integer 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.Matrix
columns, getInvalidElementMsg, rows
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractDoubleMatrix

protected AbstractDoubleMatrix(int rows,
                               int cols)
Constructs a matrix.

Method Detail

equals

public final boolean equals(java.lang.Object obj)
Compares two ${nativeTyp} matrices for equality.

Overrides:
equals in class java.lang.Object
Parameters:
obj - a double matrix

equals

public final boolean equals(AbstractDoubleMatrix m)
Compares two ${nativeTyp} matrices for equality. Two matrices are considered to be equal if the Frobenius norm of their difference is within the zero tolerance.

Parameters:
m - a double matrix

equals

public boolean equals(AbstractDoubleMatrix m,
                      double tol)

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

toIntegerMatrix

public AbstractIntegerMatrix toIntegerMatrix()
Converts this matrix to an integer matrix.

Returns:
an integer matrix

toComplexMatrix

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

Returns:
a complex matrix

getElement

public abstract double 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 abstract void setElement(int i,
                                int j,
                                double x)
Sets the value of an element of the matrix. Should only be used to initialise this matrix.

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.

getSet

public final java.lang.Object getSet()

infNorm

public double infNorm()
Returns the linfinity-norm.


frobeniusNorm

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

PlanetMath references:
FrobeniusMatrixNorm

negate

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


add

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

Parameters:
m - a group member

add

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

Parameters:
m - a double matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

subtract

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

Parameters:
m - a group member

subtract

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

Parameters:
m - a double matrix
Throws:
MatrixDimensionException - If the matrices are different sizes.

scalarMultiply

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

Parameters:
x - a ring member

scalarMultiply

public AbstractDoubleMatrix scalarMultiply(double x)
Returns the multiplication of this matrix by a scalar.

Parameters:
x - a double.
Returns:
a double matrix.

scalarDivide

public final VectorSpace.Member scalarDivide(Field.Member x)
Returns the division of this matrix by a scalar. Always throws an exception.

Parameters:
x - a field member

scalarDivide

public AbstractDoubleMatrix scalarDivide(double x)
Returns the division of this matrix by a scalar.

Parameters:
x - a double.
Returns:
a double matrix.

scalarProduct

public double scalarProduct(AbstractDoubleMatrix m)
Returns the scalar product of this matrix and another.

Parameters:
m - a double matrix.
Throws:
MatrixDimensionException - If the matrices are different sizes.

multiply

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

Parameters:
v - a double vector.
Throws:
DimensionException - If the matrix and vector are incompatible.

multiply

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

Parameters:
m - a ring member

multiply

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

Parameters:
m - a double matrix
Returns:
a AbstractDoubleMatrix or a AbstractDoubleSquareMatrix as appropriate
Throws:
MatrixDimensionException - If the matrices are incompatible.

directSum

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


tensor

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


transpose

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

Specified by:
transpose in class Matrix
Returns:
a double matrix

mapElements

public AbstractDoubleMatrix mapElements(Mapping f)
Applies a function on all the matrix elements.

Parameters:
f - a user-defined function
Returns:
a double matrix