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

public abstract Class AbstractRealMatrix

extends RealLinearOperator
implements RealMatrix
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.linear.RealMatrix, org.apache.commons.math3.linear.AnyMatrix
Known Direct Subclasses
org.apache.commons.math3.linear.Array2DRowRealMatrix, org.apache.commons.math3.linear.BlockRealMatrix, org.apache.commons.math3.linear.DiagonalMatrix, org.apache.commons.math3.linear.OpenMapRealMatrix
Imports
java.util.ArrayList, .Locale, org.apache.commons.math3.exception.NoDataException, .NotPositiveException, .NotStrictlyPositiveException, .DimensionMismatchException, .NullArgumentException, .NumberIsTooSmallException, .OutOfRangeException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.util.MathUtils, .FastMath

Basic implementation of RealMatrix methods regardless of the underlying storage.

All the methods implemented here use getEntry(int, int) to access matrix elements. Derived class can provide faster implementations.

Since
2.0

Field Summary

Modifier and TypeField and Description
private static final RealMatrixFormat
DEFAULT_FORMAT

Default format.

Constructor Summary

AccessConstructor and Description
protected
AbstractRealMatrix()

Creates a matrix with no data

protected
AbstractRealMatrix(final int
the number of rows in the new matrix
rowDimension
,
final int
the number of columns in the new matrix
columnDimension
)

Create a new RealMatrix with the supplied row and column dimensions.

Method Summary

Modifier and TypeMethod and Description
public RealMatrix
add(RealMatrix
matrix to be added
m
)

Implements org.apache.commons.math3.linear.RealMatrix.add.

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
)

Implements org.apache.commons.math3.linear.RealMatrix.addToEntry.

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

public abstract RealMatrix
copy()

Redeclares org.apache.commons.math3.linear.RealMatrix.copy.

Returns a (deep) copy of this.

public void
copySubMatrix(final int
Initial row index
startRow
,
final int
Final row index (inclusive)
endRow
,
final int
Initial column index
startColumn
,
final int
Final column index (inclusive)
endColumn
,
final 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
)

Implements org.apache.commons.math3.linear.RealMatrix.copySubMatrix.

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
)

Implements org.apache.commons.math3.linear.RealMatrix.copySubMatrix.

Copy a submatrix.

public abstract RealMatrix
createMatrix(int
the number of rows in the new matrix
rowDimension
,
int
the number of columns in the new matrix
columnDimension
)

Redeclares org.apache.commons.math3.linear.RealMatrix.createMatrix.

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

public boolean

Returns:

true if object equals this
equals
(final Object
the object to test equality against.
object
)

Overrides java.lang.Object.equals.

Returns true iff object is a RealMatrix instance with the same dimensions as this and all corresponding matrix entries are equal.

public double[]
getColumn(final int
Column to be fetched.
column
)

Implements org.apache.commons.math3.linear.RealMatrix.getColumn.

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

public abstract int

Returns:

the number of columns.
getColumnDimension
()

Redeclares org.apache.commons.math3.linear.AnyMatrix.getColumnDimension.

Implements abstract org.apache.commons.math3.linear.RealLinearOperator.getColumnDimension.

Returns the number of columns of this matrix.

public RealMatrix
getColumnMatrix(final int
Column to be fetched.
column
)

Implements org.apache.commons.math3.linear.RealMatrix.getColumnMatrix.

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

public RealVector
getColumnVector(final int
Column to be fetched.
column
)

Implements org.apache.commons.math3.linear.RealMatrix.getColumnVector.

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

public double[][]
getData()

Implements org.apache.commons.math3.linear.RealMatrix.getData.

Returns matrix entries as a two-dimensional array.

public abstract double
getEntry(int
Row index of entry to be fetched.
row
,
int
Column index of entry to be fetched.
column
)

Redeclares org.apache.commons.math3.linear.RealMatrix.getEntry.

Get the entry in the specified row and column.

public double
public double
public double[]
getRow(final int
Row to be fetched.
row
)

Implements org.apache.commons.math3.linear.RealMatrix.getRow.

Get the entries at the given row index.

public abstract int

Returns:

