Class FunctionUtils


  • public final class FunctionUtils
    extends Object
    A collection of basic useful maths functions.
    • Method Detail

      • square

        @Deprecated
        public static double square​(double x)
        Deprecated.
        Returns the square of a number.
        Parameters:
        x - the number to square
        Returns:
        x*x
      • cube

        @Deprecated
        public static double cube​(double x)
        Deprecated.
        Returns the cube of a number.
        Parameters:
        x - the number to cube
        Returns:
        x*x*x
      • toTensorIndex

        public static int toTensorIndex​(int[] indices,
                                        int[] dimensions)
      • fromTensorIndex

        public static int[] fromTensorIndex​(int index,
                                            int[] dimensions)
      • unique

        public static double[] unique​(double[] in)
        Same behaviour as mathlab unique.
        Parameters:
        in - the input array
        Returns:
        a sorted array with no duplicates values
      • unique

        public static int[] unique​(int[] in)
        Same behaviour as mathlab unique.
        Parameters:
        in - the input array
        Returns:
        a sorted array with no duplicates values
      • getLowerBoundIndex

        public static int getLowerBoundIndex​(DoubleArray set,
                                             double value)
        Find the index of a sorted set that is less than or equal to a given value. If the given value is lower than the lowest member (i.e. the first) of the set, zero is returned. This uses Arrays.binarySearch.
        Parameters:
        set - a sorted array of numbers.
        value - the value to search for
        Returns:
        the index in the array