Top Description Methods
org.apache.commons.math3.linear

public Interface RealMatrix

extends AnyMatrix
Known Direct Subinterfaces
org.apache.commons.math3.linear.SparseRealMatrix
Known Direct Implementers
org.apache.commons.math3.linear.AbstractRealMatrix
Imports
org.apache.commons.math3.exception.DimensionMismatchException, .NoDataException, .NotPositiveException, .NotStrictlyPositiveException, .NullArgumentException, .NumberIsTooSmallException, .OutOfRangeException

Interface defining a real-valued matrix with basic algebraic operations.

Matrix element indexing is 0-based -- e.g., getEntry(0, 0) returns the element in the first row, first column of the matrix.

Method Summary

Modifier and TypeMethod and Description
public RealMatrix

Returns:

this + m
add
(RealMatrix
matrix to be added
m
)

Returns the sum of this and m.

public void
addToEntry(int
Row index of the entry to be modified.
row
,
int
Column index of the entry to be modified.
column
,
double
value to add to the matrix entry.
increment
)

Adds (in place) the specified value to the specified entry of this matrix.

public RealMatrix

Returns:

matrix copy
copy
()

Returns a (deep) copy of this.

public void
copySubMatrix(int
Initial row index
startRow
,
int
Final row index (inclusive)
endRow
,
int
Initial column index
startColumn
,
int
Final column index (inclusive)
endColumn
,
double[][]
The arrays where the submatrix data should be copied (if larger than rows/columns counts, only the upper-left part will be used)
destination
)

Copy a submatrix.

public void
copySubMatrix(int[]
Array of row indices.
selectedRows
,
int[]
Array of column indices.
selectedColumns
,
double[][]
The arrays where the submatrix data should be copied (if larger than rows/columns counts, only the upper-left part will be used)
destination
)

Copy a submatrix.

public RealMatrix

Returns:

a new matrix of the same type as the instance
createMatrix
(int
the number of rows in the new matrix
rowDimension
,
int
the number of columns in the new matrix
columnDimension
)

Create a new RealMatrix of the same type as the instance with the supplied row and column dimensions.

public double[]

Returns:

the array of entries in the column.
getColumn
(int
Column to be fetched.
column
)

Get the entries at the given column index as an array.

public RealMatrix

Returns:

column Matrix.
getColumnMatrix
(int
Column to be fetched.
column
)

Get the entries at the given column index as a column matrix.

public RealVector

Returns:

a column vector.
getColumnVector
(int
Column to be fetched.
column
)

Get the entries at the given column index as a vector.

public double[][]

Returns:

2-dimensional array of entries
getData
()

Returns matrix entries as a two-dimensional array.

public double

Returns:

the matrix entry at (row, column).
getEntry
(int
Row index of entry to be fetched.
row
,
int
Column index of entry to be fetched.
column
)

Get the entry in the specified row and column.

public double

Returns:

norm
getFrobeniusNorm
()

Returns the Frobenius norm of the matrix.

public double

Returns:

norm
getNorm
()

Returns the maximum absolute row sum norm of the matrix.

public double[]

Returns:

the array of entries in the row.
getRow
(int
Row to be fetched.
row
)

Get the entries at the given row index.

public RealMatrix

Returns:

row Matrix.
getRowMatrix
(int
Row to be fetched.
row
)

Get the entries at the given row index as a row matrix.

public RealVector

Returns:

a row vector.
getRowVector
(int
Row to be fetched.
row
)

Returns the entries in row number row as a vector.

public RealMatrix

Returns:

The subMatrix containing the data of the specified rows and columns.
getSubMatrix
(int
Initial row index
startRow
,
int
Final row index (inclusive)
endRow
,
int
Initial column index
startColumn
,
int
Final column index (inclusive)
endColumn
)

Gets a submatrix.

public RealMatrix

Returns:

The subMatrix containing the data in the specified rows and columns
getSubMatrix
(int[]
Array of row indices.
selectedRows
,
int[]
Array of column indices.
selectedColumns
)

