org.apache.commons.math.linear
Interface RealMatrix

All Known Implementing Classes:
RealMatrixImpl

public interface RealMatrix

Interface defining a real-valued matrix with basic algebraic operations

Version:
$Revision: 1.7 $ $Date: 2003/11/14 22:22:19 $

Method Summary
 RealMatrix add(RealMatrix m)
          Compute the sum of this and m.
 RealMatrix copy()
          Returns a (deep) copy of this.
 double[] getColumn(int col)
          Returns the entries in column number col as an array.
 int getColumnDimension()
          Returns the number of columns in the matrix.
 double[][] getData()
          Returns matrix entries as a two-dimensional array.
 double getDeterminant()
          Returns the determinant of this matrix.
 double getEntry(int row, int column)
          Returns the entry in the specified row and column.
 double getNorm()
          Returns the maximum absolute row sum norm of the matrix.
 int getRank()
          Returns the rank of the matrix.
 double[] getRow(int row)
          Returns the entries in row number row as an array.
 int getRowDimension()
          Returns the number of rows in the matrix.
 double getTrace()
          Returns the trace of the matrix (the sum of the elements on the main diagonal).
 RealMatrix inverse()
          Returns the inverse of this matrix.
 boolean isSingular()
          Is this a singular matrix?
 boolean isSquare()
          Is this a square matrix?
 RealMatrix multiply(RealMatrix m)
          Returns the result postmultiplying this by m.
 double[] operate(double[] v)
          Returns the result of multiplying this by the vector v.
 RealMatrix preMultiply(double[] v)
          Returns the result of premultiplying this by the vector v.
 RealMatrix scalarAdd(double d)
          Returns the result of adding d to each entry of this.
 RealMatrix scalarMultiply(double d)
          Returns the result multiplying each entry of this by d.
 void setData(double[][] data)
          Overwrites the underlying data for the matrix with a fresh copy of data.
 void setEntry(int row, int column, double value)
          Sets the entry in the specified row and column to the specified value.
 double[] solve(double[] b)
          Returns the solution vector for a linear system with coefficient matrix = this and constant vector = b.
 RealMatrix solve(RealMatrix b)
          Returns a matrix of (column) solution vectors for linear systems with coefficient matrix = this and constant vectors = columns of b.
 RealMatrix subtract(RealMatrix m)
          Compute this minus m.
 RealMatrix transpose()
          Returns the transpose of this matrix.
 

Method Detail

copy

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

Returns:
matrix copy

add

public RealMatrix add(RealMatrix m)
               throws IllegalArgumentException
Compute the sum of this and m.

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

subtract

public RealMatrix subtract(RealMatrix m)
                    throws IllegalArgumentException
Compute this minus m.

Parameters:
m - matrix to be subtracted
Returns:
this + m
Throws:
IllegalArgumentException - if m is not the same size as this

getRank

public int getRank()
Returns the rank of the matrix.

Returns:
the rank of this matrix

scalarAdd

public RealMatrix scalarAdd(double d)
Returns the result of adding d to each entry of this.

Parameters:
d - value to be added to each entry
Returns:
d + this

scalarMultiply

public RealMatrix scalarMultiply(double d)
Returns the result multiplying each entry of this by d.

Parameters:
d - value to multiply all entries by
Returns:
d * this

multiply

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

Parameters:
m - matrix to postmultiply by
Returns:
this * m
Throws:
IllegalArgumentException - if columnDimension(this) != rowDimension(m)

getData

public double[][] getData()
Returns matrix entries as a two-dimensional array.

Returns:
2-dimensional array of entries

setData

public void setData(double[][] data)
Overwrites the underlying data for the matrix with a fresh copy of data.

Parameters:
data - 2-dimensional array of entries

getNorm

public double getNorm()
Returns the maximum absolute row sum norm of the matrix.

Returns:
norm

getRow

public double[] getRow(int row)
                throws IllegalArgumentException
Returns the entries in row number row as an array.

Parameters:
row - the row to be fetched
Returns:
array of entries in the row
Throws:
IllegalArgumentException - if row > rowDimension

getColumn

public double[] getColumn(int col)
                   throws IllegalArgumentException
Returns the entries in column number col as an array.

Parameters:
col - column to fetch
Returns:
array of entries in the column
Throws:
IllegalArgumentException - if column > columnDimension

getEntry

public double getEntry(int row,
                       int column)
                throws IllegalArgumentException
Returns the entry in the specified row and column.

Parameters:
row - row location of entry to be fetched
column - column location of entry to be fetched
Returns:
matrix entry in row,column
Throws:
IllegalArgumentException - if entry does not exist

setEntry

public void setEntry(int row,
                     int column,
                     double value)
              throws IllegalArgumentException
Sets the entry in the specified row and column to the specified value.

Parameters:
row - row location of entry to be set
column - column location of entry to be set
value - value to set
Throws:
IllegalArgumentException - if entry does not exist

transpose

public RealMatrix transpose()
Returns the transpose of this matrix.

Returns:
transpose matrix

inverse

public RealMatrix inverse()
                   throws IllegalArgumentException
Returns the inverse of this matrix.

Returns:
inverse matrix
Throws:
IllegalArgumentException - if *this is not invertible

getDeterminant

public double getDeterminant()
Returns the determinant of this matrix.

Returns:
determinant

isSquare

public boolean isSquare()
Is this a square matrix?

Returns:
true if the matrix is square (rowDimension = columnDimension)

isSingular

public boolean isSingular()
Is this a singular matrix?

Returns:
true if the matrix is singular

getRowDimension

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

Returns:
rowDimension

getColumnDimension

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

Returns:
columnDimension

getTrace

public double getTrace()
Returns the trace of the matrix (the sum of the elements on the main diagonal).

Returns:
trace

operate

public double[] operate(double[] v)
                 throws IllegalArgumentException
Returns the result of multiplying this by the vector v.

Parameters:
v - the vector to operate on
Returns:
this*v
Throws:
IllegalArgumentException - if columnDimension != v.size()

preMultiply

public RealMatrix preMultiply(double[] v)
                       throws IllegalArgumentException
Returns the result of premultiplying this by the vector v.

Parameters:
v - the row vector to premultiply by
Returns:
v*this
Throws:
IllegalArgumentException - if rowDimension != v.size()

solve

public double[] solve(double[] b)
               throws IllegalArgumentException
Returns the solution vector for a linear system with coefficient matrix = this and constant vector = b.

Parameters:
b - constant vector
Returns:
vector of solution values to AX = b, where A is *this
Throws:
IllegalArgumentException - if rowDimension != b.length or matrix is singular

solve

public RealMatrix solve(RealMatrix b)
                 throws IllegalArgumentException
Returns a matrix of (column) solution vectors for linear systems with coefficient matrix = this and constant vectors = columns of b.

Parameters:
b - matrix of constant vectors forming RHS of linear systems to to solve
Returns:
matrix of solution vectors
Throws:
IllegalArgumentException - if rowDimension != row dimension of b or this is not square or singular


Copyright © 2003-2004 Apache Software Foundation. All Rights Reserved.