org.apache.commons.math.linear
Class OpenMapRealMatrix

java.lang.Object
  extended by org.apache.commons.math.linear.RealLinearOperator
      extended by org.apache.commons.math.linear.AbstractRealMatrix
          extended by org.apache.commons.math.linear.OpenMapRealMatrix
All Implemented Interfaces:
java.io.Serializable, AnyMatrix, RealMatrix, SparseRealMatrix

public class OpenMapRealMatrix
extends AbstractRealMatrix
implements SparseRealMatrix, java.io.Serializable

Sparse matrix implementation based on an open addressed map.

Since:
2.0
Version:
$Id: OpenMapRealMatrix.java 1181181 2011-10-10 19:56:03Z luc $
See Also:
Serialized Form

Constructor Summary
OpenMapRealMatrix(int rowDimension, int columnDimension)
          Build a sparse matrix with the supplied row and column dimensions.
OpenMapRealMatrix(OpenMapRealMatrix matrix)
          Build a matrix by copying another one.
 
Method Summary
 OpenMapRealMatrix add(OpenMapRealMatrix m)
          Compute the sum of this matrix and m.
 void addToEntry(int row, int column, double increment)
          Change an entry in the specified row and column.
 OpenMapRealMatrix copy()
          Returns a (deep) copy of this.
 OpenMapRealMatrix createMatrix(int rowDimension, int columnDimension)
          Create a new RealMatrix of the same type as the instance with the supplied row and column dimensions.
 int getColumnDimension()
          Returns the number of columns of this matrix.
 double getEntry(int row, int column)
          Get the entry in the specified row and column.
 int getRowDimension()
          Returns the number of rows of this matrix.
 OpenMapRealMatrix multiply(OpenMapRealMatrix m)
          Postmultiply this matrix by m.
 RealMatrix multiply(RealMatrix m)
          Returns the result of postmultiplying this by m.
 void multiplyEntry(int row, int column, double factor)
          Change an entry in the specified row and column.
 void setEntry(int row, int column, double value)
          Set the entry in the specified row and column.
 OpenMapRealMatrix subtract(OpenMapRealMatrix m)
          Subtract m from this matrix.
 OpenMapRealMatrix subtract(RealMatrix m)
          Compute this minus m.
 
Methods inherited from class org.apache.commons.math.linear.AbstractRealMatrix
add, copySubMatrix, copySubMatrix, equals, getColumn, getColumnMatrix, getColumnVector, getData, getFrobeniusNorm, getNorm, getRow, getRowMatrix, getRowVector, getSubMatrix, getSubMatrix, getTrace, hashCode, isSquare, operate, operate, power, preMultiply, preMultiply, preMultiply, scalarAdd, scalarMultiply, setColumn, setColumnMatrix, setColumnVector, setRow, setRowMatrix, setRowVector, setSubMatrix, toString, transpose, walkInColumnOrder, walkInColumnOrder, walkInColumnOrder, walkInColumnOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInRowOrder, walkInRowOrder, walkInRowOrder, walkInRowOrder
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.commons.math.linear.RealMatrix
add, copySubMatrix, copySubMatrix, getColumn, getColumnMatrix, getColumnVector, getData, getFrobeniusNorm, getNorm, getRow, getRowMatrix, getRowVector, getSubMatrix, getSubMatrix, getTrace, operate, operate, power, preMultiply, preMultiply, preMultiply, scalarAdd, scalarMultiply, setColumn, setColumnMatrix, setColumnVector, setRow, setRowMatrix, setRowVector, setSubMatrix, transpose, walkInColumnOrder, walkInColumnOrder, walkInColumnOrder, walkInColumnOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInRowOrder, walkInRowOrder, walkInRowOrder, walkInRowOrder
 
Methods inherited from interface org.apache.commons.math.linear.AnyMatrix
isSquare
 

Constructor Detail

OpenMapRealMatrix

public OpenMapRealMatrix(int rowDimension,
                         int columnDimension)
Build a sparse matrix with the supplied row and column dimensions.

Parameters:
rowDimension - Number of rows of the matrix.
columnDimension - Number of columns of the matrix.

OpenMapRealMatrix