the number of rows.
getRowDimension
()

Redeclares org.apache.commons.math3.linear.AnyMatrix.getRowDimension.

Implements abstract org.apache.commons.math3.linear.RealLinearOperator.getRowDimension.

Returns the number of rows of this matrix.

public RealMatrix
getRowMatrix(final int
Row to be fetched.
row
)

Implements org.apache.commons.math3.linear.RealMatrix.getRowMatrix.

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

public RealVector
getRowVector(final int
Row to be fetched.
row
)

Implements org.apache.commons.math3.linear.RealMatrix.getRowVector.

Returns the entries in row number row as a vector.

public RealMatrix
getSubMatrix(final int
Initial row index
startRow
,
final int
Final row index (inclusive)
endRow
,
final int
Initial column index
startColumn
,
final int
Final column index (inclusive)
endColumn
)

Implements org.apache.commons.math3.linear.RealMatrix.getSubMatrix.

Gets a submatrix.

public RealMatrix
getSubMatrix(final int[]
Array of row indices.
selectedRows
,
final int[]
Array of column indices.
selectedColumns
)

Implements org.apache.commons.math3.linear.RealMatrix.getSubMatrix.

Gets a submatrix.

public double
getTrace()

Implements org.apache.commons.math3.linear.RealMatrix.getTrace.

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

public int

Returns:

hashcode for matrix
hashCode
()

Overrides java.lang.Object.hashCode.

Computes a hashcode for the matrix.

public boolean
isSquare()

Implements org.apache.commons.math3.linear.AnyMatrix.isSquare.

Is this a square matrix?

public RealMatrix
multiply(final RealMatrix
matrix to postmultiply by
m
)

Implements org.apache.commons.math3.linear.RealMatrix.multiply.

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
)

Implements org.apache.commons.math3.linear.RealMatrix.multiplyEntry.

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

public double[]
operate(final double[]
the vector to operate on
v
)

Implements org.apache.commons.math3.linear.RealMatrix.operate.

Returns the result of multiplying this by the vector v.

public RealVector
operate(final RealVector
the vector to operate on
v
)

Implements abstract org.apache.commons.math3.linear.RealLinearOperator.operate.

Implements org.apache.commons.math3.linear.RealMatrix.operate.

Returns the result of multiplying this by the vector v.

public RealMatrix
power(final int
raise this to power p
p
)

Implements org.apache.commons.math3.linear.RealMatrix.power.

Returns the result of multiplying this with itself p times.

public RealMatrix
preMultiply(final RealMatrix
matrix to premultiply by
m
)

Implements org.apache.commons.math3.linear.RealMatrix.preMultiply.

Returns the result of premultiplying this by m.

public double[]
preMultiply(final double[]
the row vector to premultiply by
v
)

Implements org.apache.commons.math3.linear.RealMatrix.preMultiply.

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

public RealVector
preMultiply(final RealVector
the row vector to premultiply by
v
)

Implements org.apache.commons.math3.linear.RealMatrix.preMultiply.

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

public RealMatrix
scalarAdd(final double
value to be added to each entry
d
)

Implements org.apache.commons.math3.linear.RealMatrix.scalarAdd.

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

public RealMatrix
scalarMultiply(final double
value to multiply all entries by
d
)

Implements org.apache.commons.math3.linear.RealMatrix.scalarMultiply.

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

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

Implements org.apache.commons.math3.linear.RealMatrix.setColumn.

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

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

Implements org.apache.commons.math3.linear.RealMatrix.setColumnMatrix.

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

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

Implements org.apache.commons.math3.linear.RealMatrix.setColumnVector.

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

public abstract 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
)

Redeclares org.apache.commons.math3.linear.RealMatrix.setEntry.

Set the entry in the specified row and column.

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

Implements org.apache.commons.math3.linear.RealMatrix.setRow.

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

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

Implements org.apache.commons.math3.linear.RealMatrix.setRowMatrix.

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

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

Implements org.apache.commons.math3.linear.RealMatrix.setRowVector.

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

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

Implements org.apache.commons.math3.linear.RealMatrix.setSubMatrix.

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

public RealMatrix
subtract(final RealMatrix
matrix to be subtracted
m
)

Implements org.apache.commons.math3.linear.RealMatrix.subtract.

Returns this minus m.

public String

Returns:

a string representation for this matrix
toString
()

Overrides java.lang.Object.toString.

Get a string representation for this matrix.

public RealMatrix
transpose()

Implements org.apache.commons.math3.linear.RealMatrix.transpose.

Returns the transpose of this matrix.

public double
walkInColumnOrder(final RealMatrixChangingVisitor
visitor used to process all matrix entries
visitor
)

Implements org.apache.commons.math3.linear.RealMatrix.walkInColumnOrder.

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

public double
walkInColumnOrder(final RealMatrixPreservingVisitor
visitor used to process all matrix entries
visitor
)

Implements org.apache.commons.math3.linear.RealMatrix.walkInColumnOrder.

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

public double
walkInColumnOrder(final RealMatrixChangingVisitor
visitor used to process all matrix entries
visitor
,
final int
Initial row index
startRow
,
final int
Final row index (inclusive)
endRow
,
final int
Initial column index
startColumn
,
final int
Final column index
endColumn
)

Implements org.apache.commons.math3.linear.RealMatrix.walkInColumnOrder.

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

public double
walkInColumnOrder(final RealMatrixPreservingVisitor
visitor used to process all matrix entries
visitor
,
final int
Initial row index
startRow
,
final int
Final row index (inclusive)
endRow
,
final int
Initial column index
startColumn
,
final int
Final column index
endColumn
)

Implements org.apache.commons.math3.linear.RealMatrix.walkInColumnOrder.

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

public double
walkInOptimizedOrder(final RealMatrixChangingVisitor
visitor used to process all matrix entries
visitor
)

Implements org.apache.commons.math3.linear.RealMatrix.walkInOptimizedOrder.

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

public double
walkInOptimizedOrder(final RealMatrixPreservingVisitor
visitor used to process all matrix entries
visitor
)

Implements org.apache.commons.math3.linear.RealMatrix.walkInOptimizedOrder.

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

public double
walkInOptimizedOrder(final RealMatrixChangingVisitor
visitor used to process all matrix entries
visitor
,
final int
Initial row index
startRow
,
final int
Final row index (inclusive)
endRow
,
final int
Initial column index
startColumn
,
final int
Final column index (inclusive)
endColumn
)

Implements org.apache.commons.math3.linear.RealMatrix.walkInOptimizedOrder.

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

public double
walkInOptimizedOrder(final RealMatrixPreservingVisitor
visitor used to process all matrix entries
visitor
,
final int
Initial row index
startRow
,
final int
Final row index (inclusive)
endRow
,
final int
Initial column index
startColumn
,
final int
Final column index (inclusive)
endColumn
)

Implements org.apache.commons.math3.linear.RealMatrix.walkInOptimizedOrder.

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

public double
walkInRowOrder(final RealMatrixChangingVisitor
visitor used to process all matrix entries
visitor
)

Implements org.apache.commons.math3.linear.RealMatrix.walkInRowOrder.

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

public double
walkInRowOrder(final RealMatrixPreservingVisitor
visitor used to process all matrix entries
visitor
)

Implements org.apache.commons.math3.linear.RealMatrix.walkInRowOrder.

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

public double
walkInRowOrder(final RealMatrixChangingVisitor
visitor used to process all matrix entries
visitor
,
final int
Initial row index
startRow
,
final int
Final row index (inclusive)
endRow
,
final int
Initial column index
startColumn
,
final int
Final column index
endColumn
)

Implements org.apache.commons.math3.linear.RealMatrix.walkInRowOrder.

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

public double
walkInRowOrder(final RealMatrixPreservingVisitor
visitor used to process all matrix entries
visitor
,
final int
Initial row index
startRow
,
final int
Final row index (inclusive)
endRow
,
final int
Initial column index
startColumn
,
final int
Final column index
endColumn
)

Implements org.apache.commons.math3.linear.RealMatrix.walkInRowOrder.

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

Inherited from org.apache.commons.math3.linear.RealLinearOperator:
isTransposableoperateTranspose