Gets a submatrix.

public double

Returns:

the trace.
getTrace
()

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

public RealMatrix

Returns:

this * m
multiply
(RealMatrix
matrix to postmultiply by
m
)

Returns the result of postmultiplying this by m.

public void
multiplyEntry(int
Row index of the entry to be modified.
row
,
int
Column index of the entry to be modified.
column
,
double
Multiplication factor for the matrix entry.
factor
)

Multiplies (in place) the specified entry of this matrix by the specified value.

public double[]

Returns:

this * v
operate
(double[]
the vector to operate on
v
)

Returns the result of multiplying this by the vector v.

public RealVector

Returns:

this * v
operate
(RealVector
the vector to operate on
v
)

Returns the result of multiplying this by the vector v.

public RealMatrix

Returns:

this^p
power
(final int
raise this to power p
p
)

Returns the result of multiplying this with itself p times.

public RealMatrix

Returns:

m * this
preMultiply
(RealMatrix
matrix to premultiply by
m
)

Returns the result of premultiplying this by m.

public double[]

Returns:

v * this
preMultiply
(double[]
the row vector to premultiply by
v
)

Returns the (row) vector result of premultiplying this by the vector v.

public RealVector

Returns:

v * this
preMultiply
(RealVector
the row vector to premultiply by
v
)

Returns the (row) vector result of premultiplying this by the vector v.

public RealMatrix

Returns:

d + this
scalarAdd
(double
value to be added to each entry
d
)

Returns the result of adding d to each entry of this.

public RealMatrix

Returns:

d * this
scalarMultiply
(double
value to multiply all entries by
d
)

Returns the result of multiplying each entry of this by d.

public void
setColumn(int
Column to be set.
column
,
double[]
Column array to be copied (must have the same number of rows as the instance).
array
)

Sets the specified column of this matrix to the entries of the specified array.

public void
setColumnMatrix(int
Column to be set.
column
,
RealMatrix
Column matrix to be copied (must have one column and the same number of rows as the instance).
matrix
)

Sets the specified column of this matrix to the entries of the specified column matrix.

public void
setColumnVector(int
Column to be set.
column
,
RealVector
column vector to be copied (must have the same number of rows as the instance).
vector
)

Sets the specified column of this matrix to the entries of the specified vector.

public void
setEntry(int
Row index of entry to be set.
row
,
int
Column index of entry to be set.
column
,
double
the new value of the entry.
value
)

Set the entry in the specified row and column.

public void
setRow(int
Row to be set.
row
,
double[]
Row matrix to be copied (must have the same number of columns as the instance)
array
)

Sets the specified row of this matrix to the entries of the specified array.

public void
setRowMatrix(int
Row to be set.
row
,
RealMatrix
Row matrix to be copied (must have one row and the same number of columns as the instance).
matrix
)

Sets the specified row of this matrix to the entries of the specified row matrix.

public void
setRowVector(int
Row to be set.
row
,
RealVector
row vector to be copied (must have the same number of column as the instance).
vector
)

Sets the specified row of this matrix to the entries of the specified vector.

public void
setSubMatrix(double[][]
array containing the submatrix replacement data
subMatrix
,
int
row coordinate of the top, left element to be replaced
row
,
int
column coordinate of the top, left element to be replaced
column
)

Replace the submatrix starting at row, column using data in the input subMatrix array.

public RealMatrix

Returns:

this - m
subtract
(RealMatrix
matrix to be subtracted
m
)

Returns this minus m.

public RealMatrix

Returns:

transpose matrix
transpose
()

Returns the transpose of this matrix.

public double

Returns:

the value returned by RealMatrixChangingVisitor#end() at the end of the walk
walkInColumnOrder
(RealMatrixChangingVisitor
visitor used to process all matrix entries
visitor
)

Visit (and possibly change) all matrix entries in column order.

public double

Returns:

