Package com.powsybl.math.matrix
Class DenseMatrix
- java.lang.Object
-
- com.powsybl.math.matrix.AbstractMatrix
-
- com.powsybl.math.matrix.DenseMatrix
-
- All Implemented Interfaces:
Matrix
public class DenseMatrix extends AbstractMatrix
Dense matrix implementation based on an array ofrowCount
*columnCount
double values.- Author:
- Geoffroy Jamgotchian
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.powsybl.math.matrix.Matrix
Matrix.Element, Matrix.ElementHandler
-
-
Constructor Summary
Constructors Constructor Description DenseMatrix(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
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
add(int i, int j, double value)
Add value at rowi
and columnj
.Matrix.Element
addAndGetElement(int i, int j, double value)
Add value at rowi
and columnj
and get an#Element
to later update the element.LUDecomposition
decomposeLU()
Get LU decomposition utility class for this matrix.boolean
equals(Object obj)
double
get(int i, int j)
Get value at rowi
and columnj
.int
getColumnCount()
Get column count.protected int
getEstimatedNonZeroValueCount()
Get an estimation of non zero value count.int
getRowCount()
Get row count.double
getValue(int i, int j)
Deprecated.Useget(int, int)
instead.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(PrintStream out, List<String> rowNames, List<String> columnNames)
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
.Matrix
times(Matrix other)
Multiply the matrix by another one (this*other).Matrix
to(MatrixFactory factory)
Copy this matrix using another implementation.DenseMatrix
toDense()
Copy this matrix using a dense implementation.com.powsybl.math.matrix.SparseMatrix
toSparse()
Copy this matrix using a sparse implementation.-
Methods inherited from class com.powsybl.math.matrix.AbstractMatrix
checkBounds, copy
-
-
-
-
Constructor Detail
-
DenseMatrix
public DenseMatrix(int rowCount, int columnCount, double[] values)
-
DenseMatrix
public DenseMatrix(int rowCount, int columnCount)
-
DenseMatrix
public DenseMatrix(int rowCount, int columnCount, Supplier<ByteBuffer> bufferSupplier)
-
DenseMatrix
public DenseMatrix(Jama.Matrix matrix)
-
-
Method Detail
-
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 public double getValue(int i, int j)
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
public Matrix.Element addAndGetElement(int i, int j, double value)
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
-
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
public LUDecomposition decomposeLU()
Description copied from interface:Matrix
Get LU decomposition utility class for this matrix.- Returns:
- LU decomposition utility class for this matrix
-
times
public Matrix times(Matrix other)
Description copied from interface:Matrix
Multiply the matrix by another one (this*other).- Parameters:
other
- the other matrix- Returns:
- the result of the multiplication of this matrix by the other one
-
iterateNonZeroValue
public void iterateNonZeroValue(Matrix.ElementHandler handler)
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
public void iterateNonZeroValueOfColumn(int j, Matrix.ElementHandler handler)
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
public DenseMatrix 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
public com.powsybl.math.matrix.SparseMatrix 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
public Matrix to(MatrixFactory factory)
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
-
getEstimatedNonZeroValueCount
protected int getEstimatedNonZeroValueCount()
Description copied from class:AbstractMatrix
Get an estimation of non zero value count.- Specified by:
getEstimatedNonZeroValueCount
in classAbstractMatrix
- Returns:
- an estimation of non zero value count
-
print
public void print(PrintStream out)
Description copied from interface:Matrix
Print the matrix to a stream.- Parameters:
out
- the stream
-
print
public void print(PrintStream out, List<String> rowNames, List<String> columnNames)
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
-
-