Back to index

wims  3.65+svn20090927
Static Public Member Functions | Static Package Attributes | Static Private Member Functions | Static Private Attributes
org.javia.arity.MoreMath Class Reference
Inheritance diagram for org.javia.arity.MoreMath:
Inheritance graph
[legend]
Collaboration diagram for org.javia.arity.MoreMath:
Collaboration graph
[legend]

List of all members.

Static Public Member Functions

static final double asinh (double x)
static final double acosh (double x)
static final double atanh (double x)
static final double trunc (double x)
static final double gcd (double x, double y)
static final double lgamma (double x)
static final double factorial (double x)
static final double comb (double n, double k)
static final double perm (double n, double k)
static final double log2 (double x)
static final int intLog10 (double x)
static final double intExp10 (int exp)
static final double asinh (double x)
static final double acosh (double x)
static final double atanh (double x)
static final double trunc (double x)
static final double gcd (double x, double y)
static final double lgamma (double x)
static final double factorial (double x)
static final double comb (double n, double k)
static final double perm (double n, double k)
static final double log2 (double x)
static final int intLog10 (double x)
static final double intExp10 (int exp)
static final double atan (double x)
static final double atan (double x)
static final double asin (double x)
static final double asin (double x)
static final double acos (double x)
static final double acos (double x)
static final double exp (double x)
static final double exp (double x)
static final double log (double x)
static final double log (double x)
static final double sinh (double x)
static final double sinh (double x)
static final double cosh (double x)
static final double cosh (double x)
static final double tanh (double x)
static final double tanh (double x)
static final double cbrt (double x)
static final double cbrt (double x)
static final double pow (double x, double y)
static final double pow (double x, double y)
static final double log10 (double x)
static final double log10 (double x)

Static Package Attributes

static final double FACT []

Static Private Member Functions

static final boolean isPiMultiple (double x)
static final boolean isPiMultiple (double x)

Static Private Attributes

static final double LOG2E = 1.4426950408889634074

Detailed Description

Definition at line 20 of file MoreMath.java.


Member Function Documentation

static final double org.javia.arity.BaseMath.acos ( double  x) [inline, static, inherited]

Definition at line 30 of file BaseMath.java.

                                              {
        return Math.acos(x);
    }

Here is the caller graph for this function:

static final double org.javia.arity.BaseMath.acos ( double  x) [inline, static, inherited]

Definition at line 30 of file BaseMath.java.

                                              {
        return Math.acos(x);
    }
static final double org.javia.arity.MoreMath.acosh ( double  x) [inline, static]

