sim.util.mantissa.linalg
Class GeneralMatrix

java.lang.Object
  extended by sim.util.mantissa.linalg.Matrix
      extended by sim.util.mantissa.linalg.GeneralMatrix
All Implemented Interfaces:
java.io.Serializable

public class GeneralMatrix
extends Matrix
implements java.io.Serializable

This class represents matrices of the most general type.

This class is the basic implementation of matrices to use when nothing special is known about the structure of the matrix.

This file is from the "Mantissa" Java software package found at http://www.spaceroots.org/software/mantissa/index.html. The license is included at the end of the source file.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class sim.util.mantissa.linalg.Matrix
columns, data, rows
 
Constructor Summary
GeneralMatrix(int rows, int columns)
          Simple constructor.
GeneralMatrix(int rows, int columns, double[] data)
          Simple constructor.
GeneralMatrix(Matrix m)
          Copy constructor.
 
Method Summary
 Matrix duplicate()
          Polymorphic copy operator.
protected  sim.util.mantissa.linalg.NonNullRange getRangeForColumn(int j)
          Set a range to the non null part covered by a column.
protected  sim.util.mantissa.linalg.NonNullRange getRangeForRow(int i)
          Set a range to the non null part covered by a row.
 void selfAdd(Matrix m)
          Add a matrix to the instance.
 void selfSub(Matrix m)
          Substract a matrix from the instance.
 
Methods inherited from class sim.util.mantissa.linalg.Matrix
add, getColumns, getElement, getRows, getTranspose, mul, mul, selfMul, setElement, sub, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GeneralMatrix

public GeneralMatrix(int rows,
                     int columns)
Simple constructor. Build a matrix with null elements.

Parameters:
rows - number of rows of the matrix
columns - number of columns of the matrix

GeneralMatrix

public GeneralMatrix(int rows,
                     int columns,
                     double[] data)
Simple constructor. Build a matrix with specified elements.

Parameters:
rows - number of rows of the matrix
columns - number of columns of the matrix
data - table of the matrix elements (stored row after row)

GeneralMatrix

public GeneralMatrix(Matrix m)
Copy constructor.

Parameters:
m - matrix to copy
Method Detail

duplicate

public Matrix duplicate()
Description copied from class: Matrix
Polymorphic copy operator. This method build a new object of the same type of the instance. It is somewhat similar to the Object.clone() method, except that it has public access, it doesn't throw any specific exception and it returns a Matrix.

Specified by:
duplicate in class Matrix
See Also:
Object.clone()

selfAdd

public void selfAdd(Matrix m)
Add a matrix to the instance. This method adds a matrix to the instance. It does modify the instance.

Parameters:
m - matrix to add
Throws:
java.lang.IllegalArgumentException - if there is a dimension mismatch

selfSub

public void selfSub(Matrix m)
Substract a matrix from the instance. This method substracts a matrix from the instance. It does modify the instance.

Parameters:
m - matrix to substract
Throws:
java.lang.IllegalArgumentException - if there is a dimension mismatch

getRangeForRow

protected sim.util.mantissa.linalg.NonNullRange getRangeForRow(int i)
Description copied from class: Matrix
Set a range to the non null part covered by a row.

Specified by:
getRangeForRow in class Matrix
Parameters:
i - index of the row
Returns:
range of non nul elements in the specified row
See Also:
Matrix.getRangeForColumn(int)

getRangeForColumn

protected sim.util.mantissa.linalg.NonNullRange getRangeForColumn(int j)
Description copied from class: Matrix
Set a range to the non null part covered by a column.

Specified by:
getRangeForColumn in class Matrix
Parameters:
j - index of the column
Returns:
range of non nul elements in the specified column
See Also:
Matrix.getRangeForRow(int)