Opus5
Class SparseMatrixAsVector

java.lang.Object
  |
  +--Opus5.SparseMatrixAsVector
All Implemented Interfaces:
Matrix, SparseMatrix

public class SparseMatrixAsVector
extends java.lang.Object
implements SparseMatrix

Sparse matrix implemented using a vector of triples.

Version:
$Id: SparseMatrixAsVector.java,v 3.2 1998/07/28 03:02:23 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.

Field Summary
protected  Opus5.SparseMatrixAsVector.Entry[] array
          An array of triples (entries).
protected  int numberOfColumns
          The number of columns.
protected  int numberOfElements
          The maximum number of non-zero elements in this matrix.
protected  int numberOfRows
          The number of rows.
 
Fields inherited from interface Opus5.SparseMatrix
copyright
 
Constructor Summary
SparseMatrixAsVector(int numberOfRows, int numberOfColumns, int numberOfElements)
          Construct a SparseMatrixAsVector with the specified dimensions and maximum number of non-zero elements.
 
Method Summary
protected  int findPosition(int i, int j)
          Finds the position of the (i,j)th matrix entry.
 double get(int i, int j)
          Returns the value in this matrix at the specified position.
 Matrix plus(Matrix mat)
          Returns the sum of this matrix and the specified matrix.
 void put(int i, int j, double datum)
          Stores the specified value in this matrix at the specified position.
 void putZero(int i, int j)
          Stores a zero in this matrix at the specified position.
 Matrix times(Matrix mat)
          Returns the product of this matrix and the specified matrix.
 Matrix transpose()
          Returns the transpose of this matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numberOfRows

protected int numberOfRows
The number of rows.

numberOfColumns

protected int numberOfColumns
The number of columns.

numberOfElements

protected int numberOfElements
The maximum number of non-zero elements in this matrix.

array

protected Opus5.SparseMatrixAsVector.Entry[] array
An array of triples (entries).
Constructor Detail

SparseMatrixAsVector

public SparseMatrixAsVector(int numberOfRows,
                            int numberOfColumns,
                            int numberOfElements)
Construct a SparseMatrixAsVector with the specified dimensions and maximum number of non-zero elements.
Parameters:
numberOfRows - The number of rows.
numberOfColumns - The number of columns.
numberOfElements - The maximum number of non-zero elements in this matrix.
Method Detail

findPosition

protected int findPosition(int i,
                           int j)
Finds the position of the (i,j)th matrix entry.
Parameters:
i - The row number.
j - The column number.
Returns:
The position of the (i,j)th matrix entry; -1 if the matrix entry is zero.

get

public double get(int i,
                  int j)
Returns the value in this matrix at the specified position.
Specified by:
get in interface Matrix
Parameters:
i - The row number.
j - The column number.
Returns:
The value in this matrix at the specified position.

put

public void put(int i,
                int j,
                double datum)
Stores the specified value in this matrix at the specified position.
Specified by:
put in interface Matrix
Parameters:
i - The row number.
j - The column number.
datum - The value to be stored.

putZero

public void putZero(int i,
                    int j)
Stores a zero in this matrix at the specified position.
Specified by:
putZero in interface SparseMatrix
Parameters:
i - The row number.
j - The column number.

transpose

public Matrix transpose()
Returns the transpose of this matrix.
Specified by:
transpose in interface Matrix
Returns:
The transpose of this matrix.

times

public Matrix times(Matrix mat)
Returns the product of this matrix and the specified matrix.
Specified by:
times in interface Matrix
Parameters:
The - specified matrix.
Returns:
The product of this matrix and the specified matrix

plus

public Matrix plus(Matrix mat)
Returns the sum of this matrix and the specified matrix. This method is not implemented.
Specified by:
plus in interface Matrix
Parameters:
The - specified matrix.
Returns:
The sum of this matrix and the specified matrix
Throws:
MethodNotImplemented - Always.