Package ca.phon.math

Class MathUtils

java.lang.Object
ca.phon.math.MathUtils

public class MathUtils extends Object
Math helper methods.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    applyAsymetricalExponentialWindow(double[] samples, int nSamples, double asymFact)
    This inplace function apllyes an Asynchron Expoantion Window function to the given array.
    static void
    applyBlackmanWindow(double[] samples, int N)
    This inplace function applyes a Blackman window function to the gives array.
    static void
    applyCosineWindow(double[] samples, int N)
    This inplace function applyes an Cosine window function to the gives array.
    static void
    applyGaussWindow(double[] samples, int N)
    This inplace function applyes an Gauss window function to the gives array.
    static void
    applyHammingWindow(double[] data, int len)
    This inplace function applyes an Hamming window function to the gives array.
    static void
    applyHannWindow(double[] samples, int N)
    This inplace function applyes an Hann window function to the gives array.
    static void
    applyTriangleWindow(double[] samples, int N)
    This inplace function applyes a Tringle window function to the gives array.
    static void
    applyWelchWindow(double[] samples, int N)
    This inplace function applyes a Welch window function to the gives array.
    static boolean
    isPowerOfTwo(int x)
    Is the given number a power of two.
    static double
    lin2log(double lin)
     
    static int
    Return next power of two.

    Methods inherited from class java.lang.Object

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

    • MathUtils

      public MathUtils()
  • Method Details

    • isPowerOfTwo

      public static boolean isPowerOfTwo(int x)
      Is the given number a power of two.
    • nextPowerOfTwo

      public static int nextPowerOfTwo(int v)
      Return next power of two.
    • applyHammingWindow

      public static void applyHammingWindow(double[] data, int len)
      This inplace function applyes an Hamming window function to the gives array. The Hamming window function is per definition delared as: w(n) = 25/46 - 21/46*cos(2*Pi*n/(N-1))
      Parameters:
      data - A pointer to the input samples. Note that the window function is applyed in place which means that no further vector is allocated or given back.
      len - The number of input samples.
    • applyHannWindow

      public static void applyHannWindow(double[] samples, int N)
      This inplace function applyes an Hann window function to the gives array. The Hann window function is per definition delared as: w(n) = 0.5*(1-cos(2*Pi*n/(N-1)))
      Parameters:
      sampels - A pointer to the input samples. Note that the window function is applyed in place which means that no further vector is allocated or given back.
      nSamples - The number of input samples.
    • applyBlackmanWindow

      public static void applyBlackmanWindow(double[] samples, int N)
      This inplace function applyes a Blackman window function to the gives array.
      Parameters:
      Sampels - A pointer to the input samples. Note that the window function is applyed in place which means that no further vector is allocated or given back.
      nSamples - The number of input samples.
    • applyTriangleWindow

      public static void applyTriangleWindow(double[] samples, int N)
      This inplace function applyes a Tringle window function to the gives array.
      Parameters:
      Sampels - A pointer to the input samples. Note that the window function is applyed in place which means that no further vector is allocated or given back.
      nSamples - The number of input samples.
    • applyWelchWindow

      public static void applyWelchWindow(double[] samples, int N)
      This inplace function applyes a Welch window function to the gives array.
      Parameters:
      Sampels - A pointer to the input samples. Note that the window function is applyed in place which means that no further vector is allocated or given back.
      nSamples - The number of input samples.
    • applyGaussWindow

      public static void applyGaussWindow(double[] samples, int N)
      This inplace function applyes an Gauss window function to the gives array.
      Parameters:
      sampels - A pointer to the input samples. Note that the window function is applyed in place which means that no further vector is allocated or given back.
      nSamples - The number of input samples.
    • applyCosineWindow

      public static void applyCosineWindow(double[] samples, int N)
      This inplace function applyes an Cosine window function to the gives array.
      Parameters:
      sampels - A pointer to the input samples. Note that the window function is applyed in place which means that no further vector is allocated or given back.
      nSamples - The number of input samples.
    • applyAsymetricalExponentialWindow

      public static void applyAsymetricalExponentialWindow(double[] samples, int nSamples, double asymFact)
      This inplace function apllyes an Asynchron Expoantion Window function to the given array.
      Parameters:
      samples - A Pointer to the input samples. Note that the window function is applyed in place which means that no further vector is allocated or given back.
      nSamples - The number of input sampels.
      asymFact - This factor influences the unsymetrical side relation from one side to another. The value value should be more/less in the intervall [0.8...1.5]. A typical value is 1.0
    • lin2log

      public static double lin2log(double lin)