Package com.powsybl.math.matrix
Class DenseMatrix
java.lang.Object
com.powsybl.math.AbstractMathNative
com.powsybl.math.matrix.AbstractMatrix
com.powsybl.math.matrix.DenseMatrix
- All Implemented Interfaces:
Matrix
Dense matrix implementation based on an array of
rowCount
* columnCount
double values.- Author:
- Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.powsybl.math.matrix.Matrix
Matrix.Element, Matrix.ElementHandler
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDenseMatrix
(int rowCount, int columnCount) DenseMatrix
(int rowCount, int columnCount, double[] values) DenseMatrix
(int rowCount, int columnCount, Supplier<ByteBuffer> bufferSupplier) DenseMatrix
(Jama.Matrix matrix) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int i, int j, double value) Add value at rowi
and columnj
.add
(DenseMatrix other, double alpha, double beta) 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.Get LU decomposition utility class for this matrix.boolean
double
get
(int i, int j) Get value at rowi
and columnj
.int
Get column count.int
Get row count.double
getValue
(int i, int j) Deprecated.int
Get value count.int
hashCode()
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.times
(DenseMatrix other) times
(DenseMatrix other, double scalar) 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.Methods inherited from class com.powsybl.math.matrix.AbstractMatrix
add, checkBounds, copy, times
-
Field Details
-
MAX_ELEMENT_COUNT
public static final int MAX_ELEMENT_COUNT- See Also:
-
-
Constructor Details
-
DenseMatrix
public DenseMatrix(int rowCount, int columnCount, double[] values) -
DenseMatrix
public DenseMatrix(int rowCount, int columnCount) -
DenseMatrix
-
DenseMatrix
public DenseMatrix(Jama.Matrix matrix)
-
-
Method Details
-
get
public double get(int i, int j) Get value at rowi
and columnj
.- Parameters:
i
- row indexj
- column index- Returns:
- value at row
i
and columnj
-
getValue
Deprecated.Useget(int, int)
instead. -
set
public void set(int i, int j, double value) Description copied from interface:Matrix
Set value at rowi
and columnj
.- Parameters:
i
- row indexj
- column indexvalue
- the value to set at rowi
and columnj
-
add
public void add(int i, int j, double value) Description copied from interface:Matrix
Add value at rowi
and columnj
.- Parameters:
i
- row indexj
- column indexvalue
- the value to add at rowi
and columnj
-
addAndGetElement
Description copied from interface:Matrix
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
public int addAndGetIndex(int i, int j, double value) Description copied from interface:Matrix
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
public void setAtIndex(int index, double value) Description copied from interface:Matrix
Set value at element indexindex
.- Parameters:
index
- element indexvalue
- the value to set at element indexindex
-
setQuickAtIndex
public void setQuickAtIndex(int index, double value) Description copied from interface:Matrix
Set value at element indexindex
without doing any bound checking.- Parameters:
index
- element indexvalue
- the value to set at element indexindex
-
addAtIndex
public void addAtIndex(int index, double value) Description copied from interface:Matrix
Add value at element indexindex
.- Parameters:
index
- element indexvalue
- the value to add at element indexindex
-
addQuickAtIndex
public void addQuickAtIndex(int index, double value) Description copied from interface:Matrix
Add value at element indexindex
without doing any bound checking.- Parameters:
index
- element indexvalue
- the value to add at element indexindex
-
reset
public void reset()Description copied from interface:Matrix
Fill matrix with zeros. -
getRowCount
public int getRowCount()Description copied from interface:Matrix
Get row count.- Returns:
- row count
-
getColumnCount
public int getColumnCount()Description copied from interface:Matrix
Get column count.- Returns:
- column count
-
decomposeLU
Description copied from interface:Matrix
Get LU decomposition utility class for this matrix.- Returns:
- LU decomposition utility class for this matrix
-
times
Description copied from interface:Matrix
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
-
times
-
add
-
add
Description copied from interface:Matrix
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
-
iterateNonZeroValue
Description copied from interface:Matrix
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
Description copied from interface:Matrix
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
Description copied from interface:Matrix
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
Description copied from interface:Matrix
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
Description copied from interface:Matrix
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
-
getValueCount
public int getValueCount()Description copied from class:AbstractMatrix
Get value count.- Specified by:
getValueCount
in classAbstractMatrix
- Returns:
- the value count
-
transpose
Description copied from interface:Matrix
Calculate the transposed matrix.- Returns:
- the transposed matrix
-
print
Description copied from interface:Matrix
Print the matrix to a stream.- Parameters:
out
- the stream
-
print
Description copied from interface:Matrix
Print the matrix to a stream. Row and column names are also printed to facilitate debugging.- Parameters:
out
- the streamrowNames
- row namescolumnNames
- column names
-
hashCode
public int hashCode() -
equals
-
get(int, int)
instead.