Class ComplexCsrOperations
java.lang.Object
org.flag4j.operations.sparse.csr.complex.ComplexCsrOperations
This class contains low-level implementations for element-wise operations on complex CSR matrices.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CMatrix
addToEachCol
(CsrCMatrix src1, CVector src2) Adds a vector to each column of a matrix.static CMatrix
addToEachCol
(CsrCMatrix src1, Vector src2) Adds a vector to each column of a matrix.static CMatrix
addToEachCol
(CsrCMatrix src1, CooCVector src2) Adds a vector to each column of a matrix.static CMatrix
addToEachCol
(CsrCMatrix src1, CooVector src2) Adds a vector to each column of a matrix.static CMatrix
addToEachRow
(CsrCMatrix src1, CVector src2) Adds a vector to each row of a matrix.static CMatrix
addToEachRow
(CsrCMatrix src1, Vector src2) Adds a vector to each row of a matrix.static CMatrix
addToEachRow
(CsrCMatrix src1, CooCVector src2) Adds a vector to each row of a matrix.static CMatrix
addToEachRow
(CsrCMatrix src1, CooVector src2) Adds a vector to each row of a matrix.static CsrCMatrix
applyBinOpp
(CsrCMatrix src1, CsrCMatrix src2, BinaryOperator<CNumber> opp, UnaryOperator<CNumber> uOpp) Applies an element-wise binary operation to twocomplex CSR matrices
.static CsrCMatrix
getSlice
(CsrCMatrix src, int rowStart, int rowEnd, int colStart, int colEnd) Gets a specified slice of a CSR matrix.static CsrCMatrix
hermTranspose
(CsrCMatrix src) Computes Hermitian transpose of complex CSR matrix.static CsrCMatrix
transpose
(CsrCMatrix src) Computes transpose of complex CSR matrix.
-
Constructor Details
-
ComplexCsrOperations
private ComplexCsrOperations()
-
-
Method Details
-
hermTranspose
Computes Hermitian transpose of complex CSR matrix.- Parameters:
src
- The matrix to transpose.- Returns:
- The transpose of the
src
matrix.
-
getSlice
public static CsrCMatrix getSlice(CsrCMatrix src, int rowStart, int rowEnd, int colStart, int colEnd) 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
- IfrowEnd
is not greater thanrowStart
or ifcolEnd
is not greater thancolStart
.
-
transpose
Computes transpose of complex CSR matrix.- Parameters:
src
- The matrix to transpose.- Returns:
- The transpose of the
src
matrix.
-
applyBinOpp
public static CsrCMatrix applyBinOpp(CsrCMatrix src1, CsrCMatrix src2, BinaryOperator<CNumber> opp, UnaryOperator<CNumber> uOpp) Applies an element-wise binary operation to twocomplex 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 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.
-
addToEachCol
Adds a vector to each column of a matrix. The vector need not be a column vector. If it is a row vector it will be treated as if it were a column vector.- Parameters:
src1
- CSR matrix to add vector to each column of.src2
- Vector to add to each column of this matrix.- Returns:
- The result of adding the vector src2 to each column of this matrix.
-
addToEachCol
Adds a vector to each column of a matrix. The vector need not be a column vector. If it is a row vector it will be treated as if it were a column vector.- Parameters:
src1
- CSR matrix to add vector to each column of.src2
- Vector to add to each column of this matrix.- Returns:
- The result of adding the vector src2 to each column of this matrix.
-
addToEachCol
Adds a vector to each column of a matrix. The vector need not be a column vector. If it is a row vector it will be treated as if it were a column vector.- Parameters:
src1
- CSR matrix to add vector to each column of.src2
- Vector to add to each column of this matrix.- Returns:
- The result of adding the vector src2 to each column of this matrix.
-
addToEachCol
Adds a vector to each column of a matrix. The vector need not be a column vector. If it is a row vector it will be treated as if it were a column vector.- Parameters:
src1
- CSR matrix to add vector to each column of.src2
- Vector to add to each column of this matrix.- Returns:
- The result of adding the vector src2 to each column of this matrix.
-
addToEachRow
Adds a vector to each row of a matrix. The vector need not be a row vector. If it is a column vector it will be treated as if it were a row vector for this operation.- Parameters:
src1
- CSR matrix to add vector to each row of.src2
- Vector to add to each row of this matrix.- Returns:
- The result of adding the vector src2 to each row of this matrix.
-
addToEachRow
Adds a vector to each row of a matrix. The vector need not be a row vector. If it is a column vector it will be treated as if it were a row vector for this operation.- Parameters:
src1
- CSR matrix to add vector to each row of.src2
- Vector to add to each row of this matrix.- Returns:
- The result of adding the vector src2 to each row of this matrix.
-
addToEachRow
Adds a vector to each row of a matrix. The vector need not be a row vector. If it is a column vector it will be treated as if it were a row vector for this operation.- Parameters:
src1
- CSR matrix to add vector to each row of.src2
- Vector to add to each row of this matrix.- Returns:
- The result of adding the vector src2 to each row of this matrix.
-
addToEachRow
Adds a vector to each row of a matrix. The vector need not be a row vector. If it is a column vector it will be treated as if it were a row vector for this operation.- Parameters:
src1
- CSR matrix to add vector to each row of.src2
- Vector to add to each row of this matrix.- Returns:
- The result of adding the vector src2 to each row of this matrix.
-