Package de.gsi.math

Class ArrayMath


  • public final class ArrayMath
    extends java.lang.Object
    some double array convenience methods
    Author:
    rstein
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ArrayMath.FilterType  
    • Constructor Summary

      Constructors 
      Constructor Description
      ArrayMath()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double[] add​(double[] in, double add)  
      static double[] add​(double[] in, double[] add)  
      static double[] addInPlace​(double[] in, double value)  
      static double[] addInPlace​(double[] in, double[] value)  
      static double[] calculateFilterParameters​(double cutoffFraction, ArrayMath.FilterType filterType, double rippleP, double numberOfPoles, int iteration)
      calculate 2nd-order filter with Butterworth (rippleP=0) or Chebychev filter response (rippleP>0) N.B.
      static double[] decibel​(double[] in)  
      static double[] decibelInPlace​(double[] in)  
      static double[] divide​(double[] in, double divisor)  
      static double[] divide​(double[] in, double[] divisor)  
      static double[] divideInPlace​(double[] in, double divisor)  
      static double[] divideInPlace​(double[] in, double[] divisor)  
      static double[] filterSignal​(double[] signal, double cutoffFraction, double filterOrder, ArrayMath.FilterType filterType, double ripplePercent)
      filter from: "The Scientist and Engineer's Guide to DSP" Chapter 20
      static double[] multiply​(double[] in, double multiplicator)  
      static double[] multiply​(double[] in, double[] multiplicator)  
      static double[] multiplyInPlace​(double[] in, double multiplicator)  
      static double[] multiplyInPlace​(double[] in, double[] multiplicator)  
      static double[] sqr​(double[] in)  
      static double[] sqrInPlace​(double[] in)  
      static double[] sqrt​(double[] in)  
      static double[] sqrtInPlace​(double[] in)  
      static double[] subtract​(double[] in, double value)  
      static double[] subtract​(double[] in, double[] value)  
      static double[] subtractInPlace​(double[] in, double value)  
      static double[] subtractInPlace​(double[] in, double[] value)  
      static double[] tenLog10​(double[] in)  
      static double[] tenLog10InPlace​(double[] in)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ArrayMath

        public ArrayMath()
    • Method Detail

      • add

        public static double[] add​(double[] in,
                                   double add)
      • add

        public static double[] add​(double[] in,
                                   double[] add)
      • addInPlace

        public static double[] addInPlace​(double[] in,
                                          double value)
      • addInPlace

        public static double[] addInPlace​(double[] in,
                                          double[] value)
      • calculateFilterParameters

        public static double[] calculateFilterParameters​(double cutoffFraction,
                                                         ArrayMath.FilterType filterType,
                                                         double rippleP,
                                                         double numberOfPoles,
                                                         int iteration)
        calculate 2nd-order filter with Butterworth (rippleP=0) or Chebychev filter response (rippleP>0) N.B. numerically validated against data set examples in Table 20-6 http://www.dspguide.com/ch20/4.htm
        Parameters:
        cutoffFraction - fractional cut-off
        filterType - LOW_PASS or HIGH_PASS
        rippleP - >0 -> Chebychev design-ripple in percent in the pass-band
        numberOfPoles - number of poles (if combined with 2*n filter stages)
        iteration - (whether this is the i-th filter in the chain)
        Returns:
        array of [A0, A1, A2, B1, B2]
      • decibel

        public static double[] decibel​(double[] in)
      • decibelInPlace

        public static double[] decibelInPlace​(double[] in)
      • divide

        public static double[] divide​(double[] in,
                                      double divisor)
      • divide

        public static double[] divide​(double[] in,
                                      double[] divisor)
      • divideInPlace

        public static double[] divideInPlace​(double[] in,
                                             double divisor)
      • divideInPlace

        public static double[] divideInPlace​(double[] in,
                                             double[] divisor)
      • filterSignal

        public static double[] filterSignal​(double[] signal,
                                            double cutoffFraction,
                                            double filterOrder,
                                            ArrayMath.FilterType filterType,
                                            double ripplePercent)
        filter from: "The Scientist and Engineer's Guide to DSP" Chapter 20
        Parameters:
        signal - input signal
        cutoffFraction - cutoffFreq must be smaller than half the samplerate
        filterOrder - can be between 2 and 20
        filterType - 0: lowPass 1: highPass
        ripplePercent - ripplePercent is amount of ripple in Chebyshev filter (0-29) (ripplePercent == 0 -> Butterworth)
        Returns:
        filtered output signal
      • multiply

        public static double[] multiply​(double[] in,
                                        double multiplicator)
      • multiply

        public static double[] multiply​(double[] in,
                                        double[] multiplicator)
      • multiplyInPlace

        public static double[] multiplyInPlace​(double[] in,
                                               double multiplicator)
      • multiplyInPlace

        public static double[] multiplyInPlace​(double[] in,
                                               double[] multiplicator)
      • sqr

        public static double[] sqr​(double[] in)
      • sqrInPlace

        public static double[] sqrInPlace​(double[] in)
      • sqrt

        public static double[] sqrt​(double[] in)
      • sqrtInPlace

        public static double[] sqrtInPlace​(double[] in)
      • subtract

        public static double[] subtract​(double[] in,
                                        double value)
      • subtract

        public static double[] subtract​(double[] in,
                                        double[] value)
      • subtractInPlace

        public static double[] subtractInPlace​(double[] in,
                                               double value)
      • subtractInPlace

        public static double[] subtractInPlace​(double[] in,
                                               double[] value)
      • tenLog10

        public static double[] tenLog10​(double[] in)
      • tenLog10InPlace

        public static double[] tenLog10InPlace​(double[] in)