Package jline.util

Class Maths

java.lang.Object
jline.util.Maths

public class Maths extends Object
Mathematical functions and utilities.
  • Constructor Details

    • Maths

      public Maths()
  • Method Details

    • softmin

      public static double softmin(double x, double y, double alpha)
      Softmin function.
      Parameters:
      x - first term to compare
      y - second term to compare
      alpha - softmin smoothing parameter
      Returns:
      Softmin function value
    • max

      public static double max(double x, double y)
      Returns the max of two numbers. If one of the two is NaN, it returns the other.
      Parameters:
      x - - the first number to be compared
      y - - the second number to be compared
      Returns:
      - the max between the two
    • min

      public static double min(double x, double y)
      Returns the min of two numbers. If one of the two is NaN, it returns the other.
      Parameters:
      x - - the first number to be compared
      y - - the second number to be compared
      Returns:
      - the min between the two
    • erf

      public static double erf(double x)
    • setRandomNumbersMatlab

      public static void setRandomNumbersMatlab(boolean matlab_style)
    • randomMatlabStyle

      public static boolean randomMatlabStyle()
    • setMatlabRandomSeed

      public static void setMatlabRandomSeed(long seed)
    • rand

      public static double rand()
    • randn

      public static double randn()
    • fact

      public static int fact(int n)
    • factln

      public static double factln(int n)
    • fact

      public static double fact(double n)
    • factln

      public static double factln(double n)
    • gammaFunction

      public static double gammaFunction(double x)
    • circul

      public static Matrix circul(int c)
    • circul

      public static Matrix circul(Matrix c)
    • hist

      public static Matrix hist(Matrix v, int minVal, int maxVal)
      Implementation of MATLAB "hist": puts elements of v into k bins
      Parameters:
      v - - vector of elements
      minVal - - lowest number in v
      maxVal - - highest number in v
      Returns:
      - vector containing number of elements in each bin
    • perms

      public static Matrix perms(Matrix vec)
    • uniquePerms

      public static Matrix uniquePerms(Matrix vec)
    • nchoosek

      public static double nchoosek(double n, double k)
    • nchoosek

      public static Matrix nchoosek(Matrix v, int k)
      Computes the combinations of the elements in v taken k at a time
      Parameters:
      v - - vector of elements
      k - - how many elements to pick at a time
      Returns:
      - the combinations of the elements in v taken k at a time
    • multinomialln

      public static double multinomialln(Matrix n)
    • multichoose

      public static Matrix multichoose(double n, double k)
    • multiChooseCon

      public static Matrix multiChooseCon(Matrix n, double S)
    • cumSum

      public static int[] cumSum(int[] ar)
      Cumulative sum of an array, where the value at each index of the result is the sum of all the previous values of the input.
      Parameters:
      ar - Array we want the cumulative sum of.
      Returns:
      New array that is the cumulative sum of the input.
    • cumSum

      public static double[] cumSum(double[] ar)
      Cumulative sum of an array, where the value at each index of the result is the sum of all the previous values of the input.
      Parameters:
      ar - Array we want the cumulative sum of.
      Returns:
      New array that is the cumulative sum of the input.
    • linspace

      public static double[] linspace(double start, double end, int num)
    • logspace

      public static double[] logspace(double min, double max, int n)
    • logspacei

      public static int[] logspacei(int start, int stop, int n)
      Generates an integer list of n logarithmically spaced values.
      Parameters:
      start - First element of array.
      stop - Last element of array.
      n - Number of values.
      Returns:
      Array of logarithmically spaced values.
    • transpose

      public static double[][] transpose(double[][] data)
      Transposes a 2D array of values.
      Parameters:
      data - 2D array to be transposed.
      Returns:
      New 2D array of transposed data.
    • elementAdd

      public static void elementAdd(int[] ar, int i)
      Helper method that adds an integer to every element of an integer array.
      Parameters:
      ar - Array to be added to.
      i - Integer to add.
    • nextPowerOfTwo

      protected static int nextPowerOfTwo(int x)
      Given an integer x input, find the next integer y greater than x such that y is a power of 2.
      Parameters:
      x - Input to find next power
      Returns:
      Closest integer greater than input that is a power of two.
    • grnmol

      public static Maths.simplexQuadResult grnmol(Function<double[],Double> f, double[][] V, int s, double tol)
      Grundmann-Moeller simplex integration
    • simplex_fun

      public static double simplex_fun(double[] x, Matrix L, Matrix N)
    • simplexquad

      public static Maths.simplexQuadResult simplexquad(Function<double[],Double> f, int n, int order, double tol)
    • logmeanexp

      public static double logmeanexp(Matrix x)
    • roots

      public static org.apache.commons.math3.complex.Complex[] roots(Matrix coefficients)
    • roots

      public static org.apache.commons.math3.complex.Complex[] roots(double[] coefficients)
    • num_grad_h_complex

      public static ComplexMatrix num_grad_h_complex(Matrix x0, double h, SerializableFunction<Matrix,ComplexMatrix> hfun)
    • num_grad_h

      public static Matrix num_grad_h(Matrix x0, double h, SerializableFunction<Matrix,Matrix> hfun)
    • sub2ind

      public static List<Integer> sub2ind(Matrix dims, Matrix row, Matrix col)
    • num_hess_h_complex

      public static ComplexMatrix num_hess_h_complex(Matrix x0, double h, SerializableFunction<Matrix,ComplexMatrix> hfun)
    • num_hess_h

      public static Matrix num_hess_h(Matrix x0, double h, SerializableFunction<Matrix,Matrix> hfun)
    • laplaceapprox_h_complex

      public static Maths.laplaceApproxComplexReturn laplaceapprox_h_complex(Matrix x0, SerializableFunction<Matrix,ComplexMatrix> h)
    • laplaceapprox_h

      public static Maths.laplaceApproxReturn laplaceapprox_h(Matrix x0, SerializableFunction<Matrix,Matrix> h)
    • main

      public static void main(String[] args)