the value returned by RealMatrixPreservingVisitor#end() at the end of the walk
walkInColumnOrder
(RealMatrixPreservingVisitor
visitor used to process all matrix entries
visitor
)

Visit (but don't change) all matrix entries in column order.

public double

Returns:

the value returned by RealMatrixChangingVisitor#end() at the end of the walk
walkInColumnOrder
(RealMatrixChangingVisitor
visitor used to process all matrix entries
visitor
,
int
Initial row index
startRow
,
int
Final row index (inclusive)
endRow
,
int
Initial column index
startColumn
,
int
Final column index
endColumn
)

Visit (and possibly change) some matrix entries in column order.

public double

Returns:

the value returned by RealMatrixPreservingVisitor#end() at the end of the walk
walkInColumnOrder
(RealMatrixPreservingVisitor
visitor used to process all matrix entries
visitor
,
int
Initial row index
startRow
,
int
Final row index (inclusive)
endRow
,
int
Initial column index
startColumn
,
int
Final column index
endColumn
)

Visit (but don't change) some matrix entries in column order.

public double

Returns:

the value returned by RealMatrixChangingVisitor#end() at the end of the walk
walkInOptimizedOrder
(RealMatrixChangingVisitor
visitor used to process all matrix entries
visitor
)

Visit (and possibly change) all matrix entries using the fastest possible order.

public double

Returns:

the value returned by RealMatrixPreservingVisitor#end() at the end of the walk
walkInOptimizedOrder
(RealMatrixPreservingVisitor
visitor used to process all matrix entries
visitor
)

Visit (but don't change) all matrix entries using the fastest possible order.

public double

Returns:

the value returned by RealMatrixChangingVisitor#end() at the end of the walk
walkInOptimizedOrder
(RealMatrixChangingVisitor
visitor used to process all matrix entries
visitor
,
int
Initial row index
startRow
,
int
Final row index (inclusive)
endRow
,
int
Initial column index
startColumn
,
int
Final column index (inclusive)
endColumn
)

Visit (and possibly change) some matrix entries using the fastest possible order.

public double

Returns:

the value returned by RealMatrixPreservingVisitor#end() at the end of the walk
walkInOptimizedOrder
(RealMatrixPreservingVisitor
visitor used to process all matrix entries
visitor
,
int
Initial row index
startRow
,
int
Final row index (inclusive)
endRow
,
int
Initial column index
startColumn
,
int
Final column index (inclusive)
endColumn
)

Visit (but don't change) some matrix entries using the fastest possible order.

public double

Returns:

the value returned by RealMatrixChangingVisitor#end() at the end of the walk
walkInRowOrder
(RealMatrixChangingVisitor
visitor used to process all matrix entries
visitor
)

Visit (and possibly change) all matrix entries in row order.

public double

Returns:

the value returned by RealMatrixPreservingVisitor#end() at the end of the walk
walkInRowOrder
(RealMatrixPreservingVisitor
visitor used to process all matrix entries
visitor
)

Visit (but don't change) all matrix entries in row order.

public double

Returns:

the value returned by RealMatrixChangingVisitor#end() at the end of the walk
walkInRowOrder
(RealMatrixChangingVisitor
visitor used to process all matrix entries
visitor
,
int
Initial row index
startRow
,
int
Final row index (inclusive)
endRow
,
int
Initial column index
startColumn
,
int
Final column index
endColumn
)

Visit (and possibly change) some matrix entries in row order.

public double

Returns:

the value returned by RealMatrixPreservingVisitor#end() at the end of the walk
walkInRowOrder
(RealMatrixPreservingVisitor
visitor used to process all matrix entries
visitor
,
int
Initial row index
startRow
,
int
Final row index (inclusive)
endRow
,
int
Initial column index
startColumn
,
int
Final column index
endColumn
)

Visit (but don't change) some matrix entries in row order.

Inherited from org.apache.commons.math3.linear.AnyMatrix:
getColumnDimensiongetRowDimensionisSquare