Class ListMath


  • public class ListMath
    extends Object
    Math operations defined on lists of numbers.
    Author:
    carcassi, Mark Davis (NSCL/FRIB)
    • Method Detail

      • rescale

        public static ListDouble rescale​(ListNumber data,
                                         double factor,
                                         double offset)
        Performs a linear transformation on the data.
        Parameters:
        data - A list of numbers
        factor - The multiplicative constant
        offset - The additive constant
        Returns:
        result[x] = data[x] * factor + offset
      • inverseRescale

        public static ListDouble inverseRescale​(ListNumber data,
                                                double numerator,
                                                double offset)
        Performs a linear transformation on inverse value of each number in a list.
        Parameters:
        data - The list of numbers to divide the numerator by
        numerator - The numerator for each division
        offset - The additive constant
        Returns:
        result[x] = numerator / data[x] + offset
      • pow

        public static ListDouble pow​(ListNumber data,
                                     double expon)
        Raises each value in a list to the same power.
        Parameters:
        data - The list of numbers to raise to a power
        expon - The power to raise each number in the list to
        Returns:
        result[x] = data[x] ** expon
      • pow

        public static ListDouble pow​(double base,
                                     ListNumber expons)
        Raises a value to the power of each value in a list.
        Parameters:
        base - The value to raise to each power
        expons - The list of exponents to raise the base value to
        Returns:
        result[x] = base ** expons[x]
      • add

        public static ListDouble add​(ListNumber data,
                                     double offset)
        Returns a new list where all elements are added to a constant.
        Parameters:
        data - a list of number
        offset - the additive constant
        Returns:
        result[x] = data[x] + offset
      • add

        public static ListDouble add​(ListNumber data1,
                                     ListNumber data2)
        Returns a list where each element is the sum of the elements of the two lists at the same index. The lists have to match in size.
        Parameters:
        data1 - a list of numbers
        data2 - another list of numbers
        Returns:
        result[x] = data1[x] + data2[x]
      • subtract

        public static ListDouble subtract​(ListNumber data1,
                                          ListNumber data2)
        Returns a list where each element is the difference of the elements of the two lists at the same index. The lists have to match in size.
        Parameters:
        data1 - a list of numbers
        data2 - another list of numbers
        Returns:
        result[x] = data1[x] - data2[x]
      • multiply

        public static ListDouble multiply​(ListNumber data1,
                                          ListNumber data2)
        Returns a list where each element is the product of the elements of the two lists at the same index. The lists have to match in size.
        Parameters:
        data1 - a list of numbers
        data2 - another list of numbers
        Returns:
        result[x] = data1[x] * data2[x]
      • divide

        public static ListDouble divide​(ListNumber data1,
                                        ListNumber data2)
        Returns a list where each element is the division of the elements of the two lists at the same index. The lists have to match in size.
        Parameters:
        data1 - a list of numbers
        data2 - another list of numbers
        Returns:
        result[x] = data1[x] / data2[x]
      • dft

        public static List<ListNumber> dft​(ListNumber x,
                                           ListNumber y)
        XXX: This is just a prototype
        Parameters:
        x - real part
        y - imaginary part
        Returns:
        the real and imaginary part of the transform