Class CooDataSorter<T>
java.lang.Object
org.flag4j.linalg.ops.sparse.coo.CooDataSorter<T>
A class which can be used to sort the indices, along with data values, in lexicographical order.
This class is not thread safe.
Specifically, if a sparse tensor has shape (10, 15, 5, 2) and the following indices and non-zero values,
- Indices: {{4, 1, 2, 0}, {4, 0, 1, 2}, {1, 2, 3, 0}, {2, 3, 5, 1}, {9, 10, 4, 1}, {1, 2, 1, 1}} - Values: {1.1, 2.2, 3.3, 4.4, 5.5, 6.6}then the sorted indices and non-zero values will be,
- Indices: {{1, 2, 1, 1}, {1, 2, 3, 0}, {2, 3, 5, 1}, {4, 0, 1, 2}, {4, 1, 2, 0}, {9, 10, 4, 1}} - Values: {6.6, 3.3, 4.4, 2.2, 1.1, 5.5}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSorts the wrapped indices in lexicographical order while maintaining the order of the non-zero values so that their order matches the order of the indices.void
unwrap
(double[] values, int[] indices) Unwraps sparse data values and indices.void
unwrap
(double[] values, int[][] indices) Unwraps sparse data values and indices.void
unwrap
(double[] values, int[] rowIndices, int[] colIndices) Unwraps sparse data values and indices.void
Unwraps sparse data values and indices.void
Unwraps sparse data values and indices.void
Unwraps sparse data values and indices.static CooDataSorter
wrap
(double[] values, int[] indices) Factory method which wraps data in an instance ofCooDataSorter
and returns that instance.static CooDataSorter
wrap
(double[] values, int[][] indices) Factory method which wraps data in an instance ofCooDataSorter
and returns that instance.static CooDataSorter
wrap
(double[] values, int[] rowIndices, int[] colIndices) Factory method which wraps data in an instance ofCooDataSorter
and returns that instance.static CooDataSorter
Factory method which wraps data in an instance ofCooDataSorter
and returns that instance.static CooDataSorter
Factory method which wraps data in an instance ofCooDataSorter
and returns that instance.static CooDataSorter
Factory method which wraps data in an instance ofCooDataSorter
and returns that instance.
-
Constructor Details
-
CooDataSorter
Creates a sorter which can sort the indices and values of a COO matrix lexicographically.
When
sparseSort()
is called on an instance created with this constructor, the sorting will be done in place.- Parameters:
values
- Non-zero values of the sparse COO matrix.rowIndices
- Row indices of the sparse COO matrix.colIndices
- Row indices of the sparse COO matrix.
-
-
Method Details
-
wrap
Factory method which wraps data in an instance ofCooDataSorter
and returns that instance.- Parameters:
values
- Non-zero values of the sparse tensor.indices
- Indices of non-zero values in the sparse tensor.- Returns:
- A new instance of
CooDataSorter
which wraps the specifiedvalues
andindices
.
-
wrap
Factory method which wraps data in an instance ofCooDataSorter
and returns that instance.- Parameters:
values
- Non-zero values of the sparse tensor.indices
- Indices of non-zero values in the sparse tensor.- Returns:
- A new instance of
CooDataSorter
which wraps the specifiedvalues
andindices
.
-
wrap
Factory method which wraps data in an instance ofCooDataSorter
and returns that instance.- Parameters:
values
- Non-zero values of the sparse tensor.indices
- Indices of non-zero values in the sparse tensor.- Returns:
- A new instance of
CooDataSorter
which wraps the specifiedvalues
andindices
.
-
wrap
Factory method which wraps data in an instance ofCooDataSorter
and returns that instance.- Parameters:
values
- Non-zero values of the sparse tensor.indices
- Indices of non-zero values in the sparse tensor.- Returns:
- A new instance of
CooDataSorter
which wraps the specifiedvalues
andindices
.
-
wrap
Factory method which wraps data in an instance ofCooDataSorter
and returns that instance.- Parameters:
values
- Non-zero values of the sparse tensor.rowIndices
- Row indices of non-zero data of the sparse tensor.colIndices
- Column indices of non-zero data of the sparse tensor.- Returns:
- A new instance of
CooDataSorter
which wraps the specifiedvalues
andindices
.
-
wrap
Factory method which wraps data in an instance ofCooDataSorter
and returns that instance.- Parameters:
values
- Non-zero values of the sparse tensor.rowIndices
- Row indices of non-zero data of the sparse tensor.colIndices
- Column indices of non-zero data of the sparse tensor.- Returns:
- A new instance of
CooDataSorter
which wraps the specifiedvalues
andindices
.
-
sparseSort
Sorts the wrapped indices in lexicographical order while maintaining the order of the non-zero values so that their order matches the order of the indices.- Returns:
- A reference to this sparse data wrapper.
-
unwrap
Unwraps sparse data values and indices.- Parameters:
values
- Storage for unwrapped values. Must have the same length as that passed to the constructor. Modified.indices
- Storage for unwrapped indices. Must have the same shape as that passed to the constructor. Modified.
-
unwrap
Unwraps sparse data values and indices.- Parameters:
values
- Storage for unwrapped values. Must have the same length as that passed to the constructor. Modified.indices
- Storage for unwrapped indices. Must have the same shape as that passed to the constructor. Modified.
-
unwrap
public void unwrap(double[] values, int[][] indices) Unwraps sparse data values and indices.- Parameters:
values
- Storage for unwrapped values. Must have the same length as that passed to the constructor. Modified.indices
- Storage for unwrapped indices. Must have the same shape as that passed to the constructor. Modified.
-
unwrap
public void unwrap(double[] values, int[] rowIndices, int[] colIndices) Unwraps sparse data values and indices.- Parameters:
values
- Storage for unwrapped values. Must have the same length as that passed to the constructor. Modified.rowIndices
- Storage for unwrapped row indices. Must have the same shape as that passed to the constructor. Modified.colIndices
- Storage for unwrapped column indices. Must have the same shape as that passed to the constructor. Modified.
-
unwrap
Unwraps sparse data values and indices.- Parameters:
values
- Storage for unwrapped values. Must have the same length as that passed to the constructor. Modified.rowIndices
- Storage for unwrapped row indices. Must have the same shape as that passed to the constructor. Modified.colIndices
- Storage for unwrapped column indices. Must have the same shape as that passed to the constructor. Modified.
-
unwrap
public void unwrap(double[] values, int[] indices) Unwraps sparse data values and indices.- Parameters:
values
- Storage for unwrapped values. Must have the same length as that passed to the constructor. Modified.indices
- Storage for unwrapped indices. Must have the same shape as that passed to the constructor. Modified.
-