mathcomp.la
Class Matrix

java.lang.Object
  extended by mathcomp.la.Matrix
Direct Known Subclasses:
MapMatrix

public abstract class Matrix
extends java.lang.Object

A quadratic matrix based on an index. To access the elements use the methods get(Object i, Object j) and set(Object i, Object j, double value). The Matrix is designed for sparse handling. So use the relevantIndices(Object row) for handling the matrix.

Author:
pht

Constructor Summary
Matrix()
           
 
Method Summary
 void add(java.lang.Object i, java.lang.Object j, double x)
          Performs this(i,j) = this(i.j) + x.
abstract  Matrix copy()
          Creates a copy of this matrix.
abstract  double get(java.lang.Object i, java.lang.Object j)
          Returns value at (i,j).
abstract  Index getIndex()
           
 double map(Vector v, java.lang.Object row)
           
 Vector map(Vector v, Vector ret)
          Performs ret := this*v, i.e.
 java.util.Iterator relevantIndices(java.lang.Object row)
          Returns Iterator, that traverses all indices of nonnull elements in the row row.
 int relevantIndicesNum(java.lang.Object row)
          Returns the number of nonnull elements in row row.
abstract  void set(java.lang.Object i, java.lang.Object j, double x)
          Sets value at (i,j) to x.
 Matrix transpose(Matrix ret)
          Performs ret := this^T, i.e.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Matrix

public Matrix()
Method Detail

getIndex

public abstract Index getIndex()

get

public abstract double get(java.lang.Object i,
                           java.lang.Object j)
Returns value at (i,j).

Parameters:
i - index of the row
j - index of the column
Returns:
value at (i,j)

set

public abstract void set(java.lang.Object i,
                         java.lang.Object j,
                         double x)
Sets value at (i,j) to x.

Parameters:
i - index of the row
j - index of the column
x - value to set at (i,j)

copy

public abstract Matrix copy()
Creates a copy of this matrix.

Returns:
a copy of this matrix

relevantIndices

public java.util.Iterator relevantIndices(java.lang.Object row)
Returns Iterator, that traverses all indices of nonnull elements in the row row.

Parameters:
row - the index of the row
Returns:
Iterator, that traverses all indices of nonnull elements in the row row

relevantIndicesNum

public int relevantIndicesNum(java.lang.Object row)
Returns the number of nonnull elements in row row.

Parameters:
row - the index of the row
Returns:
the number of nonnull elements in row row

map

public double map(Vector v,
                  java.lang.Object row)
Parameters:
v - the vector to map
row - index of the component we want to calculate
Returns:
scalar product of v and the row row.

map

public Vector map(Vector v,
                  Vector ret)
Performs ret := this*v, i.e. matrix-vector multiplication of this matrix and v, stored the result in ret, which will be returned.

Parameters:
v - the vector to map
ret - vector in which will be stored the result of the mapping.
Returns:
the matrix-vector multiplication of this matrix and v. ret will be returned

add

public void add(java.lang.Object i,
                java.lang.Object j,
                double x)
Performs this(i,j) = this(i.j) + x.

Parameters:
i - index of the row
j - index of the column
x - the value to add

transpose

public Matrix transpose(Matrix ret)
Performs ret := this^T, i.e. this transposed and stores the result in ret, which will be returned.

Parameters:
ret - temporary Matrix
Returns:
this transposed. ret will be returned