Class FloatVectorData

    • Field Detail

      • vectorSI

        protected float[] vectorSI
        The internal storage of the Vector; can be sparse or dense.
    • Constructor Detail

      • FloatVectorData

        FloatVectorData​(StorageType storageType)
        Construct a new FloatVectorData object.
        Parameters:
        storageType - StorageType; the data type.
    • Method Detail

      • instantiate

        public static FloatVectorData instantiate​(float[] values,
                                                  Scale scale,
                                                  StorageType storageType)
        Instantiate a FloatVectorData with the right data type.
        Parameters:
        values - float[]; the (SI) values to store
        scale - Scale; the scale of the unit to use for conversion to SI
        storageType - StorageType; the data type to use
        Returns:
        FloatVectorData; the FloatVectorData with the right data type
        Throws:
        NullPointerException - when values are null, or storageType is null
      • instantiate

        public static FloatVectorData instantiate​(List<Float> values,
                                                  Scale scale,
                                                  StorageType storageType)
        Instantiate a FloatVectorData with the right data type.
        Parameters:
        values - List<Float>; the values to store
        scale - Scale; the scale of the unit to use for conversion to SI
        storageType - StorageType; the data type to use
        Returns:
        FloatVectorData; the FloatVectorData with the right data type
        Throws:
        NullPointerException - when list is null, or storageType is null
      • instantiate

        public static <U extends Unit<U>,​S extends FloatScalarInterface<U,​S>> FloatVectorData instantiate​(S[] values,
                                                                                                                      StorageType storageType)
        Instantiate a FloatVectorData with the right data type.
        Type Parameters:
        U - the unit type
        S - the corresponding scalar type
        Parameters:
        values - S[]; the values to store
        storageType - StorageType; the data type to use
        Returns:
        FloatVectorData; the FloatVectorData with the right data type
        Throws:
        NullPointerException - when values is null, or storageType is null
      • instantiateList

        public static <U extends Unit<U>,​S extends FloatScalarInterface<U,​S>> FloatVectorData instantiateList​(List<S> valueList,
                                                                                                                          StorageType storageType)
        Instantiate a FloatVectorData with the right data type.
        Type Parameters:
        U - the unit type
        S - the corresponding scalar type
        Parameters:
        valueList - List<? extends FloatScalarInterface>; the FloatScalar values to store
        storageType - StorageType; the data type to use
        Returns:
        FloatVectorData; the FloatVectorData with the right data type
        Throws:
        NullPointerException - when values is null, or storageType is null
      • instantiate

        public static FloatVectorData instantiate​(SortedMap<Integer,​Float> valueMap,
                                                  int length,
                                                  Scale scale,
                                                  StorageType storageType)
                                           throws ValueRuntimeException
        Instantiate a FloatVectorData with the right data type.
        Parameters:
        valueMap - SortedMap<Integer,Float>; the FloatScalar values to store
        length - int; the length of the vector to pad with 0 after last entry in map
        scale - Scale; the scale of the unit to use for conversion to SI
        storageType - StorageType; the data type to use
        Returns:
        FloatVectorData; the FloatVectorData with the right data type
        Throws:
        ValueRuntimeException - when length < 0
        NullPointerException - when values is null, or storageType is null
      • instantiateMap

        public static <U extends Unit<U>,​S extends FloatScalarInterface<U,​S>> FloatVectorData instantiateMap​(SortedMap<Integer,​S> values,
                                                                                                                         int length,
                                                                                                                         StorageType storageType)
                                                                                                                  throws ValueRuntimeException
        Instantiate a FloatVectorData with the right data type.
        Type Parameters:
        U - the unit type
        S - the scalar type to use
        Parameters:
        values - SortedMap<Integer,S>; the FloatScalar values to store
        length - int; the length of the vector to pad with 0 after last entry in map
        storageType - StorageType; the data type to use
        Returns:
        FloatVectorData; the FloatVectorData with the right data type
        Throws:
        NullPointerException - when values is null, or storageType is null
        ValueRuntimeException - when length < 0
      • size

        public abstract int size()
        Retrieve the size of the vector.
        Returns:
        int; the size of the vector
      • toDense

        public abstract FloatVectorDataDense toDense()
        Return the densely stored equivalent of this data.
        Returns:
        FloatVectorDataDense; the dense transformation of this data
      • toSparse

        public abstract FloatVectorDataSparse toSparse()
        Return the sparsely stored equivalent of this data.
        Returns:
        FloatVectorDataSparse; the sparse transformation of this data
      • getSI

        public abstract float getSI​(int index)
        Retrieve the SI value of one element of this data.
        Parameters:
        index - int; the index to get the value for
        Returns:
        the value at the index
      • setSI

        public abstract void setSI​(int index,
                                   float valueSI)
        Sets a value at the index in the vector.
        Parameters:
        index - int; the index to set the value for
        valueSI - float; the value at the index
      • zSum

        public final float zSum()
        Compute and return the sum of all values.
        Returns:
        double; the sum of the values of all cells
      • getDenseVectorSI

        public abstract float[] getDenseVectorSI()
        Create and return a dense copy of the data.
        Returns:
        float[]; a safe copy of VectorSI
      • assign

        public abstract FloatVectorData assign​(FloatFunction floatFunction)
        Apply an operation to each cell.
        Parameters:
        floatFunction - FloatFunction; the operation to apply
        Returns:
        FloatVectorData; this (modified) float vector data object
      • assign

        abstract FloatVectorData assign​(FloatFunction2 floatFunction2,
                                        FloatVectorData right)
                                 throws ValueRuntimeException
        Apply a binary operation on a cell by cell basis.
        Parameters:
        floatFunction2 - FloatFunction2; the binary operation to apply
        right - FloatVectorData; the right operand for the binary operation
        Returns:
        DoubleMatrixData; this (modified) float vector data object
        Throws:
        ValueRuntimeException - when the sizes of the vectors do not match
      • plus

        public abstract FloatVectorData plus​(FloatVectorData right)
                                      throws ValueRuntimeException
        Add two vectors on a cell-by-cell basis. If both vectors are sparse, a sparse vector is returned, otherwise a dense vector is returned.
        Parameters:
        right - FloatVectorData; the other data object to add
        Returns:
        FloatVectorData; the sum of this data object and the other data object
        Throws:
        ValueRuntimeException - if vectors have different lengths
      • incrementBy

        public final FloatVectorData incrementBy​(FloatVectorData right)
                                          throws ValueRuntimeException
        Add a vector to this vector on a cell-by-cell basis. The type of vector (sparse, dense) stays the same.
        Parameters:
        right - FloatVectorData; the other data object to add
        Returns:
        FloatVectorData; this modified float vector data object
        Throws:
        ValueRuntimeException - if vectors have different lengths
      • minus

        public abstract FloatVectorData minus​(FloatVectorData right)
                                       throws ValueRuntimeException
        Subtract two vectors on a cell-by-cell basis. If both vectors are sparse, a sparse vector is returned, otherwise a dense vector is returned.
        Parameters:
        right - FloatVectorData; the other data object to subtract
        Returns:
        FloatVectorData; the difference of this data object and the other data object
        Throws:
        ValueRuntimeException - if vectors have different lengths
      • decrementBy

        public final FloatVectorData decrementBy​(FloatVectorData right)
                                          throws ValueRuntimeException
        Subtract a vector from this vector on a cell-by-cell basis. The type of vector (sparse, dense) stays the same.
        Parameters:
        right - FloatVectorData; the other data object to subtract
        Returns:
        FloatVectorData; this modified float vector data object
        Throws:
        ValueRuntimeException - if vectors have different lengths
      • times

        public abstract FloatVectorData times​(FloatVectorData right)
                                       throws ValueRuntimeException
        Multiply two vector on a cell-by-cell basis. If both vectors are dense, a dense vector is returned, otherwise a sparse vector is returned.
        Parameters:
        right - FloatVectorData; the other data object to multiply with
        Returns:
        FloatVectorData; a new double vector data store holding the result of the multiplications
        Throws:
        ValueRuntimeException - if vectors have different lengths
      • multiplyBy

        public final FloatVectorData multiplyBy​(FloatVectorData right)
                                         throws ValueRuntimeException
        Multiply a vector with the values of another vector on a cell-by-cell basis. The type of vector (sparse, dense) stays the same.
        Parameters:
        right - FloatVectorData; the other data object to multiply with
        Returns:
        FloatVectorData; this modified float vector data store
        Throws:
        ValueRuntimeException - if vectors have different lengths
      • divide

        public abstract FloatVectorData divide​(FloatVectorData right)
                                        throws ValueRuntimeException
        Divide two vectors on a cell-by-cell basis. If this vector is sparse and right is dense, a sparse vector is returned, otherwise a dense vector is returned.
        Parameters:
        right - FloatVectorData; the other data object to divide by
        Returns:
        FloatVectorData; the ratios of the values of this data object and the other data object
        Throws:
        ValueRuntimeException - if vectors have different lengths
      • divideBy

        public final FloatVectorData divideBy​(FloatVectorData right)
                                       throws ValueRuntimeException
        Divide the values of a vector by the values of another vector on a cell-by-cell basis. The type of vector (sparse, dense) stays the same.
        Parameters:
        right - FloatVectorData; the other data object to divide by
        Returns:
        FloatVectorData; this modified float vector data store
        Throws:
        ValueRuntimeException - if vectors have different lengths
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • compareDenseVectorWithSparseVector

        protected boolean compareDenseVectorWithSparseVector​(FloatVectorDataDense dm,
                                                             FloatVectorDataSparse sm)
        Compare contents of a dense and a sparse vector.
        Parameters:
        dm - FloatVectorDataDense; the dense vector
        sm - FloatVectorDataSparse; the sparse vector
        Returns:
        boolean; true if the contents are equal