Class RealDenseSparseMatrixOperations
java.lang.Object
org.flag4j.operations.dense_sparse.coo.real.RealDenseSparseMatrixOperations
This class contains low-level operations between a real dense and real sparse matrix.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Matrix
Adds a real dense matrix to a real sparse matrix.static void
Adds a real dense matrix to a real sparse matrix and stores the result in the first matrix.static Matrix
addToEachCol
(CooMatrix src, Vector col) Adds a dense vector to each column as if the vector is a column vector.static Matrix
addToEachRow
(CooMatrix src, Vector row) Adds a dense vector to add to each row as if the vector is a row vector.static CooMatrix
Computes the element-wise division between a real sparse matrix and a real dense matrix.static CooMatrix
Computes the element-wise multiplication between a real dense matrix and a real sparse matrix.static Matrix
Subtracts a real sparse matrix from a real dense matrix.static Matrix
Subtracts a real dense matrix from a real sparse matrix.static void
Subtracts a real sparse matrix from a real dense matrix and stores the result in the first matrix.
-
Constructor Details
-
RealDenseSparseMatrixOperations
private RealDenseSparseMatrixOperations()
-
-
Method Details
-
add
Adds a real dense matrix to a real sparse matrix.- Parameters:
src1
- First matrix in sum.src2
- Second matrix in sum.- Returns:
- The result of the matrix addition.
- Throws:
IllegalArgumentException
- If the matrices do not have the same shape.
-
sub
Subtracts a real sparse matrix from a real dense matrix.- Parameters:
src1
- First matrix in difference.src2
- Second matrix in difference.- Returns:
- The result of the matrix subtraction.
- Throws:
IllegalArgumentException
- If the matrices do not have the same shape.
-
sub
Subtracts a real dense matrix from a real sparse matrix.- Parameters:
src2
- Entries of second matrix in the difference.src1
- Entries of first matrix in difference.- Returns:
- The result of the matrix subtraction.
- Throws:
IllegalArgumentException
- If the matrices do not have the same shape.
-
addEq
Adds a real dense matrix to a real sparse matrix and stores the result in the first matrix.- Parameters:
src1
- Entries of first matrix in the sum. Also, storage for the result.src2
- Entries of second matrix in the sum.- Throws:
IllegalArgumentException
- If the matrices do not have the same shape.
-
subEq
Subtracts a real sparse matrix from a real dense matrix and stores the result in the first matrix.- Parameters:
src1
- Entries of first matrix in difference.src2
- Entries of second matrix in difference.- Throws:
IllegalArgumentException
- If the matrices do not have the same shape.
-
elemMult
Computes the element-wise multiplication between a real dense matrix and a real sparse matrix.- Parameters:
src1
- Entries of first matrix in element-wise product.src2
- Entries of second matrix in element-wise product.- Returns:
- The result of element-wise multiplication.
- Throws:
IllegalArgumentException
- If the matrices do not have the same shape.
-
elemDiv
Computes the element-wise division between a real sparse matrix and a real dense matrix.If the dense matrix contains a zero at the same index the sparse matrix contains a non-zero, the result will be either
Double.POSITIVE_INFINITY
orDouble.NEGATIVE_INFINITY
.If the dense matrix contains a zero at an index for which the sparse matrix is also zero, the result will be zero. This is done to realize computational benefits from operations with sparse matrices.
- Parameters:
src1
- Real sparse matrix and numerator in element-wise quotient.src2
- Real Dense matrix and denominator in element-wise quotient.- Returns:
- The element-wise quotient of
src1
andsrc2
. - Throws:
IllegalArgumentException
- Ifsrc1
andsrc2
do not have the same shape.
-
addToEachCol
Adds a dense vector to each column as if the vector is a column vector.- Parameters:
src
- Source sparse matrix.col
- Vector to add to each column of the source matrix.- Returns:
- A dense copy of the
src
matrix with the specified vector added to each column. - Throws:
IllegalArgumentException
- If the number of entries in thecol
vector does not match the number of rows in thesrc
matrix.
-
addToEachRow
Adds a dense vector to add to each row as if the vector is a row vector.- Parameters:
src
- Source sparse matrix.row
- Vector to add to each row of the source matrix.- Returns:
- A dense copy of the
src
matrix with the specified vector added to each row. - Throws:
IllegalArgumentException
- If the number of entries in thecol
vector does not match the number of columns in thesrc
matrix.
-