drasys.or.matrix
Class RowArrayMatrix

java.lang.Object
  |
  +--drasys.or.matrix.RealContainer
        |
        +--drasys.or.matrix.Matrix
              |
              +--drasys.or.matrix.ArrayMatrix
                    |
                    +--drasys.or.matrix.RowArrayMatrix

public class RowArrayMatrix
extends ArrayMatrix

A dense row-major matrix of double values where each row is an array. The elements are held in a java two-dimensional array, each array row holds a row of the matrix. The elements in a row can be either all null or all non-null. This matrix is efficient for row-wise expansion and row-wise numerical computations.

References:

Matrix Computations (Johns Hopkins Studies in the Mathematical Sciences)
    Gene H. Golub, Charles F. Van Loan (Contributor) / Paperback / Published 1996
Numerical Recipes in C : The Art of Scientific Computing
    William H. Press, et al / Hardcover / Published 1993
Parallel Algorithms for Matrix Computations
    K.A. Gallivan / Paperback / Published 1990

See Also:
Serialized Form

Fields inherited from class drasys.or.matrix.RealContainer
_epsilon, _globalEpsilon
 
Constructor Summary
RowArrayMatrix(double[][] array)
          Constructs a dense matrix and copy the contents from 'array'.
RowArrayMatrix(double[][] array, boolean useArrayInternally)
          Constructs a dense matrix from 'array'.
RowArrayMatrix(int sizeOfRows, int sizeOfColumns)
          Constructs a dense matrix with an explicit size.
RowArrayMatrix(int sizeOfRows, int sizeOfColumns, int capacityOfRows, int capacityOfColumns)
          Constructs a dense matrix with an explicit size and capacity.
RowArrayMatrix(MatrixI matrix)
          Constructs a sparse matrix the same size as 'matrix'.
RowArrayMatrix(VectorI vector)
          Constructs a square matrix with the 'vector' as the diagonal.
 
Method Summary
 void addColumn(VectorI vector)
          Adds a new column and any non-null elements in vector to the end of the matrix .
 void addRow(VectorI vector)
          Adds a new row and any non-null elements in vector to the end of the matrix .
 int capacityOfColumns()
          Returns the number of columns the matrix can hold without reallocating memory.
 int capacityOfRows()
          Returns the number of rows the matrix can hold without reallocating memory.
 java.util.Enumeration columnElements(int column)
          Returns an enumeration of the non-null elements in a column.
 double elementAt(int row, int column)
          Gets an element's value from the matrix.
 java.util.Enumeration elements()
          Returns an enumeration of the non-null elements in the matrix.
 double[][] getArray()
          Returns a new two-dimensional array containing the values in matrix.
 boolean isColumnMajor()
          Always returns false.
 boolean isNull(int row, int column)
          Returns true if an element has no value associated with it.
 boolean isRowMajor()
          Always returns true.
 java.util.Enumeration rowElements(int row)
          Returns an enumeration of the non-null elements in a row.
 void setCapacity(int capacityOfRows, int capacityOfColumns)
          Ensures the matrix has enough memory to expand to this size without reallocation.
 void setElementAt(int row, int column, double value)
          Sets an element's value in the matrix.
 void setSize(int sizeOfRows, int sizeOfColumns)
          Sets the number of rows and columns in the matrix.
 int sizeOfElements()
          Returns the number of non-null elements in the matrix.
 double sum(int rowBegin, int rowEnd, int columnBegin, int columnEnd)
          Returns the sum of all of the elements in the sub-matrix.
Computes sum(a[i][j]).
Where: i = {rowBegin,...,(rowEnd-1)}
j = {columBegin,...,(columnEnd-1)}
 double sumOfSquaredDifferences(int rowBegin, int rowEnd, int columnBegin, int columnEnd, double scaler)
          Returns the sum of the squared differences between the elements and a scaler.
Computes sum((a[i][j]-scaler)^2).
Where: i = {rowBegin,...,(rowEnd-1)}
j = {columBegin,...,(columnEnd-1)}
 double sumOfSquares(int rowBegin, int rowEnd, int columnBegin, int columnEnd)
          Returns the sum of the squares of all of the elements in the sub-matrix.
Computes sum(a[i][j]^2).
Where: i = {rowBegin,...,(rowEnd-1)}
j = {columBegin,...,(columnEnd-1)}
 
Methods inherited from class drasys.or.matrix.ArrayMatrix
getValueArray, setElements, sizeOfColumns, sizeOfRows
 
Methods inherited from class drasys.or.matrix.Matrix
equals, equals, setColumn, setDiagonal, setElements, setRow, sum, sum, sumOfSquaredDifferences, sumOfSquaredDifferences, sumOfSquares, sumOfSquares, toString
 
Methods inherited from class drasys.or.matrix.RealContainer
equals, getEpsilon, getGlobalEpsilon, setEpsilon, setGlobalEpsilon
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RowArrayMatrix