public OpenMapRealMatrix(OpenMapRealMatrix matrix)
Build a matrix by copying another one.

Parameters:
matrix - matrix to copy.
Method Detail

copy

public OpenMapRealMatrix copy()
Returns a (deep) copy of this.

Specified by:
copy in interface RealMatrix
Specified by:
copy in class AbstractRealMatrix
Returns:
matrix copy

createMatrix

public OpenMapRealMatrix createMatrix(int rowDimension,
                                      int columnDimension)
Create a new RealMatrix of the same type as the instance with the supplied row and column dimensions.

Specified by:
createMatrix in interface RealMatrix
Specified by:
createMatrix in class AbstractRealMatrix
Parameters:
rowDimension - the number of rows in the new matrix
columnDimension - the number of columns in the new matrix
Returns:
a new matrix of the same type as the instance

getColumnDimension

public int getColumnDimension()
Returns the number of columns of this matrix.

Specified by:
getColumnDimension in interface AnyMatrix
Specified by:
getColumnDimension in class AbstractRealMatrix
Returns:
the number of columns.

add

public OpenMapRealMatrix add(OpenMapRealMatrix m)
Compute the sum of this matrix and m.

Parameters:
m - Matrix to be added.
Returns:
this + m.
Throws:
DimensionMismatchException - if m is not the same size as this matrix.

subtract

public OpenMapRealMatrix subtract(RealMatrix m)
Compute this minus m.

Specified by:
subtract in interface RealMatrix
Overrides:
subtract in class AbstractRealMatrix
Parameters:
m - matrix to be subtracted
Returns:
this - m

subtract

public OpenMapRealMatrix subtract(OpenMapRealMatrix m)
Subtract m from this matrix.

Parameters:
m - Matrix to be subtracted.
Returns:
this - m.
Throws:
DimensionMismatchException - if m is not the same size as this matrix.

multiply

public RealMatrix multiply(RealMatrix m)
Returns the result of postmultiplying this by m.

Specified by:
multiply in interface RealMatrix
Overrides:
multiply in class AbstractRealMatrix
Parameters:
m - matrix to postmultiply by
Returns:
this * m

multiply

public OpenMapRealMatrix multiply(OpenMapRealMatrix m)
Postmultiply this matrix by m.

Parameters:
m - Matrix to postmultiply by.
Returns:
this * m.
Throws:
MatrixDimensionMismatchException - if the number of rows of m differ from the number of columns of this matrix.

getEntry

public double getEntry(int row,
                       int column)
Get the entry in the specified row and column. Row and column indices start at 0.

Specified by:
getEntry in interface RealMatrix
Specified by:
getEntry in class AbstractRealMatrix
Parameters:
row - Row location of entry to be fetched.
column - Column location of entry to be fetched.
Returns:
the matrix entry at (row, column).

getRowDimension

public int getRowDimension()
Returns the number of rows of this matrix.

Specified by:
getRowDimension in interface AnyMatrix
Specified by:
getRowDimension in class AbstractRealMatrix
Returns:
the number of rows.

setEntry

public void setEntry(int row,
                     int column,
                     double value)
Set the entry in the specified row and column. Row and column indices start at 0.

Specified by:
setEntry in interface RealMatrix
Specified by:
setEntry in class AbstractRealMatrix
Parameters:
row - Row location of entry to be set.
column - Column location of entry to be set.
value - matrix entry to be set.

addToEntry

public void addToEntry(int row,
                       int column,
                       double increment)
Change an entry in the specified row and column. Row and column indices start at 0.

Specified by:
addToEntry in interface RealMatrix
Specified by:
addToEntry in class AbstractRealMatrix
Parameters:
row - Row location of entry to be set.
column - Column location of entry to be set.
increment - value to add to the matrix entry.

multiplyEntry

public void multiplyEntry(int row,
                          int column,
                          double factor)
Change an entry in the specified row and column. Row and column indices start at 0.

Specified by:
multiplyEntry in interface RealMatrix
Specified by:
multiplyEntry in class AbstractRealMatrix
Parameters:
row - Row location of entry to be set.
column - Column location of entry to be set.
factor - Multiplication factor for the matrix entry.


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.