Class DenseCooFieldMatrixOps
java.lang.Object
org.flag4j.linalg.ops.dense_sparse.coo.field_ops.DenseCooFieldMatrixOps
This class contains low level implementations for ops between a dense and a sparse field matrix.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Field<T>>
AbstractDenseFieldMatrix<?, ?, T> add(AbstractDenseFieldMatrix<?, ?, T> src1, AbstractCooFieldMatrix<?, ?, ?, T> src2) Computes the element-wise sum of a dense matrix to a sparse COO matrix.static <T extends Field<T>>
voidaddEq(AbstractDenseFieldMatrix<?, ?, T> src1, AbstractCooFieldMatrix<?, ?, ?, T> src2) Adds a complex dense matrix to a real sparse matrix and stores the result in the first matrix.static <T extends Field<T>>
AbstractDenseFieldMatrix<?, ?, T> addToEachCol(AbstractCooFieldMatrix<?, ?, ?, T> src, AbstractDenseFieldVector<?, ?, T> col) Adds a dense vector to each column as if the vector is a column vector.static <T extends Field<T>>
AbstractDenseFieldMatrix<?, ?, T> addToEachRow(AbstractCooFieldMatrix<?, ?, ?, T> src, AbstractDenseFieldVector<?, ?, T> row) Adds a dense vector to add to each row as if the vector is a row vector.static <T extends Field<T>>
AbstractCooFieldMatrix<?, ?, ?, T> elemDiv(AbstractCooFieldMatrix<?, ?, ?, T> src1, AbstractDenseFieldMatrix<?, ?, T> src2) Computes the element-wise division between a complex sparse matrix and a complex dense matrix.static <T extends Field<T>>
voidelemMult(Shape shape1, T[] data1, Shape shape2, T[] data2, int[] rowIndices2, int[] colIndices2, T[] dest) Computes the element-wise multiplication between a real dense matrix and a real sparse matrix.static <T extends Field<T>>
AbstractDenseFieldMatrix<?, ?, T> sub(AbstractCooFieldMatrix<?, ?, ?, T> src2, AbstractDenseFieldMatrix<?, ?, T> src1) Subtracts a complex dense matrix from a complex sparse matrix.static <T extends Field<T>>
AbstractDenseFieldMatrix<?, ?, T> sub(AbstractDenseFieldMatrix<?, ?, T> src1, AbstractCooFieldMatrix<?, ?, ?, T> src2) Subtracts a real sparse matrix from a real dense matrix.static <T extends Field<T>>
voidsubEq(AbstractDenseFieldMatrix<?, ?, T> src1, AbstractCooFieldMatrix<?, ?, ?, T> src2) Subtracts a complex sparse matrix from a complex dense matrix and stores the result in the dense matrix.
-
Method Details
-
add
public static <T extends Field<T>> AbstractDenseFieldMatrix<?,?, addT> (AbstractDenseFieldMatrix<?, ?, T> src1, AbstractCooFieldMatrix<?, ?, ?, T> src2) Computes the element-wise sum of a dense matrix to a sparse COO matrix.- Parameters:
src1- Dense matrix in sum.src2- Sparse COO matrix in the sum.- Returns:
- The element-wise sum of
src1andsrc2. - Throws:
IllegalArgumentException- If the matrices do not have the same shape.
-
sub
public static <T extends Field<T>> AbstractDenseFieldMatrix<?,?, subT> (AbstractDenseFieldMatrix<?, ?, T> src1, AbstractCooFieldMatrix<?, ?, ?, T> src2) Subtracts a real sparse matrix from a real dense matrix.- Parameters:
src1- First matrix.src2- Second matrix.- Returns:
- The result of the matrix subtraction.
- Throws:
IllegalArgumentException- If the matrices do not have the same shape.
-
sub
public static <T extends Field<T>> AbstractDenseFieldMatrix<?,?, subT> (AbstractCooFieldMatrix<?, ?, ?, T> src2, AbstractDenseFieldMatrix<?, ?, T> src1) Subtracts a complex dense matrix from a complex 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
public static <T extends Field<T>> void addEq(AbstractDenseFieldMatrix<?, ?, T> src1, AbstractCooFieldMatrix<?, ?, ?, T> src2) Adds a complex dense matrix to a real sparse matrix and stores the result in the first matrix.- Parameters:
src1- First matrix.src2- Second matrix.- Throws:
IllegalArgumentException- If the matrices do not have the same shape.
-
subEq
public static <T extends Field<T>> void subEq(AbstractDenseFieldMatrix<?, ?, T> src1, AbstractCooFieldMatrix<?, ?, ?, T> src2) Subtracts a complex sparse matrix from a complex dense matrix and stores the result in the dense matrix.- Parameters:
src1- First matrix.src2- Second matrix.- Throws:
IllegalArgumentException- If the matrices do not have the same shape.
-
elemMult
public static <T extends Field<T>> void elemMult(Shape shape1, T[] data1, Shape shape2, T[] data2, int[] rowIndices2, int[] colIndices2, T[] dest) Computes the element-wise multiplication between a real dense matrix and a real sparse matrix.- Parameters:
shape1- Shape of the first matrix in element-wise product.data1- Entries of the first matrix in the element-wise product.shape2- Shape of the second matrix in the element-wise product.data2- Non-zero data of the second matrix in the element-wise product.rowIndices2- Non-zero row indices of the second matrix in the element-wise product.colIndices2- Non-zero column indices of the second matrix in the element-wise product.dest- Array to store the non-zero data of the sparse COO matrix resulting from the element-wise multiplication (modified). Must have same length asdata2. May be the same array asdata2.- Throws:
TensorShapeException- If!shape1.equals(shape2)
-
elemDiv
public static <T extends Field<T>> AbstractCooFieldMatrix<?,?, elemDiv?, T> (AbstractCooFieldMatrix<?, ?, ?, T> src1, AbstractDenseFieldMatrix<?, ?, T> src2) Computes the element-wise division between a complex sparse matrix and a complex 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_INFINITYorDouble.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 ops 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
src1andsrc2. - Throws:
IllegalArgumentException- Ifsrc1andsrc2do not have the same shape.
-
addToEachCol
public static <T extends Field<T>> AbstractDenseFieldMatrix<?,?, addToEachColT> (AbstractCooFieldMatrix<?, ?, ?, T> src, AbstractDenseFieldVector<?, ?, T> col) 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
srcmatrix with the specified vector added to each column. - Throws:
IllegalArgumentException- If the number of data in thecolvector does not match the number of rows in thesrcmatrix.
-
addToEachRow
public static <T extends Field<T>> AbstractDenseFieldMatrix<?,?, addToEachRowT> (AbstractCooFieldMatrix<?, ?, ?, T> src, AbstractDenseFieldVector<?, ?, T> row) 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
srcmatrix with the specified vector added to each row. - Throws:
IllegalArgumentException- If the number of data in thecolvector does not match the number of columns in thesrcmatrix.
-