Package com.powsybl.math.matrix
Interface Matrix
- All Known Implementing Classes:
AbstractMatrix
,DenseMatrix
,SparseMatrix
public interface Matrix
Interface for all double typed matrix implementation. It has been designed to be generic enough to allow dense and
sparse matrix implementations. In the case of sparse matrix additional usage constraint could be added and specified
in the javadoc for instance in the order a matrix has to be filled.
- Author:
- Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
An element of the matrix.static interface
Handler used to iterate a matrix and get values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int i, int j, double value) Add value at rowi
and columnj
.Addition the matrix with another one (this + other).Addition the matrix with another one (alpha * this + beta * other).addAndGetElement
(int i, int j, double value) Add value at rowi
and columnj
and get an#Element
to later update the element.int
addAndGetIndex
(int i, int j, double value) Add value at rowi
and columnj
and get an element index to later update the element.void
addAtIndex
(int index, double value) Add value at element indexindex
.void
addQuickAtIndex
(int index, double value) Add value at element indexindex
without doing any bound checking.default void
addValue
(int i, int j, double value) Deprecated.copy
(MatrixFactory factory) Copy this matrix using another implementation.static Matrix
createFromColumn
(double[] c, MatrixFactory matrixFactory) Utility method for creating a single column matrix from a java array.static Matrix
createFromRow
(double[] r, MatrixFactory matrixFactory) Utility method for creating a single row matrix from a java array.Get LU decomposition utility class for this matrix.int
Get column count.default int
getM()
Deprecated.UsegetRowCount()
instead.default int
getN()
Deprecated.UsegetColumnCount()
instead.int
Get row count.void
iterateNonZeroValue
(Matrix.ElementHandler handler) Iterate over non zero values of the matrix.void
iterateNonZeroValueOfColumn
(int j, Matrix.ElementHandler handler) Iterate over non zero values of thej
column of the matrix.void
print
(PrintStream out) Print the matrix to a stream.void
Print the matrix to a stream.void
reset()
Fill matrix with zeros.void
set
(int i, int j, double value) Set value at rowi
and columnj
.void
setAtIndex
(int index, double value) Set value at element indexindex
.void
setQuickAtIndex
(int index, double value) Set value at element indexindex
without doing any bound checking.default void
setValue
(int i, int j, double value) Deprecated.Useset(int, int, double)
instead.Multiply the matrix by another one.Multiply the matrix by another one and by a scalar (this*other*scalar).to
(MatrixFactory factory) Copy this matrix using another implementation.toDense()
Copy this matrix using a dense implementation.toSparse()
Copy this matrix using a sparse implementation.Calculate the transposed matrix.
-
Method Details
-
createFromColumn
Utility method for creating a single column matrix from a java array.- Parameters:
c
- a column arraymatrixFactory
- matrix factory to allow creating the matrix with different implementations.- Returns:
- the single column matrix
-
createFromRow
Utility method for creating a single row matrix from a java array.- Parameters:
r
- a row arraymatrixFactory
- matrix factory to allow creating the matrix with different implementations.- Returns:
- the single row matrix
-
getRowCount
int getRowCount()Get row count.- Returns:
- row count
-
getM
Deprecated.UsegetRowCount()
instead. -
getColumnCount
int getColumnCount()Get column count.- Returns:
- column count
-
getN
Deprecated.UsegetColumnCount()
instead. -
set
void set(int i, int j, double value) Set value at rowi
and columnj
.- Parameters:
i
- row indexj
- column indexvalue
- the value to set at rowi
and columnj
-
setValue
Deprecated.Useset(int, int, double)
instead. -
add
void add(int i, int j, double value) Add value at rowi
and columnj
.- Parameters:
i
- row indexj
- column indexvalue
- the value to add at rowi
and columnj
-
addAndGetElement
Add value at rowi
and columnj
and get an#Element
to later update the element.- Parameters:
i
- row indexj
- column indexvalue
- the value to add at rowi
and columnj
- Returns:
- an element at row
i
and columnj
-
addAndGetIndex
int addAndGetIndex(int i, int j, double value) Add value at rowi
and columnj
and get an element index to later update the element.- Parameters:
i
- row indexj
- column indexvalue
- the value to add at rowi
and columnj
- Returns:
- an element index corresponding to row
i
and columnj
-
setAtIndex
void setAtIndex(int index, double value) Set value at element indexindex
.- Parameters:
index
- element indexvalue
- the value to set at element indexindex
-
setQuickAtIndex
void setQuickAtIndex(int index, double value) Set value at element indexindex
without doing any bound checking.- Parameters:
index
- element indexvalue
- the value to set at element indexindex
-
addAtIndex
void addAtIndex(int index, double value) Add value at element indexindex
.- Parameters:
index
- element indexvalue
- the value to add at element indexindex
-
addQuickAtIndex
void addQuickAtIndex(int index, double value) Add value at element indexindex
without doing any bound checking.- Parameters:
index
- element indexvalue
- the value to add at element indexindex
-
addValue
Deprecated.Useadd(int, int, double)
instead. -
reset
void reset()Fill matrix with zeros. -
decomposeLU
LUDecomposition decomposeLU()Get LU decomposition utility class for this matrix.- Returns:
- LU decomposition utility class for this matrix
-
times
Multiply the matrix by another one and by a scalar (this*other*scalar). The resulting matrix has the same implementation as this matrix.- Parameters:
other
- the other matrixscalar
- a scalar to multiply the result matrix- Returns:
- the result of the multiplication of this matrix by the other one
-
times
Multiply the matrix by another one. The resulting matrix has the same implementation as this matrix.- Parameters:
other
- the other matrix- Returns:
- the result of the multiplication of this matrix by the other one
-
add
Addition the matrix with another one (alpha * this + beta * other). The resulting matrix has the same implementation as this matrix.- Parameters:
other
- the other matrixalpha
- a scalar to multiply this matrixbeta
- a scalar to multiply other matrix- Returns:
- the result of the addition of this matrix and the other one
-
add
Addition the matrix with another one (this + other). The resulting matrix has the same implementation as this matrix.- Parameters:
other
- the other matrix- Returns:
- the result of the addition of this matrix and the other one
-
iterateNonZeroValue
Iterate over non zero values of the matrix. At each non zero valueMatrix.ElementHandler.onElement(int, int, double)
is called.- Parameters:
handler
- the element handler
-
iterateNonZeroValueOfColumn
Iterate over non zero values of thej
column of the matrix. At each non zero valueMatrix.ElementHandler.onElement(int, int, double)
is called.- Parameters:
j
- column indexhandler
- the element handler
-
toDense
DenseMatrix toDense()Copy this matrix using a dense implementation. If already a dense matrix, this method is allowed to return this.- Returns:
- a copy of the matrix with a dense implementation.
-
toSparse
SparseMatrix toSparse()Copy this matrix using a sparse implementation. If already a sparse matrix, this method is allowed to return this.- Returns:
- a copy of the matrix with a sparse implementation.
-
to
Copy this matrix using another implementation. If already with the right implementation, this method is allowed to return this.- Parameters:
factory
- a matrix factory to create the copy.- Returns:
- a copy of the matrix
-
copy
Copy this matrix using another implementation. This method is not allowed to return this.- Parameters:
factory
- a matrix factory to create the copy.- Returns:
- a copy of the matrix
-
transpose
Matrix transpose()Calculate the transposed matrix.- Returns:
- the transposed matrix
-
print
Print the matrix to a stream. Row and column names are also printed to facilitate debugging.- Parameters:
out
- the streamrowNames
- row namescolumnNames
- column names
-
print
Print the matrix to a stream.- Parameters:
out
- the stream
-
add(int, int, double)
instead.