Class CooConcat
java.lang.Object
org.flag4j.linalg.ops.sparse.coo.CooConcat
This utility class contains methods for combining or joining sparse COO tensors, matrices, and vectors.
All methods in this class will result in non-zero data and indices being lexicographically sorted.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> void
augment
(T[] src1Entries, int[] src1RowIndices, int[] src1ColIndices, int src1NumCols, T[] src2Entries, int[] src2RowIndices, int[] src2ColIndices, T[] destEntries, int[] destRowIndices, int[] destColIndices) Augments two matrices.static <T> void
augmentVector
(T[] src1Entries, int[] src1RowIndices, int[] src1ColIndices, int src1NumCols, T[] src2Entries, int[] src2Indices, T[] destEntries, int[] destRowIndices, int[] destColIndices) Augments two matrices.static <T> void
join
(T[] src1Entries, int[] src1Indices, int src1Size, T[] src2Entries, int[] src2Indices, T[] destEntries, int[] destIndices) Joins two sparse COO vectors into one vector.static <T> Shape
repeat
(T[] src, int[] srcIndices, int size, int n, int axis, T[] destEntries, int[] destRows, int[] destCols) Repeats a sparse COO vectorn
times along a certain axis to create a matrix.static <T> void
stack
(T[] src1Entries, int[] src1RowIndices, int[] src1ColIndices, int src1NumRows, T[] src2Entries, int[] src2RowIndices, int[] src2ColIndices, T[] destEntries, int[] destRowIndices, int[] destColIndices) Stacks two sparse COO matrices along columns.static <T> void
stack
(T[] src1, int[] src1Indices, T[] src2, int[] src2Indices, T[] destEntries, int[] rowIndices, int[] colIndices) Stacks two sparse COO vectors joining along columns as if they were row vectors.
-
Method Details
-
stack
public static <T> void stack(T[] src1Entries, int[] src1RowIndices, int[] src1ColIndices, int src1NumRows, T[] src2Entries, int[] src2RowIndices, int[] src2ColIndices, T[] destEntries, int[] destRowIndices, int[] destColIndices) Stacks two sparse COO matrices along columns.
WARNING: This method does not perform any bounds checks. If the destination arrays are not large enough, an
IndexOutOfBoundsException
will be thrown.- Parameters:
src1Entries
- Non-zero data of the first COO matrix to stack.src1RowIndices
- Row indices of the first COO matrix to stack.src1ColIndices
- Column indices of the first COO matrix to stack.src1NumRows
- The number of rows in the first COO matrix. This is required to compute the shifted indices of the second matrix.src2Entries
- Non-zero data of the second COO matrix to stack.src2RowIndices
- Row indices of the second COO matrix to stack.src2ColIndices
- Column indices of the second COO matrix to stack.destEntries
- Array to store the non-zero data resulting from the stacking the two COO matrices.destRowIndices
- Array to store the row indices resulting from the stacking the two COO matrices.destColIndices
- Array to store the column indices resulting from the stacking the two COO matrices.- Throws:
IndexOutOfBoundsException
- If copying arrays to the destination arrays would cause access of data outside the array.- See Also:
-
augment
public static <T> void augment(T[] src1Entries, int[] src1RowIndices, int[] src1ColIndices, int src1NumCols, T[] src2Entries, int[] src2RowIndices, int[] src2ColIndices, T[] destEntries, int[] destRowIndices, int[] destColIndices) Augments two matrices. This is equivalent to joining the matrices stacks matrices along rows.- Parameters:
src1Entries
- Non-zero data of the first COO matrix to augment.src1RowIndices
- Row indices of the first COO matrix to augment.src1ColIndices
- Column indices of the first COO matrix to augment.src1NumCols
- The number of columns in the first COO matrix. This is required to compute the shifted indices of the second matrix.src2Entries
- Non-zero data of the second COO matrix to augment.src2RowIndices
- Row indices of the second COO matrix to augment.src2ColIndices
- Column indices of the second COO matrix to augment.destEntries
- Array to store the non-zero data resulting from the augmenting the two COO matrices.destRowIndices
- Array to store the row indices resulting from the augmenting the two COO matrices.destColIndices
- Array to store the column indices resulting from the augmenting the two COO matrices.- Throws:
IllegalArgumentException
- If this matrix and matrixb
have a different number of rows.- See Also:
-
augmentVector
public static <T> void augmentVector(T[] src1Entries, int[] src1RowIndices, int[] src1ColIndices, int src1NumCols, T[] src2Entries, int[] src2Indices, T[] destEntries, int[] destRowIndices, int[] destColIndices) Augments two matrices. This is equivalent to joining the matrices stacks matrices along rows.- Parameters:
src1Entries
- Non-zero data of the first COO matrix to augment.src1RowIndices
- Row indices of the first COO matrix to augment.src1ColIndices
- Column indices of the first COO matrix to augment.src1NumCols
- The number of columns in the first COO matrix. This is required to compute the shifted indices of vector.src2Entries
- Non-zero data of the COO vector to augment.destEntries
- Array to store the non-zero data resulting from the augmenting the two COO matrices.destRowIndices
- Array to store the row indices resulting from the augmenting the two COO matrices.destColIndices
- Array to store the column indices resulting from the augmenting the two COO matrices.src2RowIndices
- Indices of the COO vector to augment.- Throws:
IllegalArgumentException
- If this matrix and matrixb
have a different number of rows.- See Also:
-
join
public static <T> void join(T[] src1Entries, int[] src1Indices, int src1Size, T[] src2Entries, int[] src2Indices, T[] destEntries, int[] destIndices) Joins two sparse COO vectors into one vector.- Parameters:
src1Entries
- Non-zero data of the first vector to join.src1Indices
- Non-zero indices of the first vector to join.src1Size
- Full size of the first vector.src2Entries
- Non-zero data of the second vector to join.src2Indices
- Non-zero indices of the second vector to join.destEntries
- Array to store the resulting non-zero data of the vector join.destIndices
- Array to store the resulting non-zero indices of the vector join.- Throws:
IndexOutOfBoundsException
- IfdestEntries.length < src1Entries.length + src2Entries.length
ordestIndices.length < src1Indices.length + src2Indices.length
-
repeat
public static <T> Shape repeat(T[] src, int[] srcIndices, int size, int n, int axis, T[] destEntries, int[] destRows, int[] destCols) Repeats a sparse COO vectorn
times along a certain axis to create a matrix.- Parameters:
src
- Non-zero data of the vector.srcIndices
- Non-zero indices of the vector.size
- The full size of the vector.n
- Number of times to repeat vector.axis
- Axis along which to repeat vector. Ifaxis=0
then each row of the resulting matrix will be equivalent to this vector. Ifaxis=1
then each column of the resulting matrix will be equivalent to this vector.destEntries
- Array to store the non-zero data of the resulting matrix.destRows
- Array to store the non-zero row indices of the resulting matrix.destCols
- Array to store the non-zero column indices of the resulting matrix.- Returns:
- The shape of the resulting matrix.
-
stack
public static <T> void stack(T[] src1, int[] src1Indices, T[] src2, int[] src2Indices, T[] destEntries, int[] rowIndices, int[] colIndices) Stacks two sparse COO vectors joining along columns as if they were row vectors. That is, constructs a sparse COO matrix from the two vectors where the first row of the matrix is given by the fist vector in the stack operation and the second row is given by the second vector.- Parameters:
src1
- Non-zero data of the fist COO vector to stack.src1Indices
- Non-zero indices of the first COO vector to stack.src2
- Non-zero data of the second COO vector to stack.src2Indices
- Non-zero indices of the second COO vector to stack.destEntries
- Array to store the non
-