Package org.la4j

Class Vectors


  • public final class Vectors
    extends java.lang.Object
    • Constructor Detail

      • Vectors

        public Vectors()
    • Method Detail

      • asConstFunction

        public static VectorFunction asConstFunction​(double arg)
        Creates a const function that evaluates it's argument to given value.
        Parameters:
        arg - a const value
        Returns:
        a closure object that does _
      • asPlusFunction

        public static VectorFunction asPlusFunction​(double arg)
        Creates a plus function that adds given value to it's argument.
        Parameters:
        arg - a value to be added to function's argument
        Returns:
        a closure object that does _ + _
      • asMinusFunction

        public static VectorFunction asMinusFunction​(double arg)
        Creates a minus function that subtracts given value from it's argument.
        Parameters:
        arg - a value to be subtracted from function's argument
        Returns:
        a closure that does _ - _
      • asMulFunction

        public static VectorFunction asMulFunction​(double arg)
        Creates a mul function that multiplies given value by it's argument.
        Parameters:
        arg - a value to be multiplied by function's argument
        Returns:
        a closure that does _ * _
      • asDivFunction

        public static VectorFunction asDivFunction​(double arg)
        Creates a div function that divides it's argument by given value.
        Parameters:
        arg - a divisor value
        Returns:
        a closure that does _ / _
      • asModFunction

        public static VectorFunction asModFunction​(double arg)
        Creates a mod function that calculates the modulus of it's argument and given value.
        Parameters:
        arg - a divisor value
        Returns:
        a closure that does _ % _
      • asSumAccumulator

        public static VectorAccumulator asSumAccumulator​(double neutral)
        Creates a sum vector accumulator that calculates the sum of all elements in the vector.
        Parameters:
        neutral - the neutral value
        Returns:
        a sum accumulator
      • asProductAccumulator

        public static VectorAccumulator asProductAccumulator​(double neutral)
        Creates a product vector accumulator that calculates the product of all elements in the vector.
        Parameters:
        neutral - the neutral value
        Returns:
        a product accumulator
      • mkMinAccumulator

        public static VectorAccumulator mkMinAccumulator()
        Makes a minimum vector accumulator that accumulates the minimum across vector elements.
        Returns:
        a minimum vector accumulator
      • mkMaxAccumulator

        public static VectorAccumulator mkMaxAccumulator()
        Makes a maximum vector accumulator that accumulates the maximum across vector elements.
        Returns:
        a maximum vector accumulator
      • asSumFunctionAccumulator

        public static VectorAccumulator asSumFunctionAccumulator​(double neutral,
                                                                 VectorFunction function)
        Creates a sum function accumulator, that calculates the sum of all elements in the vector after applying given function to each of them.
        Parameters:
        neutral - the neutral value
        function - the vector function
        Returns:
        a sum function accumulator
      • asProductFunctionAccumulator

        public static VectorAccumulator asProductFunctionAccumulator​(double neutral,
                                                                     VectorFunction function)
        Creates a product function accumulator, that calculates the product of all elements in the vector after applying given function to each of them.
        Parameters:
        neutral - the neutral value
        function - the vector function
        Returns:
        a product function accumulator
      • asAccumulatorProcedure

        public static VectorProcedure asAccumulatorProcedure​(VectorAccumulator accumulator)
        Creates an accumulator procedure that adapts a vector accumulator for procedure interface. This is useful for reusing a single accumulator for multiple fold operations in multiple vectors.
        Parameters:
        accumulator - the vector accumulator
        Returns:
        an accumulator procedure