Class RealCsrOps
java.lang.Object
org.flag4j.linalg.ops.sparse.csr.real.RealCsrOps
This utility class contains low-level implementations for operations on real CSR matrices.
-
Method Summary
Modifier and TypeMethodDescriptionstatic CsrMatrixapplyBinOpp(CsrMatrix src1, CsrMatrix src2, BinaryOperator<Double> bOpp, UnaryOperator<Double> uOpp) Applies an element-wise binary operation to twoCSR Matrices.static CsrMatrixComputes the element-wise multiplication between two real CSR matrices.static CsrMatrixGets a specified slice of a CSR matrix.static CsrMatrixTransposes a sparse CSR matrix.
-
Method Details
-
elemMult
Computes the element-wise multiplication between two real CSR matrices.- Parameters:
src1- First CSR matrix in the element-wise product.src2- Second CSR matrix in the element-wise product.- Returns:
- The element-wise product of
src1andsrc2. - Throws:
TensorShapeException- If!src1.shape.equals(src2.shape)
-
applyBinOpp
public static CsrMatrix applyBinOpp(CsrMatrix src1, CsrMatrix src2, BinaryOperator<Double> bOpp, UnaryOperator<Double> uOpp) Applies an element-wise binary operation to two
CSR 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 to
dense matricesand using a dense matrix addition algorithm.- Parameters:
src1- The first matrix in the operation.src2- The second matrix in the operation.bOpp- Binary operator to apply element-wise tosrc1andsrc2.uOpp- Unary operator for use with binary ops 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 operationbOppand one unary operationuOppsuch that it is equivalent tobOpp.apply(x, uOpp.apply(y)).- Returns:
- The result of applying the specified binary operation to
src1andsrc2element-wise. - Throws:
IllegalArgumentException- Ifsrc1andsrc2do not have the same shape.
-
transpose
-
getSlice
Gets a specified slice of a CSR matrix.- Parameters:
src- Sparse CSR matrix to extract slice from.rowStart- Starting row index of slice (inclusive).rowEnd- Ending row index of slice (exclusive).colStart- Starting column index of slice (inclusive).colEnd- Ending row index of slice (exclusive).- Returns:
- The specified slice of this matrix. This is a completely new matrix and NOT a view into the matrix.
- Throws:
ArrayIndexOutOfBoundsException- If any of the indices are out of bounds of this matrix.IllegalArgumentException- IfrowEndis not greater thanrowStartor ifcolEndis not greater thancolStart.
-