Opus5
Class SparseMatrixAsArray

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

public class SparseMatrixAsArray
extends java.lang.Object
implements SparseMatrix

Sparse matrix implemented using arrays.

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

Field Summary
protected  int[][] columns
          The column numbers corresponding to the non-zero entries.
protected  int fill
          The maximum number of non-zero entries in any row of the sparse matrix.
protected  int numberOfColumns
          The number of columns.
protected  int numberOfRows
          The number of rows.
protected  double[][] values
          The non-zero matrix entries.
 
Fields inherited from interface Opus5.SparseMatrix
copyright
 
Constructor Summary
SparseMatrixAsArray(int numberOfRows, int numberOfColumns, int fill)
          Construct a SparseMatrixAsArray with the specified dimensions and row fill.
 
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

numberOfColumns

protected int numberOfColumns
The number of columns.

numberOfRows

protected int numberOfRows
The number of rows.

fill

protected int fill
The maximum number of non-zero entries in any row of the sparse matrix.

values

protected double[][] values
The non-zero matrix entries.

columns

protected int[][] columns
The column numbers corresponding to the non-zero entries.
Constructor Detail

SparseMatrixAsArray

public SparseMatrixAsArray(int numberOfRows,
                           int numberOfColumns,
                           int fill)
Construct a SparseMatrixAsArray with the specified dimensions and row fill.
Parameters:
numberOfRows - The number of rows.
numberOfColumns - The number of columns.
fill - The maximum number of non-zero entries in any row.
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. This method is not implemented.
Specified by:
transpose in interface Matrix
Returns:
The transpose of this matrix.
Throws:
MethodNotImplemented - Always.

times

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

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.