Package samer.maths

Class Mathx

  • java.lang.Object
    • samer.maths.Mathx


  • public class Mathx
    extends java.lang.Object
    A Class full of static functions, mainly for manipulating double arrays.
    • Constructor Summary

      Constructors 
      Constructor and Description
      Mathx() 
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      static void add(double[] x, double y)
      add scalar in place y: x[i]+=y for all i
      static void add(double[] x, double[] y)
      add in place y: x[i]+=y[i] for all i
      static void add(double[] x, double[] y, double[] z)
      add two arrays: x[i]=y[i]+z[i] for all i
      void add(double[] a, Generator g)
      increment each element of a by a value extracted from g
      static void add(int n, double[] x, double[] y) 
      static int argmax(double[] x)
      return index of supremum of elements in x
      static double atanh(double t) 
      static double[] copy(double[] a)
      return copy a in new array
      static void copy(double[] a, double[] b)
      copy a to b: b[i]=a[i]
      static double cosh(double t) 
      static void div(double[] x, double[] y)
      elementwise divide in place: x[i] /=y[i]
      static void div(double[] x, double[] y, double[] z)
      elementwise divide: x[i]=y[i]/z[i]
      static double dot(double[] a, double[] b)
      return dot product of a and b: sum_i a[i]*b[i]
      double[] doubleArray(int n) 
      static void index(double[] a)
      set each element using a function of its index
      static void indexFr(double[] a) 
      static void log(double[] x)
      log in place
      static double max(double[] x)
      return maximum element of x
      static double min(double[] x)
      return minimum element of x
      static void mul(double[] x, double k)
      multiply by scalar in place: x[i] *=k
      static void mul(double[] x, double[] y)
      elementwise multiply in place: x[i] *=y[i]
      static void mul(double[] y, double[][] A, double[] x)
      matrix multiplication: y[i] = sum_j A[i][j] x[j]
      static void mul(double[] x, double[] y, double k)
      scalar multiply x[i] = k*y[i]
      static void mul(double[] x, double[] y, double[] z)
      elementwise multiply x[i] =y[i]*z[i]
      static void mul(int n, double[] x, double k) 
      static void muladd(int n, double[] x, double[] y, double k) 
      static void negate(double[] x)
      negate in place
      static void negate(double[] x, double[] y)
      negate to y: x[i]=y[i] for all i
      static double norm2(double[] a)
      return 2-norm of a: sum_i a[i]*a[i]
      static double norm2(int n, double[] a) 
      static double prod(double[] x)
      return product of elements in x
      static void set(double[] a, Generator g)
      set each elements of a by extracting successive values from g
      static void setAll(double[] x, double a)
      set all to given value
      static double sinh(double t) 
      static void sub(double[] x, double y)
      subtract scalar in place y: x[i]-=y for all i
      static void sub(double[] x, double[] y)
      subtract in place y: x[i]-=y[i] for all i
      static void sub(double[] x, double[] y, double[] z)
      subtract: x[i]=y[i]-z[i] for all i
      static void sub(int n, double[] x, double[] y) 
      static void sub(int n, double[] x, double[] y, double[] z) 
      static double sum(double[] x)
      return sum of elements in x
      static void table(double[] a, Function f)
      set each element using a function of its index
      static double tanh(double t) 
      static void zero(double[] x)
      set to zeros
      • Methods inherited from class java.lang.Object

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

      • Mathx

        public Mathx()
    • Method Detail

      • doubleArray

        public double[] doubleArray(int n)
      • zero

        public static void zero(double[] x)
        set to zeros
      • setAll

        public static void setAll(double[] x,
                                  double a)
        set all to given value
      • log

        public static void log(double[] x)
        log in place
      • negate

        public static void negate(double[] x)
        negate in place
      • negate

        public static void negate(double[] x,
                                  double[] y)
        negate to y: x[i]=y[i] for all i
      • sub

        public static void sub(double[] x,
                               double[] y,
                               double[] z)
        subtract: x[i]=y[i]-z[i] for all i
      • sub

        public static void sub(int n,
                               double[] x,
                               double[] y,
                               double[] z)
      • sub

        public static void sub(double[] x,
                               double[] y)
        subtract in place y: x[i]-=y[i] for all i
      • sub

        public static void sub(int n,
                               double[] x,
                               double[] y)
      • sub

        public static void sub(double[] x,
                               double y)
        subtract scalar in place y: x[i]-=y for all i
      • add

        public static void add(double[] x,
                               double[] y,
                               double[] z)
        add two arrays: x[i]=y[i]+z[i] for all i
      • add

        public static void add(double[] x,
                               double[] y)
        add in place y: x[i]+=y[i] for all i
      • add

        public static void add(int n,
                               double[] x,
                               double[] y)
      • add

        public static void add(double[] x,
                               double y)
        add scalar in place y: x[i]+=y for all i
      • sum

        public static double sum(double[] x)
        return sum of elements in x
      • muladd

        public static void muladd(int n,
                                  double[] x,
                                  double[] y,
                                  double k)
      • prod

        public static double prod(double[] x)
        return product of elements in x
      • mul

        public static void mul(double[] x,
                               double k)
        multiply by scalar in place: x[i] *=k
      • mul

        public static void mul(int n,
                               double[] x,
                               double k)
      • mul

        public static void mul(double[] x,
                               double[] y,
                               double k)
        scalar multiply x[i] = k*y[i]
      • mul

        public static void mul(double[] x,
                               double[] y)
        elementwise multiply in place: x[i] *=y[i]
      • mul

        public static void mul(double[] x,
                               double[] y,
                               double[] z)
        elementwise multiply x[i] =y[i]*z[i]
      • div

        public static void div(double[] x,
                               double[] y)
        elementwise divide in place: x[i] /=y[i]
      • div

        public static void div(double[] x,
                               double[] y,
                               double[] z)
        elementwise divide: x[i]=y[i]/z[i]
      • max

        public static double max(double[] x)
        return maximum element of x
      • min

        public static double min(double[] x)
        return minimum element of x
      • argmax

        public static int argmax(double[] x)
        return index of supremum of elements in x
      • dot

        public static double dot(double[] a,
                                 double[] b)
        return dot product of a and b: sum_i a[i]*b[i]
      • norm2

        public static double norm2(double[] a)
        return 2-norm of a: sum_i a[i]*a[i]
      • norm2

        public static double norm2(int n,
                                   double[] a)
      • copy

        public static void copy(double[] a,
                                double[] b)
        copy a to b: b[i]=a[i]
      • copy

        public static double[] copy(double[] a)
        return copy a in new array
      • tanh

        public static double tanh(double t)
      • atanh

        public static double atanh(double t)
      • cosh

        public static double cosh(double t)
      • sinh

        public static double sinh(double t)
      • mul

        public static void mul(double[] y,
                               double[][] A,
                               double[] x)
        matrix multiplication: y[i] = sum_j A[i][j] x[j]
      • set

        public static void set(double[] a,
                               Generator g)
        set each elements of a by extracting successive values from g
      • add

        public void add(double[] a,
                        Generator g)
        increment each element of a by a value extracted from g
      • index

        public static void index(double[] a)
        set each element using a function of its index
      • indexFr

        public static void indexFr(double[] a)
      • table

        public static void table(double[] a,
                                 Function f)
        set each element using a function of its index