Class ReadOnlySparseVector.ReadOnlySparseVectorBinding
- java.lang.Object
-
- com.qfs.vector.binding.impl.AVectorBinding
-
- com.qfs.vector.binding.impl.GenericVectorBinding
-
- com.activeviam.risk.core.vector.impl.ReadOnlySparseVector.ReadOnlySparseVectorBinding
-
- All Implemented Interfaces:
com.qfs.vector.IVectorBinding
- Enclosing class:
- ReadOnlySparseVector
public static class ReadOnlySparseVector.ReadOnlySparseVectorBinding extends com.qfs.vector.binding.impl.GenericVectorBinding
Custom binding to use more efficient custom ReadOnlySparseVector methods for aggregation methods: plus, minus and copyFrom. We are trying to avoid calling getDouble() for every index in the vector which ultimately calls getExplicitValueIndex() which takes O(N). This leads to a total time complexity of O(N2) for operations that use loops to call getDouble() for each element in a ReadOnlySparseVector - such as the aggregation functions. Instead of retrieving each double from the ReadOnlySparseVector to perform an operation, we can instead perform the operation in the ReadOnlySparseVector its-self. This allows us to keep track of where the Explicit values are located in the compressed representation of the vector rather than searching for a specific index for every Explicit value. This allows us to perform the aggregation operations in O(N) time and O(1) space.
-
-
Constructor Summary
Constructors Constructor Description ReadOnlySparseVectorBinding()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
copyFrom(com.qfs.vector.IVector source, com.qfs.vector.IVector destination)
void
minus(com.qfs.vector.IVector source, com.qfs.vector.IVector destination)
void
plus(com.qfs.vector.IVector source, com.qfs.vector.IVector destination)
-
Methods inherited from class com.qfs.vector.binding.impl.GenericVectorBinding
applyAsDouble, applyAsFloat, applyAsInt, applyAsLong, checkIndex, equals, getInstance, minusNegativeValues, minusPositiveValues, plusNegativeValues, plusPositiveValues
-
-
-
-
Method Detail
-
plus
public final void plus(com.qfs.vector.IVector source, com.qfs.vector.IVector destination)
- Specified by:
plus
in interfacecom.qfs.vector.IVectorBinding
- Overrides:
plus
in classcom.qfs.vector.binding.impl.GenericVectorBinding
-
minus
public final void minus(com.qfs.vector.IVector source, com.qfs.vector.IVector destination)
- Specified by:
minus
in interfacecom.qfs.vector.IVectorBinding
- Overrides:
minus
in classcom.qfs.vector.binding.impl.GenericVectorBinding
-
copyFrom
public final void copyFrom(com.qfs.vector.IVector source, com.qfs.vector.IVector destination)
- Specified by:
copyFrom
in interfacecom.qfs.vector.IVectorBinding
- Overrides:
copyFrom
in classcom.qfs.vector.binding.impl.GenericVectorBinding
-
-