|
|||||||||
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.DiagonalMatrix
public class DiagonalMatrix
Implementation of a diagonal matrix.
Field Summary | |
---|---|
private double[] |
data
Entries of the diagonal. |
private static long |
serialVersionUID
Serializable version identifier. |
Constructor Summary | |
---|---|
DiagonalMatrix(double[] d)
Creates a matrix using the input array as the underlying data. |
|
DiagonalMatrix(double[] d,
boolean copyArray)
Creates a matrix using the input array as the underlying data. |
|
DiagonalMatrix(int dimension)
Creates a matrix with the supplied dimension. |
Method Summary | |
---|---|
DiagonalMatrix |
add(DiagonalMatrix m)
Compute the sum of this and m . |
void |
addToEntry(int row,
int column,
double increment)
Adds (in place) the specified value to the specified entry of this matrix. |
RealMatrix |
copy()
Returns a (deep) copy of this. |
RealMatrix |
createMatrix(int rowDimension,
int columnDimension)
Create a new RealMatrix of the same type as the instance with the supplied row and column dimensions. |
private void |
ensureZero(double value)
Ensure a value is zero. |
int |
getColumnDimension()
Returns the number of columns of this matrix. |
double[][] |
getData()
Returns matrix entries as a two-dimensional array. |
double[] |
getDataRef()
Gets 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. |
DiagonalMatrix |
multiply(DiagonalMatrix m)
Returns the result of postmultiplying this by m . |
RealMatrix |
multiply(RealMatrix m)
Returns the result of postmultiplying this by m . |
void |
multiplyEntry(int row,
int column,
double factor)
Multiplies (in place) the specified entry of this matrix by the
specified value. |
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. |
DiagonalMatrix |
subtract(DiagonalMatrix m)
Returns this minus m . |
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, operate, power, preMultiply, preMultiply, scalarAdd, scalarMultiply, setColumn, setColumnMatrix, setColumnVector, setRow, setRowMatrix, setRowVector, setSubMatrix, subtract, toString, transpose, walkInColumnOrder, walkInColumnOrder, walkInColumnOrder, walkInColumnOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInRowOrder, walkInRowOrder, walkInRowOrder, walkInRowOrder |
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 final double[] data
Constructor Detail |
---|
public DiagonalMatrix(int dimension) throws NotStrictlyPositiveException
dimension
- Number of rows and columns in the new matrix.
NotStrictlyPositiveException
- if the dimension is
not positive.public DiagonalMatrix(double[] d)
d
- Data for the new matrix.public DiagonalMatrix(double[] d, boolean copyArray) throws NullArgumentException
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.
NullArgumentException
- if d is nullMethod Detail |
---|
public RealMatrix createMatrix(int rowDimension, int columnDimension) throws NotStrictlyPositiveException, DimensionMismatchException
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
DimensionMismatchException
- if the requested dimensions are not equal.
NotStrictlyPositiveException
- if row or column dimension is not
positive.public RealMatrix copy()
copy
in interface RealMatrix
copy
in class AbstractRealMatrix
public DiagonalMatrix add(DiagonalMatrix m) throws MatrixDimensionMismatchException
this
and m
.
m
- Matrix to be added.
this + m
.
MatrixDimensionMismatchException
- if m
is not the same
size as this
.public DiagonalMatrix subtract(DiagonalMatrix m) throws MatrixDimensionMismatchException
this
minus m
.
m
- Matrix to be subtracted.
this - m
MatrixDimensionMismatchException
- if m
is not the same
size as this
.public DiagonalMatrix multiply(DiagonalMatrix m) throws DimensionMismatchException
this
by m
.
m
- matrix to postmultiply by
this * m
DimensionMismatchException
- if
columnDimension(this) != rowDimension(m)
public RealMatrix multiply(RealMatrix m) throws DimensionMismatchException
this
by m
.
multiply
in interface RealMatrix
multiply
in class AbstractRealMatrix
m
- matrix to postmultiply by
this * m
DimensionMismatchException
- if
columnDimension(this) != rowDimension(m)
public double[][] getData()
getData
in interface RealMatrix
getData
in class AbstractRealMatrix
public double[] getDataRef()
public double getEntry(int row, int column) throws OutOfRangeException
getEntry
in interface RealMatrix
getEntry
in class AbstractRealMatrix
row
- Row index of entry to be fetched.column
- Column index of entry to be fetched.
(row, column)
.
OutOfRangeException
- if the row or column index is not valid.public void setEntry(int row, int column, double value) throws OutOfRangeException, NumberIsTooLargeException
setEntry
in interface RealMatrix
setEntry
in class AbstractRealMatrix
row
- Row index of entry to be set.column
- Column index of entry to be set.value
- the new value of the entry.
NumberIsTooLargeException
- if row != column
and value is non-zero.
OutOfRangeException
- if the row or column index is not validpublic void addToEntry(int row, int column, double increment) throws OutOfRangeException, NumberIsTooLargeException
this
matrix. Row and column indices start at 0.
addToEntry
in interface RealMatrix
addToEntry
in class AbstractRealMatrix
row
- Row index of the entry to be modified.column
- Column index of the entry to be modified.increment
- value to add to the matrix entry.
NumberIsTooLargeException
- if row != column
and increment is non-zero.
OutOfRangeException
- if the row or column index is not valid.public void multiplyEntry(int row, int column, double factor) throws OutOfRangeException
this
matrix by the
specified value. Row and column indices start at 0.
multiplyEntry
in interface RealMatrix
multiplyEntry
in class AbstractRealMatrix
row
- Row index of the entry to be modified.column
- Column index of the entry to be modified.factor
- Multiplication factor for the matrix entry.
OutOfRangeException
- if the row or column index is not valid.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) throws DimensionMismatchException
v
.
operate
in interface RealMatrix
operate
in class AbstractRealMatrix
v
- the vector to operate on
this * v
DimensionMismatchException
- if the length of v
does not
match the column dimension of this
.public double[] preMultiply(double[] v) throws DimensionMismatchException
v
.
preMultiply
in interface RealMatrix
preMultiply
in class AbstractRealMatrix
v
- the row vector to premultiply by
v * this
DimensionMismatchException
- if the length of v
does not
match the row dimension of this
.private void ensureZero(double value) throws NumberIsTooLargeException
value
- value to check
NumberIsTooLargeException
- if value is not zero
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |