|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math3.linear.RealLinearOperator
org.apache.commons.math3.linear.AbstractRealMatrix
org.apache.commons.math3.linear.Array2DRowRealMatrix
public class Array2DRowRealMatrix
Implementation of RealMatrix
using a double[][]
array to
store entries.
Field Summary | |
---|---|
private double[][] |
data
Entries of the matrix. |
private static long |
serialVersionUID
Serializable version identifier. |
Constructor Summary | |
---|---|
Array2DRowRealMatrix()
Creates a matrix with no data |
|
Array2DRowRealMatrix(double[] v)
Create a new (column) RealMatrix using v as the
data for the unique column of the created matrix. |
|
Array2DRowRealMatrix(double[][] d)
Create a new RealMatrix using the input array as the underlying
data array. |
|
Array2DRowRealMatrix(double[][] d,
boolean copyArray)
Create a new RealMatrix using the input array as the underlying data array. |
|
Array2DRowRealMatrix(int rowDimension,
int columnDimension)
Create a new RealMatrix with the supplied row and column dimensions. |
Method Summary | |
---|---|
Array2DRowRealMatrix |
add(Array2DRowRealMatrix m)
Compute the sum of this matrix with m . |
void |
addToEntry(int row,
int column,
double increment)
Change an entry in the specified row and column. |
RealMatrix |
copy()
Returns a (deep) copy of this. |
private void |
copyIn(double[][] in)
Replace data with a fresh copy of the input array. |
private double[][] |
copyOut()
Get a fresh copy of the underlying data array. |
RealMatrix |
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[][] |
getData()
Returns matrix entries as a two-dimensional array. |
double[][] |
getDataRef()
Get a reference to the underlying data array. |
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. |
Array2DRowRealMatrix |
multiply(Array2DRowRealMatrix m)
Postmultiplying this matrix by m . |
void |
multiplyEntry(int row,
int column,
double factor)
Change an entry in the specified row and column. |
double[] |
operate(double[] v)
Returns the result of multiplying this by the vector v . |
double[] |
preMultiply(double[] v)
Returns the (row) vector result of premultiplying this by the vector v . |
void |
setEntry(int row,
int column,
double value)
Set the entry in the specified row and column. |
void |
setSubMatrix(double[][] subMatrix,
int row,
int column)
Replace the submatrix starting at row, column using data in
the input subMatrix array. |
Array2DRowRealMatrix |
subtract(Array2DRowRealMatrix m)
Subtract m from this matrix. |
double |
walkInColumnOrder(RealMatrixChangingVisitor visitor)
Visit (and possibly change) all matrix entries in column order. |
double |
walkInColumnOrder(RealMatrixChangingVisitor visitor,
int startRow,
int endRow,
int startColumn,
int endColumn)
Visit (and possibly change) some matrix entries in column order. |
double |
walkInColumnOrder(RealMatrixPreservingVisitor visitor)
Visit (but don't change) all matrix entries in column order. |
double |
walkInColumnOrder(RealMatrixPreservingVisitor visitor,
int startRow,
int endRow,
int startColumn,
int endColumn)
Visit (but don't change) some matrix entries in column order. |
double |
walkInRowOrder(RealMatrixChangingVisitor visitor)
Visit (and possibly change) all matrix entries in row order. |
double |
walkInRowOrder(RealMatrixChangingVisitor visitor,
int startRow,
int endRow,
int startColumn,
int endColumn)
Visit (and possibly change) some matrix entries in row order. |
double |
walkInRowOrder(RealMatrixPreservingVisitor visitor)
Visit (but don't change) all matrix entries in row order. |
double |
walkInRowOrder(RealMatrixPreservingVisitor visitor,
int startRow,
int endRow,
int startColumn,
int endColumn)
Visit (but don't change) some matrix entries in row order. |
Methods inherited from class org.apache.commons.math3.linear.AbstractRealMatrix |
---|
add, copySubMatrix, copySubMatrix, equals, getColumn, getColumnMatrix, getColumnVector, getFrobeniusNorm, getNorm, getRow, getRowMatrix, getRowVector, getSubMatrix, getSubMatrix, getTrace, hashCode, isSquare, multiply, operate, power, preMultiply, preMultiply, scalarAdd, scalarMultiply, setColumn, setColumnMatrix, setColumnVector, setRow, setRowMatrix, setRowVector, subtract, toString, transpose, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder |
Methods inherited from class org.apache.commons.math3.linear.RealLinearOperator |
---|
isTransposable, operateTranspose |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private double[][] data
Constructor Detail |
---|
public Array2DRowRealMatrix()
public Array2DRowRealMatrix(int rowDimension, int columnDimension)
rowDimension
- Number of rows in the new matrix.columnDimension
- Number of columns in the new matrix.
NotStrictlyPositiveException
- if the row or column dimension is not positive.public Array2DRowRealMatrix(double[][] d) throws DimensionMismatchException, NoDataException, NullArgumentException
RealMatrix
using the input array as the underlying
data array.
The input array is copied, not referenced. This constructor has
the same effect as calling Array2DRowRealMatrix(double[][], boolean)
with the second argument set to true
.
d
- Data for the new matrix.
DimensionMismatchException
- if d
is not rectangular.
NoDataException
- if d
row or colum dimension is zero.
NullArgumentException
- if d
is null
.Array2DRowRealMatrix(double[][], boolean)
public Array2DRowRealMatrix(double[][] d, boolean copyArray)
copyArray
may be
set to false
. This will prevent the copying and improve
performance as no new array will be built and no data will be copied.
d
- Data for new matrix.copyArray
- if true
, the input array will be copied,
otherwise it will be referenced.
DimensionMismatchException
- if d
is not rectangular
(not all rows have the same length) or empty.
NullArgumentException
- if d
is null
.
NoDataException
- if there are not at least one row and one column.Array2DRowRealMatrix(double[][])
public Array2DRowRealMatrix(double[] v)
v
as the
data for the unique column of the created matrix.
The input array is copied.
v
- Column vector holding data for new matrix.Method Detail |
---|
public RealMatrix createMatrix(int rowDimension, int columnDimension)
createMatrix
in interface RealMatrix
createMatrix
in class AbstractRealMatrix
rowDimension
- the number of rows in the new matrixcolumnDimension
- the number of columns in the new matrix
public RealMatrix copy()
copy
in interface RealMatrix
copy
in class AbstractRealMatrix
public Array2DRowRealMatrix add(Array2DRowRealMatrix m)
m
.
m
- Matrix to be added.
this
+ m.
MatrixDimensionMismatchException
- if m
is not the same size as this matrix.public Array2DRowRealMatrix subtract(Array2DRowRealMatrix m)
m
from this matrix.
m
- Matrix to be subtracted.
this
- m.
MatrixDimensionMismatchException
- if m
is not the same size as this matrix.public Array2DRowRealMatrix multiply(Array2DRowRealMatrix m)
m
.
m
- Matrix to postmultiply by.
this
* m.
DimensionMismatchException
- if the number of columns of this
matrix is not equal to the number of rows of m
.public double[][] getData()
getData
in interface RealMatrix
getData
in class AbstractRealMatrix
public double[][] getDataRef()
public void setSubMatrix(double[][] subMatrix, int row, int column)
row, column
using data in
the input subMatrix
array. Indexes are 0-based.
Example:
Starting with
1 2 3 4 5 6 7 8 9 0 1 2and
subMatrix = {{3, 4} {5,6}}
, invoking
setSubMatrix(subMatrix,1,1))
will result in 1 2 3 4 5 3 4 8 9 5 6 2
setSubMatrix
in interface RealMatrix
setSubMatrix
in class AbstractRealMatrix
subMatrix
- array containing the submatrix replacement datarow
- row coordinate of the top, left element to be replacedcolumn
- column coordinate of the top, left element to be replacedpublic double getEntry(int row, int column)
getEntry
in interface RealMatrix
getEntry
in class AbstractRealMatrix
row
- Row location of entry to be fetched.column
- Column location of entry to be fetched.
(row, column)
.public void setEntry(int row, int column, double value)
setEntry
in interface RealMatrix
setEntry
in class AbstractRealMatrix
row
- Row location of entry to be set.column
- Column location of entry to be set.value
- matrix entry to be set.public void addToEntry(int row, int column, double increment)
addToEntry
in interface RealMatrix
addToEntry
in class AbstractRealMatrix
row
- Row location of entry to be set.column
- Column location of entry to be set.increment
- value to add to the matrix entry.public void multiplyEntry(int row, int column, double factor)
multiplyEntry
in interface RealMatrix
multiplyEntry
in class AbstractRealMatrix
row
- Row location of entry to be set.column
- Column location of entry to be set.factor
- Multiplication factor for the matrix entry.public int getRowDimension()
getRowDimension
in interface AnyMatrix
getRowDimension
in class AbstractRealMatrix
public int getColumnDimension()
getColumnDimension
in interface AnyMatrix
getColumnDimension
in class AbstractRealMatrix
public double[] operate(double[] v)
v
.
operate
in interface RealMatrix
operate
in class AbstractRealMatrix
v
- the vector to operate on
public double[] preMultiply(double[] v)
v
.
preMultiply
in interface RealMatrix
preMultiply
in class AbstractRealMatrix
v
- the row vector to premultiply by
public double walkInRowOrder(RealMatrixChangingVisitor visitor)
Row order starts at upper left and iterating through all elements of a row from left to right before going to the leftmost element of the next row.
walkInRowOrder
in interface RealMatrix
walkInRowOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entries
RealMatrixChangingVisitor.end()
at the end
of the walkRealMatrix.walkInRowOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInRowOrder(RealMatrixPreservingVisitor visitor)
Row order starts at upper left and iterating through all elements of a row from left to right before going to the leftmost element of the next row.
walkInRowOrder
in interface RealMatrix
walkInRowOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entries
RealMatrixPreservingVisitor.end()
at the end
of the walkRealMatrix.walkInRowOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInRowOrder(RealMatrixChangingVisitor visitor, int startRow, int endRow, int startColumn, int endColumn)
Row order starts at upper left and iterating through all elements of a row from left to right before going to the leftmost element of the next row.
walkInRowOrder
in interface RealMatrix
walkInRowOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entriesstartRow
- Initial row indexendRow
- Final row index (inclusive)startColumn
- Initial column indexendColumn
- Final column index
RealMatrixChangingVisitor.end()
at the end
of the walkRealMatrix.walkInRowOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInRowOrder(RealMatrixPreservingVisitor visitor, int startRow, int endRow, int startColumn, int endColumn)
Row order starts at upper left and iterating through all elements of a row from left to right before going to the leftmost element of the next row.
walkInRowOrder
in interface RealMatrix
walkInRowOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entriesstartRow
- Initial row indexendRow
- Final row index (inclusive)startColumn
- Initial column indexendColumn
- Final column index
RealMatrixPreservingVisitor.end()
at the end
of the walkRealMatrix.walkInRowOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInColumnOrder(RealMatrixChangingVisitor visitor)
Column order starts at upper left and iterating through all elements of a column from top to bottom before going to the topmost element of the next column.
walkInColumnOrder
in interface RealMatrix
walkInColumnOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entries
RealMatrixChangingVisitor.end()
at the end
of the walkRealMatrix.walkInRowOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInColumnOrder(RealMatrixPreservingVisitor visitor)
Column order starts at upper left and iterating through all elements of a column from top to bottom before going to the topmost element of the next column.
walkInColumnOrder
in interface RealMatrix
walkInColumnOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entries
RealMatrixPreservingVisitor.end()
at the end
of the walkRealMatrix.walkInRowOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInColumnOrder(RealMatrixChangingVisitor visitor, int startRow, int endRow, int startColumn, int endColumn)
Column order starts at upper left and iterating through all elements of a column from top to bottom before going to the topmost element of the next column.
walkInColumnOrder
in interface RealMatrix
walkInColumnOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entriesstartRow
- Initial row indexendRow
- Final row index (inclusive)startColumn
- Initial column indexendColumn
- Final column index
RealMatrixChangingVisitor.end()
at the end
of the walkRealMatrix.walkInRowOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInColumnOrder(RealMatrixPreservingVisitor visitor, int startRow, int endRow, int startColumn, int endColumn)
Column order starts at upper left and iterating through all elements of a column from top to bottom before going to the topmost element of the next column.
walkInColumnOrder
in interface RealMatrix
walkInColumnOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entriesstartRow
- Initial row indexendRow
- Final row index (inclusive)startColumn
- Initial column indexendColumn
- Final column index
RealMatrixPreservingVisitor.end()
at the end
of the walkRealMatrix.walkInRowOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
private double[][] copyOut()
private void copyIn(double[][] in) throws DimensionMismatchException, NoDataException, NullArgumentException
in
- Data to copy.
NoDataException
- if the input array is empty.
DimensionMismatchException
- if the input array is not rectangular.
NullArgumentException
- if
the input array is null
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |