Class RealComplexCsrOperations
java.lang.Object
org.flag4j.operations.sparse.csr.real_complex.RealComplexCsrOperations
This class contains low-level implementations for element-wise operations on real/complex CSR matrices.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CsrCMatrix
applyBinOpp
(CsrCMatrix src1, CsrMatrix src2, BiFunction<CNumber, Double, CNumber> opp, UnaryOperator<Double> uOpp) Applies an element-wise binary operation to twoCSR Matrices
.static CsrCMatrix
applyBinOpp
(CsrMatrix src1, CsrCMatrix src2, BiFunction<Double, CNumber, CNumber> opp, UnaryOperator<CNumber> uOpp) Applies an element-wise binary operation to twoCSR Matrices
.static CsrCMatrix
elemMult
(CsrCMatrix src1, CsrMatrix src2) Computes the element-wise multiplication between a complex sparse matrix and a real sparse matrix.
-
Constructor Details
-
RealComplexCsrOperations
private RealComplexCsrOperations()
-
-
Method Details
-
applyBinOpp
public static CsrCMatrix applyBinOpp(CsrMatrix src1, CsrCMatrix src2, BiFunction<Double, CNumber, CNumber> opp, UnaryOperator<CNumber> uOpp) Applies an element-wise binary operation to twoCSR Matrices
.
Note, this methods efficiency relies heavily on the assumption that both operand matrices are very large and very sparse. If the two matrices are not large and very sparse, this method will likely be significantly slower than simply converting the matrices todense matrices
and using a dense matrix addition algorithm.- Parameters:
src1
- The first matrix in the operation.src2
- The second matrix in the operation.opp
- Binary operator to apply element-wise tosrc1
andsrc2
.uOpp
- Unary operator for use with binary operations which are not commutative such as subtraction. If the operation is commutative this should benull
. If the binary operation is not commutative, it needs to be decomposable to one commutative binary operationopp
and one unary operationuOpp
such that it is equivalent toopp.apply(x, uOpp.apply(y))
.- Returns:
- The result of applying the specified binary operation to
src1
andsrc2
element-wise. - Throws:
IllegalArgumentException
- Ifsrc1
andsrc2
do not have the same shape.
-
applyBinOpp
public static CsrCMatrix applyBinOpp(CsrCMatrix src1, CsrMatrix src2, BiFunction<CNumber, Double, CNumber> opp, UnaryOperator<Double> uOpp) Applies an element-wise binary operation to twoCSR Matrices
.
Note, this methods efficiency relies heavily on the assumption that both operand matrices are very large and very sparse. If the two matrices are not large and very sparse, this method will likely be significantly slower than simply converting the matrices todense matrices
and using a dense matrix addition algorithm.- Parameters:
src1
- The first matrix in the operation.src2
- The second matrix in the operation.opp
- Binary operator to apply element-wise tosrc1
andsrc2
.uOpp
- Unary operator for use with binary operations which are not commutative such as subtraction. If the operation is commutative this should benull
. If the binary operation is not commutative, it needs to be decomposable to one commutative binary operationopp
and one unary operationuOpp
such that it is equivalent toopp.apply(x, uOpp.apply(y))
.- Returns:
- The result of applying the specified binary operation to
src1
andsrc2
element-wise. - Throws:
IllegalArgumentException
- Ifsrc1
andsrc2
do not have the same shape.
-
elemMult
Computes the element-wise multiplication between a complex sparse matrix and a real sparse matrix.- Parameters:
src1
- The first matrix in the element-wise multiplication.src2
- The second matrix in the element-wise multiplication.- Returns:
- The result of the element-wise multiplication between
src1
andsrc2
. - Throws:
IllegalArgumentException
- Ifsrc1
andsrc2
do not have the same shape.
-