public RowArrayMatrix(int sizeOfRows,
                      int sizeOfColumns)
Constructs a dense matrix with an explicit size.

RowArrayMatrix

public RowArrayMatrix(int sizeOfRows,
                      int sizeOfColumns,
                      int capacityOfRows,
                      int capacityOfColumns)
Constructs a dense matrix with an explicit size and capacity.

RowArrayMatrix

public RowArrayMatrix(VectorI vector)
Constructs a square matrix with the 'vector' as the diagonal. If 'vector' is sparse, the null elements will be zero int the diagonal.

RowArrayMatrix

public RowArrayMatrix(MatrixI matrix)
Constructs a sparse matrix the same size as 'matrix'. Any null elements will be zero in the new matrix.

RowArrayMatrix

public RowArrayMatrix(double[][] array)
Constructs a dense matrix and copy the contents from 'array'. Any elements in a null row or beyond the end of a short row will be set to zero.

RowArrayMatrix

public RowArrayMatrix(double[][] array,
                      boolean useArrayInternally)
Constructs a dense matrix from 'array'. If 'useArrayInternally' is true 'array' will be used as the internal value array.
Method Detail

sizeOfElements

public int sizeOfElements()
Returns the number of non-null elements in the matrix.

isRowMajor

public boolean isRowMajor()
Always returns true.

isColumnMajor

public boolean isColumnMajor()
Always returns false.

capacityOfRows

public int capacityOfRows()
Returns the number of rows the matrix can hold without reallocating memory.

capacityOfColumns

public int capacityOfColumns()
Returns the number of columns the matrix can hold without reallocating memory.

addRow

public void addRow(VectorI vector)
Adds a new row and any non-null elements in vector to the end of the matrix . If 'vector' is null then no new elements will be modified in the new row.

addColumn

public void addColumn(VectorI vector)
Adds a new column and any non-null elements in vector to the end of the matrix . If 'vector' is null then no new elements will be changed in the new column.

setSize

public void setSize(int sizeOfRows,
                    int sizeOfColumns)
Sets the number of rows and columns in the matrix.

setCapacity

public void setCapacity(int capacityOfRows,
                        int capacityOfColumns)
Ensures the matrix has enough memory to expand to this size without reallocation.

setElementAt

public void setElementAt(int row,
                         int column,
                         double value)
Sets an element's value in the matrix.

isNull

public boolean isNull(int row,
                      int column)
Returns true if an element has no value associated with it. Elements which have no value assigned return 0.0 when accessed.
Overrides:
isNull in class ArrayMatrix

elementAt

public double elementAt(int row,
                        int column)
Gets an element's value from the matrix.
Tags copied from interface: MatrixI
Returns:
zero is the element is null

getArray

public double[][] getArray()
Returns a new two-dimensional array containing the values in matrix. The rows of the array hold the rows of the matrix.
Overrides:
getArray in class ArrayMatrix

rowElements

public java.util.Enumeration rowElements(int row)
Returns an enumeration of the non-null elements in a row. The elements are enumerated in random order.
Overrides:
rowElements in class Matrix
Returns:
an enumeration whose elements are of type MatrixElementI

columnElements

public java.util.Enumeration columnElements(int column)
Returns an enumeration of the non-null elements in a column. The elements are enumerated in random order.
Overrides:
columnElements in class Matrix
Returns:
an enumeration whose elements are of type MatrixElementI

elements

public java.util.Enumeration elements()
Returns an enumeration of the non-null elements in the matrix. The elements are enumerated in random order.
Overrides:
elements in class Matrix
Returns:
an enumeration whose elements are of type MatrixElementI

sum

public double sum(int rowBegin,
                  int rowEnd,
                  int columnBegin,
                  int columnEnd)
Returns the sum of all of the elements in the sub-matrix.
Computes sum(a[i][j]).
Where: i = {rowBegin,...,(rowEnd-1)}
j = {columBegin,...,(columnEnd-1)}
Overrides:
sum in class Matrix

sumOfSquares

public double sumOfSquares(int rowBegin,
                           int rowEnd,
                           int columnBegin,
                           int columnEnd)
Returns the sum of the squares of all of the elements in the sub-matrix.
Computes sum(a[i][j]^2).
Where: i = {rowBegin,...,(rowEnd-1)}
j = {columBegin,...,(columnEnd-1)}
Overrides:
sumOfSquares in class Matrix

sumOfSquaredDifferences

public double sumOfSquaredDifferences(int rowBegin,
                                      int rowEnd,
                                      int columnBegin,
                                      int columnEnd,
                                      double scaler)
Returns the sum of the squared differences between the elements and a scaler.
Computes sum((a[i][j]-scaler)^2).
Where: i = {rowBegin,...,(rowEnd-1)}
j = {columBegin,...,(columnEnd-1)}
Overrides:
sumOfSquaredDifferences in class Matrix


Copyright(C)1997-2000 by DRA Systems all rights reserved. OpsResearch.com