Definition at line 27 of file MoreMath.java.

                                               {
        return log(x + x - 1/(Math.sqrt(x*x - 1) + x));
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static final double org.javia.arity.MoreMath.acosh ( double  x) [inline, static]

Definition at line 27 of file MoreMath.java.

                                               {
        return log(x + x - 1/(Math.sqrt(x*x - 1) + x));
    }

Here is the call graph for this function:

static final double org.javia.arity.BaseMath.asin ( double  x) [inline, static, inherited]

Definition at line 26 of file BaseMath.java.

                                              {
        return Math.asin(x);
    }

Here is the caller graph for this function:

static final double org.javia.arity.BaseMath.asin ( double  x) [inline, static, inherited]

Definition at line 26 of file BaseMath.java.

                                              {
        return Math.asin(x);
    }
static final double org.javia.arity.MoreMath.asinh ( double  x) [inline, static]

Definition at line 23 of file MoreMath.java.

                                               {
        return (x < 0) ? -asinh(-x) : log(x + x + 1/(Math.sqrt(x*x + 1) + x));
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static final double org.javia.arity.MoreMath.asinh ( double  x) [inline, static]

Definition at line 23 of file MoreMath.java.

                                               {
        return (x < 0) ? -asinh(-x) : log(x + x + 1/(Math.sqrt(x*x + 1) + x));
    }

Here is the call graph for this function:

static final double org.javia.arity.BaseMath.atan ( double  x) [inline, static, inherited]

Definition at line 22 of file BaseMath.java.

                                              {
        return Math.atan(x);
    }

Here is the caller graph for this function:

static final double org.javia.arity.BaseMath.atan ( double  x) [inline, static, inherited]

Definition at line 22 of file BaseMath.java.

                                              {
        return Math.atan(x);
    }
static final double org.javia.arity.MoreMath.atanh ( double  x) [inline, static]

Definition at line 31 of file MoreMath.java.

                                               {
        return (x < 0) ? -atanh(-x) : 0.5 * log(1. + (x + x)/(1 - x));
    }

Here is the call graph for this function:

static final double org.javia.arity.MoreMath.atanh ( double  x) [inline, static]

Definition at line 31 of file MoreMath.java.

                                               {
        return (x < 0) ? -atanh(-x) : 0.5 * log(1. + (x + x)/(1 - x));
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static final double org.javia.arity.BaseMath.cbrt ( double  x) [inline, static, inherited]

Definition at line 54 of file BaseMath.java.

                                              {
        return Math.cbrt(x);
    }

Here is the caller graph for this function:

static final double org.javia.arity.BaseMath.cbrt ( double  x) [inline, static, inherited]

Definition at line 54 of file BaseMath.java.

                                              {
        return Math.cbrt(x);
    }
static final double org.javia.arity.MoreMath.comb ( double  n,
double  k 
) [inline, static]

Definition at line 129 of file MoreMath.java.

                                                        {
        if (n < 0 || k < 0) { return Double.NaN; }
        if (n < k) { return 0; }
        if (Math.floor(n) == n && Math.floor(k) == k) {
            k = Math.min(k, n-k);
            if (n <= 170 && 12 < k && k <= 170) {
                return factorial(n)/factorial(k)/factorial(n-k);
            } else {
                double r = 1, diff = n-k;
                for (double i = k; i > .5 && r < Double.POSITIVE_INFINITY; --i) {
                    r *= (diff+i)/i;
                }
                return r;
            }
        } else {
            return exp(lgamma(n) - lgamma(k) - lgamma(n-k));
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static final double org.javia.arity.MoreMath.comb ( double  n,
double  k 
) [inline, static]

Definition at line 129 of file MoreMath.java.

                                                        {
        if (n < 0 || k < 0) { return Double.NaN; }
        if (n < k) { return 0; }
        if (Math.floor(n) == n && Math.floor(k) == k) {
            k = Math.min(k, n-k);
            if (n <= 170 && 12 < k && k <= 170) {
                return factorial(n)/factorial(k)/factorial(n-k);
            } else {
                double r = 1, diff = n-k;
                for (double i = k; i > .5 && r < Double.POSITIVE_INFINITY; --i) {
                    r *= (diff+i)/i;
                }
                return r;
            }
        } else {
            return exp(lgamma(n) - lgamma(k) - lgamma(n-k));
        }
    }

Here is the call graph for this function:

static final double org.javia.arity.BaseMath.cosh ( double  x) [inline, static, inherited]

Definition at line 46 of file BaseMath.java.

                                              {
        return Math.cosh(x);
    }

Here is the caller graph for this function:

static final double org.javia.arity.BaseMath.cosh ( double  x) [inline, static, inherited]

Definition at line 46 of file BaseMath.java.

                                              {
        return Math.cosh(x);
    }
static final double org.javia.arity.BaseMath.exp ( double  x) [inline, static, inherited]

Definition at line 34 of file BaseMath.java.

                                             {
        return Math.exp(x);
    }

Here is the caller graph for this function:

static final double org.javia.arity.BaseMath.exp ( double  x) [inline, static, inherited]

Definition at line 34 of file BaseMath.java.

                                             {
        return Math.exp(x);
    }
static final double org.javia.arity.MoreMath.factorial ( double  x) [inline, static]

Definition at line 106 of file MoreMath.java.

                                                   {
        if (x < 0) { // x <= -1 ?
            return Double.NaN;
        }
        if (x <= 170) {
            if (Math.floor(x) == x) {
                int n = (int)x;
                double extra = x;
                switch (n & 7) {
                case 7: extra *= --x;
                case 6: extra *= --x;
                case 5: extra *= --x;
                case 4: extra *= --x;
                case 3: extra *= --x;
                case 2: extra *= --x;
                case 1: return FACT[n >> 3] * extra;
                case 0: return FACT[n >> 3];
                }
            }
        }
        return exp(lgamma(x));
    }

Here is the call graph for this function:

static final double org.javia.arity.MoreMath.factorial ( double  x) [inline, static]

Definition at line 106 of file MoreMath.java.

                                                   {
        if (x < 0) { // x <= -1 ?
            return Double.NaN;
        }
        if (x <= 170) {
            if (Math.floor(x) == x) {
                int n = (int)x;
                double extra = x;
                switch (n & 7) {
                case 7: extra *= --x;
                case 6: extra *= --x;
                case 5: extra *= --x;
                case 4: extra *= --x;
                case 3: extra *= --x;
                case 2: extra *= --x;
                case 1: return FACT[n >> 3] * extra;
                case 0: return FACT[n >> 3];
                }
            }
        }
        return exp(lgamma(x));
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static final double org.javia.arity.MoreMath.gcd ( double  x,
double  y 
) [inline, static]

Definition at line 39 of file MoreMath.java.

                                                       {
        //double remainder = y;
        if (Double.isNaN(x) || Double.isNaN(y) ||
            Double.isInfinite(x) || Double.isInfinite(y)) {
            return Double.NaN;
        }
        x = Math.abs(x);
        y = Math.abs(y);
        double save;
        while (y > 1e-12) {
            save = y;
            y = x % y;
            x = save;
            //Log.log(y);
        } 
        return x > 1e-10 ? x : 0;
    }

Here is the caller graph for this function:

static final double org.javia.arity.MoreMath.gcd ( double  x,
double  y 
) [inline, static]

Definition at line 39 of file MoreMath.java.

                                                       {
        //double remainder = y;
        if (Double.isNaN(x) || Double.isNaN(y) ||
            Double.isInfinite(x) || Double.isInfinite(y)) {
            return Double.NaN;
        }
        x = Math.abs(x);
        y = Math.abs(y);
        double save;
        while (y > 1e-12) {
            save = y;
            y = x % y;
            x = save;
            //Log.log(y);
        } 
        return x > 1e-10 ? x : 0;
    }
static final double org.javia.arity.MoreMath.intExp10 ( int  exp) [inline, static]

Definition at line 180 of file MoreMath.java.

                                                 {
        return Double.parseDouble("1E" + exp);
    }

Here is the caller graph for this function:

static final double org.javia.arity.MoreMath.intExp10 ( int  exp) [inline, static]

Definition at line 180 of file MoreMath.java.

                                                 {
        return Double.parseDouble("1E" + exp);
    }
static final int org.javia.arity.MoreMath.intLog10 ( double  x) [inline, static]

Definition at line 174 of file MoreMath.java.

                                               {
        //an alternative implem is using a for loop.
        return (int)Math.floor(log10(x));
        //return (int)log10(x);
    }

Here is the call graph for this function:

static final int org.javia.arity.MoreMath.intLog10 ( double  x) [inline, static]

Definition at line 174 of file MoreMath.java.

                                               {
        //an alternative implem is using a for loop.
        return (int)Math.floor(log10(x));
        //return (int)log10(x);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static final boolean org.javia.arity.MoreMath.isPiMultiple ( double  x) [inline, static, private]

Definition at line 170 of file MoreMath.java.

                                                        {
        return x % Math.PI == 0;
    }
static final boolean org.javia.arity.MoreMath.isPiMultiple ( double  x) [inline, static, private]

Definition at line 170 of file MoreMath.java.

                                                        {
        return x % Math.PI == 0;
    }
static final double org.javia.arity.MoreMath.lgamma ( double  x) [inline, static]

Definition at line 57 of file MoreMath.java.

                                                {
        double tmp = x + 5.2421875; //== 607/128. + .5;
        return 0.9189385332046727418 //LN_SQRT2PI, ln(sqrt(2*pi))
            + log(
                  0.99999999999999709182 +
                  57.156235665862923517     / ++x +
                  -59.597960355475491248    / ++x +
                  14.136097974741747174     / ++x +
                  -0.49191381609762019978   / ++x +
                  .33994649984811888699e-4  / ++x +
                  .46523628927048575665e-4  / ++x +
                  -.98374475304879564677e-4 / ++x +
                  .15808870322491248884e-3  / ++x +
                  -.21026444172410488319e-3 / ++x +
                  .21743961811521264320e-3  / ++x +
                  -.16431810653676389022e-3 / ++x +
                  .84418223983852743293e-4  / ++x +
                  -.26190838401581408670e-4 / ++x +
                  .36899182659531622704e-5  / ++x
                  )
            + (tmp-4.7421875)*log(tmp) - tmp
            ;
    }

Here is the call graph for this function:

static final double org.javia.arity.MoreMath.lgamma ( double  x) [inline, static]

Definition at line 57 of file MoreMath.java.

                                                {
        double tmp = x + 5.2421875; //== 607/128. + .5;
        return 0.9189385332046727418 //LN_SQRT2PI, ln(sqrt(2*pi))
            + log(
                  0.99999999999999709182 +
                  57.156235665862923517     / ++x +
                  -59.597960355475491248    / ++x +
                  14.136097974741747174     / ++x +
                  -0.49191381609762019978   / ++x +
                  .33994649984811888699e-4  / ++x +
                  .46523628927048575665e-4  / ++x +
                  -.98374475304879564677e-4 / ++x +
                  .15808870322491248884e-3  / ++x +
                  -.21026444172410488319e-3 / ++x +
                  .21743961811521264320e-3  / ++x +
                  -.16431810653676389022e-3 / ++x +
                  .84418223983852743293e-4  / ++x +
                  -.26190838401581408670e-4 / ++x +
                  .36899182659531622704e-5  / ++x
                  )
            + (tmp-4.7421875)*log(tmp) - tmp
            ;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static final double org.javia.arity.BaseMath.log ( double  x) [inline, static, inherited]

Definition at line 38 of file BaseMath.java.

                                             {
        return Math.log(x);
    }
static final double org.javia.arity.BaseMath.log ( double  x) [inline, static, inherited]

Definition at line 38 of file BaseMath.java.

                                             {
        return Math.log(x);
    }

Here is the caller graph for this function:

static final double org.javia.arity.BaseMath.log10 ( double  x) [inline, static, inherited]

Definition at line 62 of file BaseMath.java.

                                               {
        return Math.log10(x);
    }
static final double org.javia.arity.BaseMath.log10 ( double  x) [inline, static, inherited]

Definition at line 62 of file BaseMath.java.

                                               {
        return Math.log10(x);
    }

Here is the caller graph for this function:

static final double org.javia.arity.MoreMath.log2 ( double  x) [inline, static]

Definition at line 166 of file MoreMath.java.

                                              {
        return log(x) * LOG2E;
    }

Here is the call graph for this function:

static final double org.javia.arity.MoreMath.log2 ( double  x) [inline, static]

Definition at line 166 of file MoreMath.java.

                                              {
        return log(x) * LOG2E;
    }

Here is the call graph for this function:

static final double org.javia.arity.MoreMath.perm ( double  n,
double  k 
) [inline, static]

Definition at line 148 of file MoreMath.java.

                                                        {
        if (n < 0 || k < 0) { return Double.NaN; }
        if (n < k) { return 0; }
        if (Math.floor(n) == n && Math.floor(k) == k) {
            if (n <= 170 && 10 < k && k <= 170) {
                return factorial(n)/factorial(n-k);
            } else {
                double r = 1, limit = n-k+.5;
                for (double i = n; i > limit && r < Double.POSITIVE_INFINITY; --i) {
                    r *= i;
                }
                return r;
            }
        } else {
            return exp(lgamma(n) - lgamma(n-k));
        }
    }

Here is the call graph for this function:

static final double org.javia.arity.MoreMath.perm ( double  n,
double  k 
) [inline, static]

Definition at line 148 of file MoreMath.java.

                                                        {
        if (n < 0 || k < 0) { return Double.NaN; }
        if (n < k) { return 0; }
        if (Math.floor(n) == n && Math.floor(k) == k) {
            if (n <= 170 && 10 < k && k <= 170) {
                return factorial(n)/factorial(n-k);
            } else {
                double r = 1, limit = n-k+.5;
                for (double i = n; i > limit && r < Double.POSITIVE_INFINITY; --i) {
                    r *= i;
                }
                return r;
            }
        } else {
            return exp(lgamma(n) - lgamma(n-k));
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static final double org.javia.arity.BaseMath.pow ( double  x,
double  y 
) [inline, static, inherited]

Definition at line 58 of file BaseMath.java.

                                                       {
        return Math.pow(x, y);
    }

Here is the caller graph for this function:

static final double org.javia.arity.BaseMath.pow ( double  x,
double  y 
) [inline, static, inherited]

Definition at line 58 of file BaseMath.java.

                                                       {
        return Math.pow(x, y);
    }
static final double org.javia.arity.BaseMath.sinh ( double  x) [inline, static, inherited]

Definition at line 42 of file BaseMath.java.

                                              {
        return Math.sinh(x);
    }

Here is the caller graph for this function:

static final double org.javia.arity.BaseMath.sinh ( double  x) [inline, static, inherited]

Definition at line 42 of file BaseMath.java.

                                              {
        return Math.sinh(x);
    }
static final double org.javia.arity.BaseMath.tanh ( double  x) [inline, static, inherited]

Definition at line 50 of file BaseMath.java.

                                              {
        return Math.tanh(x);
    }
static final double org.javia.arity.BaseMath.tanh ( double  x) [inline, static, inherited]

Definition at line 50 of file BaseMath.java.

                                              {
        return Math.tanh(x);
    }

Here is the caller graph for this function:

static final double org.javia.arity.MoreMath.trunc ( double  x) [inline, static]

Definition at line 35 of file MoreMath.java.

                                               {
        return x >= 0 ? Math.floor(x) : Math.ceil(x);
    }
static final double org.javia.arity.MoreMath.trunc ( double  x) [inline, static]

Definition at line 35 of file MoreMath.java.

                                               {
        return x >= 0 ? Math.floor(x) : Math.ceil(x);
    }

Member Data Documentation

static final double org.javia.arity.MoreMath.FACT [static, package]
Initial value:
 {
        1.0,
        40320.0,
        2.0922789888E13,
        6.204484017332394E23,
        2.631308369336935E35,
        8.159152832478977E47,
        1.2413915592536073E61,
        7.109985878048635E74,
        1.2688693218588417E89,
        6.1234458376886085E103,
        7.156945704626381E118,
        1.8548264225739844E134,
        9.916779348709496E149,
        1.0299016745145628E166,
        1.974506857221074E182,
        6.689502913449127E198,
        3.856204823625804E215,
        3.659042881952549E232,
        5.5502938327393044E249,
        1.3113358856834524E267,
        4.7147236359920616E284,
        2.5260757449731984E302,
    }

Definition at line 81 of file MoreMath.java.

static final double org.javia.arity.MoreMath.LOG2E = 1.4426950408889634074 [static, private]

Definition at line 21 of file MoreMath.java.


The documentation for this class was generated from the following files: