Package org.tribuo.math.util
Class HeapMerger
java.lang.Object
org.tribuo.math.util.HeapMerger
- All Implemented Interfaces:
Serializable
,Merger
Merges each
SparseVector
separately using a PriorityQueue
as a heap.
Relies upon VectorIterator.compareTo(VectorIterator)
.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic SparseVector
merge
(List<SparseVector> vectors, int dimension, int[] indicesBuffer, double[] valuesBuffer) Merges a list of sparse vectors into a single sparse vector, summing the values.merge
(DenseSparseMatrix[] inputs) Merges an array of DenseSparseMatrix into a single DenseSparseMatrix.merge
(SparseVector[] inputs) Merges an array of SparseVector into a single SparseVector.
-
Constructor Details
-
HeapMerger
public HeapMerger()
-
-
Method Details
-
merge
Description copied from interface:Merger
Merges an array of DenseSparseMatrix into a single DenseSparseMatrix. -
merge
Description copied from interface:Merger
Merges an array of SparseVector into a single SparseVector. -
merge
public static SparseVector merge(List<SparseVector> vectors, int dimension, int[] indicesBuffer, double[] valuesBuffer) Merges a list of sparse vectors into a single sparse vector, summing the values.- Parameters:
vectors
- The vectors to merge.dimension
- The dimension of the sparse vector.indicesBuffer
- A buffer for the indices.valuesBuffer
- A buffer for the values.- Returns:
- The merged SparseVector.
-