uchicago.src.collection
Class DoubleMatrix

java.lang.Object
  extended by uchicago.src.collection.DoubleMatrix
All Implemented Interfaces:
BaseMatrix

public class DoubleMatrix
extends java.lang.Object
implements BaseMatrix

DoubleMatrix: a matrix of doubles (and any other number).

Version:
1.0 6/29/99
Author:
Nick Collier

Constructor Summary
DoubleMatrix(int sizeX, int sizeY)
          Constructs a matrix of the specified size, initializing the matrix cells to 0.
DoubleMatrix(int sizeX, int sizeY, double[] matrix)
          Constructs a matrix of the specified size, initializing the matrix cells to the values in matrix.
 
Method Summary
 DoubleMatrix copyMatrix()
          Copies a Double Matrix
 void copyMatrixTo(DoubleMatrix dm)
          Copies the double[] in this Matrix to the specified DoubleMatrix.
 java.lang.Object get(int index)
           
 java.lang.Object get(int col, int row)
           
 double[] getData()
           
 double getDoubleAt(int x, int y)
          Returns a double at (x,y)
 int getNumCols()
           
 int getNumRows()
           
 int getSizeX()
          The x dimension of this Matrix
 int getSizeY()
          The y dimension of this Matrix
 void initialize(double value)
          Fills the matrix with the passed in value
 void printToFile(java.lang.String fileName)
           
 void put(int col, int row, java.lang.Object obj)
           
 void put(int index, java.lang.Object obj)
           
 void putDoubleAt(int x, int y, double value)
           
 java.lang.Object remove(int index)
           
 java.lang.Object remove(int col, int row)
           
 double removeDouble(int col, int row)
          Removes the value and the specified column and row, leaving 0 in in its place.
 int size()
           
 void trim()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DoubleMatrix

public DoubleMatrix(int sizeX,
                    int sizeY)
Constructs a matrix of the specified size, initializing the matrix cells to 0. (This doesn't apprear to be correct actually, it just creates the array.)

Parameters:
sizeX -
sizeY -

DoubleMatrix

public DoubleMatrix(int sizeX,
                    int sizeY,
                    double[] matrix)
Constructs a matrix of the specified size, initializing the matrix cells to the values in matrix. This constructor produces a copy of double[] matrix internally.

Parameters:
sizeX -
sizeY -
matrix -
Method Detail

getDoubleAt

public double getDoubleAt(int x,
                          int y)
Returns a double at (x,y)

Parameters:
x -
y -
Returns:

putDoubleAt

public void putDoubleAt(int x,
                        int y,
                        double value)
Parameters:
x -
y -
value -

copyMatrix

public DoubleMatrix copyMatrix()
Copies a Double Matrix

Returns:
a new DoubleMatrix which is a "deep" copy of this matrix.

copyMatrixTo

public void copyMatrixTo(DoubleMatrix dm)
Copies the double[] in this Matrix to the specified DoubleMatrix.

Parameters:
dm - the matrix to copy

getSizeX

public int getSizeX()
The x dimension of this Matrix

Returns:
x dimension

getSizeY

public int getSizeY()
The y dimension of this Matrix

Returns:
y dimension

initialize

public void initialize(double value)
Fills the matrix with the passed in value

Parameters:
value - the value to fill the matrix with.

get

public java.lang.Object get(int index)
Parameters:
index -
Returns:

get

public java.lang.Object get(int col,
                            int row)
Specified by:
get in interface BaseMatrix

put

public void put(int index,
                java.lang.Object obj)

put

public void put(int col,
                int row,
                java.lang.Object obj)
Specified by:
put in interface BaseMatrix

remove

public java.lang.Object remove(int col,
                               int row)
Specified by:
remove in interface BaseMatrix

remove

public java.lang.Object remove(int index)

removeDouble

public double removeDouble(int col,
                           int row)
Removes the value and the specified column and row, leaving 0 in in its place.

Parameters:
col -
row -
Returns:

size

public int size()
Specified by:
size in interface BaseMatrix

getNumRows

public int getNumRows()
Specified by:
getNumRows in interface BaseMatrix

getNumCols

public int getNumCols()
Specified by:
getNumCols in interface BaseMatrix

getData

public double[] getData()

trim

public void trim()
Specified by:
trim in interface BaseMatrix

printToFile

public void printToFile(java.lang.String fileName)
Parameters:
fileName -