Class CompositeDoubleArrayOperation

  • All Implemented Interfaces:
    DoubleArrayOperation

    public class CompositeDoubleArrayOperation
    extends Object
    implements DoubleArrayOperation
    It is desirable to have multiple implementations and switch between them for, e.g., performance reason.
    • Constructor Detail

      • CompositeDoubleArrayOperation

        public CompositeDoubleArrayOperation​(int arrayLengthThreshold,
                                             DoubleArrayOperation impl1,
                                             DoubleArrayOperation impl2)
        Construct a CompositeDoubleArrayOperation that chooses an implementation by array length.
        Parameters:
        arrayLengthThreshold - the array length threshold to switch implementation
        impl1 - implementation 1
        impl2 - implementation 2
    • Method Detail

      • add

        public double[] add​(double[] arr1,
                            double[] arr2)
        Description copied from interface: DoubleArrayOperation
        Add two double arrays, entry-by-entry.
        Specified by:
        add in interface DoubleArrayOperation
        Parameters:
        arr1 - an array double[]
        arr2 - an array double[]
        Returns:
        the sum of the two arrays
      • minus

        public double[] minus​(double[] arr1,
                              double[] arr2)
        Description copied from interface: DoubleArrayOperation
        Subtract one double array from another, entry-by-entry.
        Specified by:
        minus in interface DoubleArrayOperation
        Parameters:
        arr1 - an array double[]
        arr2 - an array double[]
        Returns:
        the difference of the two arrays
      • multiply

        public double[] multiply​(double[] arr1,
                                 double[] arr2)
        Description copied from interface: DoubleArrayOperation
        Multiply one double array to another, entry-by-entry.
        Specified by:
        multiply in interface DoubleArrayOperation
        Parameters:
        arr1 - an array double[]
        arr2 - an array double[]
        Returns:
        the product of the two arrays
      • divide

        public double[] divide​(double[] arr1,
                               double[] arr2)
        Description copied from interface: DoubleArrayOperation
        Divide one double array by another, entry-by-entry.
        Specified by:
        divide in interface DoubleArrayOperation
        Parameters:
        arr1 - an array double[]
        arr2 - an array double[]
        Returns:
        the quotient array
      • scaled

        public double[] scaled​(double[] arr,
                               double c)
        Description copied from interface: DoubleArrayOperation
        Scale each entry of a double array.
        Specified by:
        scaled in interface DoubleArrayOperation
        Parameters:
        arr - an array double[]
        c - a scaling constant
        Returns:
        the scaled array