Java Code Examples for org.apache.commons.math3.util.FastMath#asinh()

The following examples show how to use org.apache.commons.math3.util.FastMath#asinh() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChebyshevII.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
public void design(final double stopBandDb) {
    reset();

    final double eps = Math.sqrt(1. / (Math.exp(stopBandDb * 0.1 * Math.log(10)) - 1));
    final double v0 = FastMath.asinh(1 / eps) / nPoles;
    final double sinhv0 = -Math.sinh(v0);
    final double coshv0 = Math.cosh(v0);
    final double fn = Math.PI / (2 * nPoles);

    int k = 1;
    for (int i = nPoles / 2; --i >= 0; k += 2) {
        final double a = sinhv0 * Math.cos((k - nPoles) * fn);
        final double b = coshv0 * Math.sin((k - nPoles) * fn);
        final double d2 = a * a + b * b;
        final double im = 1 / Math.cos(k * fn);
        final Complex pole = new Complex(a / d2, b / d2); // NOPMD
        final Complex zero = new Complex(0.0, im); // NOPMD
        addPoleZeroConjugatePairs(pole, zero);
    }

    if ((nPoles & 1) == 1) {
        add(new Complex(1 / sinhv0), new Complex(Double.POSITIVE_INFINITY));
    }
    setNormal(0, 1);
}
 
Example 2
Source File: ChebyshevI.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
public void design(final double rippleDb) {
    reset();

    final double eps = Math.sqrt(1. / Math.exp(-rippleDb * 0.1 * Math.log(10)) - 1);
    final double v0 = FastMath.asinh(1 / eps) / nPoles;
    final double sinhv0 = -Math.sinh(v0);
    final double coshv0 = Math.cosh(v0);

    final double n2 = 2.0 * nPoles;
    final int pairs = nPoles / 2;
    for (int i = 0; i < pairs; ++i) {
        final int k = 2 * i + 1 - nPoles;
        final double a = sinhv0 * Math.cos(k * Math.PI / n2);
        final double b = coshv0 * Math.sin(k * Math.PI / n2);

        addPoleZeroConjugatePairs(new Complex(a, b), new Complex(Double.POSITIVE_INFINITY)); // NOPMD
    }

    if ((nPoles & 1) == 1) {
        add(new Complex(sinhv0, 0), new Complex(Double.POSITIVE_INFINITY));
        setNormal(0, 1);
    } else {
        setNormal(0, Math.pow(10, -rippleDb / 20.));
    }
}
 
Example 3
Source File: SparseGradient.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public SparseGradient asinh() {
    return new SparseGradient(FastMath.asinh(value), 1.0 / FastMath.sqrt(value * value + 1.0), derivatives);
}
 
Example 4
Source File: Asinh.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double value(double x) {
    return FastMath.asinh(x);
}
 
Example 5
Source File: DSCompiler.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** Compute inverse hyperbolic sine of a derivative structure.
 * @param operand array holding the operand
 * @param operandOffset offset of the operand in its array
 * @param result array where result must be stored (for
 * inverse hyperbolic sine the result array <em>cannot</em> be the input
 * array)
 * @param resultOffset offset of the result in its array
 */
public void asinh(final double[] operand, final int operandOffset,
                 final double[] result, final int resultOffset) {

    // create the function value and derivatives
    double[] function = new double[1 + order];
    final double x = operand[operandOffset];
    function[0] = FastMath.asinh(x);
    if (order > 0) {
        // the nth order derivative of asinh has the form:
        // dn(asinh(x)/dxn = P_n(x) / [x^2 + 1]^((2n-1)/2)
        // where P_n(x) is a degree n-1 polynomial with same parity as n-1
        // P_1(x) = 1, P_2(x) = -x, P_3(x) = 2x^2 - 1 ...
        // the general recurrence relation for P_n is:
        // P_n(x) = (x^2+1) P_(n-1)'(x) - (2n-3) x P_(n-1)(x)
        // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array
        final double[] p = new double[order];
        p[0] = 1;
        final double x2    = x * x;
        final double f     = 1.0 / (1 + x2);
        double coeff = FastMath.sqrt(f);
        function[1] = coeff * p[0];
        for (int n = 2; n <= order; ++n) {

            // update and evaluate polynomial P_n(x)
            double v = 0;
            p[n - 1] = (1 - n) * p[n - 2];
            for (int k = n - 1; k >= 0; k -= 2) {
                v = v * x2 + p[k];
                if (k > 2) {
                    p[k - 2] = (k - 1) * p[k - 1] + (k - 2 * n) * p[k - 3];
                } else if (k == 2) {
                    p[0] = p[1];
                }
            }
            if ((n & 0x1) == 0) {
                v *= x;
            }

            coeff *= f;
            function[n] = coeff * v;

        }
    }

    // apply function composition
    compose(operand, operandOffset, function, result, resultOffset);

}
 
Example 6
Source File: Asinh.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double value(double x) {
    return FastMath.asinh(x);
}
 
Example 7
Source File: DSCompiler.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** Compute inverse hyperbolic sine of a derivative structure.
 * @param operand array holding the operand
 * @param operandOffset offset of the operand in its array
 * @param result array where result must be stored (for
 * inverse hyperbolic sine the result array <em>cannot</em> be the input
 * array)
 * @param resultOffset offset of the result in its array
 */
public void asinh(final double[] operand, final int operandOffset,
                 final double[] result, final int resultOffset) {

    // create the function value and derivatives
    double[] function = new double[1 + order];
    final double x = operand[operandOffset];
    function[0] = FastMath.asinh(x);
    if (order > 0) {
        // the nth order derivative of asinh has the form:
        // dn(asinh(x)/dxn = P_n(x) / [x^2 + 1]^((2n-1)/2)
        // where P_n(x) is a degree n-1 polynomial with same parity as n-1
        // P_1(x) = 1, P_2(x) = -x, P_3(x) = 2x^2 - 1 ...
        // the general recurrence relation for P_n is:
        // P_n(x) = (x^2+1) P_(n-1)'(x) - (2n-3) x P_(n-1)(x)
        // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array
        final double[] p = new double[order];
        p[0] = 1;
        final double x2    = x * x;
        final double f     = 1.0 / (1 + x2);
        double coeff = FastMath.sqrt(f);
        function[1] = coeff * p[0];
        for (int n = 2; n <= order; ++n) {

            // update and evaluate polynomial P_n(x)
            double v = 0;
            p[n - 1] = (1 - n) * p[n - 2];
            for (int k = n - 1; k >= 0; k -= 2) {
                v = v * x2 + p[k];
                if (k > 2) {
                    p[k - 2] = (k - 1) * p[k - 1] + (k - 2 * n) * p[k - 3];
                } else if (k == 2) {
                    p[0] = p[1];
                }
            }
            if ((n & 0x1) == 0) {
                v *= x;
            }

            coeff *= f;
            function[n] = coeff * v;

        }
    }

    // apply function composition
    compose(operand, operandOffset, function, result, resultOffset);

}
 
Example 8
Source File: Asinh.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double value(double x) {
    return FastMath.asinh(x);
}
 
Example 9
Source File: Asinh.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double value(double x) {
    return FastMath.asinh(x);
}
 
Example 10
Source File: DSCompiler.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** Compute inverse hyperbolic sine of a derivative structure.
 * @param operand array holding the operand
 * @param operandOffset offset of the operand in its array
 * @param result array where result must be stored (for
 * inverse hyperbolic sine the result array <em>cannot</em> be the input
 * array)
 * @param resultOffset offset of the result in its array
 */
public void asinh(final double[] operand, final int operandOffset,
                 final double[] result, final int resultOffset) {

    // create the function value and derivatives
    double[] function = new double[1 + order];
    final double x = operand[operandOffset];
    function[0] = FastMath.asinh(x);
    if (order > 0) {
        // the nth order derivative of asinh has the form:
        // dn(asinh(x)/dxn = P_n(x) / [x^2 + 1]^((2n-1)/2)
        // where P_n(x) is a degree n-1 polynomial with same parity as n-1
        // P_1(x) = 1, P_2(x) = -x, P_3(x) = 2x^2 - 1 ...
        // the general recurrence relation for P_n is:
        // P_n(x) = (x^2+1) P_(n-1)'(x) - (2n-3) x P_(n-1)(x)
        // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array
        final double[] p = new double[order];
        p[0] = 1;
        final double x2    = x * x;
        final double f     = 1.0 / (1 + x2);
        double coeff = FastMath.sqrt(f);
        function[1] = coeff * p[0];
        for (int n = 2; n <= order; ++n) {

            // update and evaluate polynomial P_n(x)
            double v = 0;
            p[n - 1] = (1 - n) * p[n - 2];
            for (int k = n - 1; k >= 0; k -= 2) {
                v = v * x2 + p[k];
                if (k > 2) {
                    p[k - 2] = (k - 1) * p[k - 1] + (k - 2 * n) * p[k - 3];
                } else if (k == 2) {
                    p[0] = p[1];
                }
            }
            if ((n & 0x1) == 0) {
                v *= x;
            }

            coeff *= f;
            function[n] = coeff * v;

        }
    }

    // apply function composition
    compose(operand, operandOffset, function, result, resultOffset);

}
 
Example 11
Source File: DSCompiler.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** Compute inverse hyperbolic sine of a derivative structure.
 * @param operand array holding the operand
 * @param operandOffset offset of the operand in its array
 * @param result array where result must be stored (for
 * inverse hyperbolic sine the result array <em>cannot</em> be the input
 * array)
 * @param resultOffset offset of the result in its array
 */
public void asinh(final double[] operand, final int operandOffset,
                 final double[] result, final int resultOffset) {

    // create the function value and derivatives
    double[] function = new double[1 + order];
    final double x = operand[operandOffset];
    function[0] = FastMath.asinh(x);
    if (order > 0) {
        // the nth order derivative of asinh has the form:
        // dn(asinh(x)/dxn = P_n(x) / [x^2 + 1]^((2n-1)/2)
        // where P_n(x) is a degree n-1 polynomial with same parity as n-1
        // P_1(x) = 1, P_2(x) = -x, P_3(x) = 2x^2 - 1 ...
        // the general recurrence relation for P_n is:
        // P_n(x) = (x^2+1) P_(n-1)'(x) - (2n-3) x P_(n-1)(x)
        // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array
        final double[] p = new double[order];
        p[0] = 1;
        final double x2    = x * x;
        final double f     = 1.0 / (1 + x2);
        double coeff = FastMath.sqrt(f);
        function[1] = coeff * p[0];
        for (int n = 2; n <= order; ++n) {

            // update and evaluate polynomial P_n(x)
            double v = 0;
            p[n - 1] = (1 - n) * p[n - 2];
            for (int k = n - 1; k >= 0; k -= 2) {
                v = v * x2 + p[k];
                if (k > 2) {
                    p[k - 2] = (k - 1) * p[k - 1] + (k - 2 * n) * p[k - 3];
                } else if (k == 2) {
                    p[0] = p[1];
                }
            }
            if ((n & 0x1) == 0) {
                v *= x;
            }

            coeff *= f;
            function[n] = coeff * v;

        }
    }

    // apply function composition
    compose(operand, operandOffset, function, result, resultOffset);

}
 
Example 12
Source File: Asinh.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double value(double x) {
    return FastMath.asinh(x);
}
 
Example 13
Source File: DSCompiler.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** Compute inverse hyperbolic sine of a derivative structure.
 * @param operand array holding the operand
 * @param operandOffset offset of the operand in its array
 * @param result array where result must be stored (for
 * inverse hyperbolic sine the result array <em>cannot</em> be the input
 * array)
 * @param resultOffset offset of the result in its array
 */
public void asinh(final double[] operand, final int operandOffset,
                 final double[] result, final int resultOffset) {

    // create the function value and derivatives
    double[] function = new double[1 + order];
    final double x = operand[operandOffset];
    function[0] = FastMath.asinh(x);
    if (order > 0) {
        // the nth order derivative of asinh has the form:
        // dn(asinh(x)/dxn = P_n(x) / [x^2 + 1]^((2n-1)/2)
        // where P_n(x) is a degree n-1 polynomial with same parity as n-1
        // P_1(x) = 1, P_2(x) = -x, P_3(x) = 2x^2 - 1 ...
        // the general recurrence relation for P_n is:
        // P_n(x) = (x^2+1) P_(n-1)'(x) - (2n-3) x P_(n-1)(x)
        // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array
        final double[] p = new double[order];
        p[0] = 1;
        final double x2    = x * x;
        final double f     = 1.0 / (1 + x2);
        double coeff = FastMath.sqrt(f);
        function[1] = coeff * p[0];
        for (int n = 2; n <= order; ++n) {

            // update and evaluate polynomial P_n(x)
            double v = 0;
            p[n - 1] = (1 - n) * p[n - 2];
            for (int k = n - 1; k >= 0; k -= 2) {
                v = v * x2 + p[k];
                if (k > 2) {
                    p[k - 2] = (k - 1) * p[k - 1] + (k - 2 * n) * p[k - 3];
                } else if (k == 2) {
                    p[0] = p[1];
                }
            }
            if ((n & 0x1) == 0) {
                v *= x;
            }

            coeff *= f;
            function[n] = coeff * v;

        }
    }

    // apply function composition
    compose(operand, operandOffset, function, result, resultOffset);

}
 
Example 14
Source File: Asinh.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double value(double x) {
    return FastMath.asinh(x);
}
 
Example 15
Source File: DSCompiler.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** Compute inverse hyperbolic sine of a derivative structure.
 * @param operand array holding the operand
 * @param operandOffset offset of the operand in its array
 * @param result array where result must be stored (for
 * inverse hyperbolic sine the result array <em>cannot</em> be the input
 * array)
 * @param resultOffset offset of the result in its array
 */
public void asinh(final double[] operand, final int operandOffset,
                 final double[] result, final int resultOffset) {

    // create the function value and derivatives
    double[] function = new double[1 + order];
    final double x = operand[operandOffset];
    function[0] = FastMath.asinh(x);
    if (order > 0) {
        // the nth order derivative of asinh has the form:
        // dn(asinh(x)/dxn = P_n(x) / [x^2 + 1]^((2n-1)/2)
        // where P_n(x) is a degree n-1 polynomial with same parity as n-1
        // P_1(x) = 1, P_2(x) = -x, P_3(x) = 2x^2 - 1 ...
        // the general recurrence relation for P_n is:
        // P_n(x) = (x^2+1) P_(n-1)'(x) - (2n-3) x P_(n-1)(x)
        // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array
        final double[] p = new double[order];
        p[0] = 1;
        final double x2    = x * x;
        final double f     = 1.0 / (1 + x2);
        double coeff = FastMath.sqrt(f);
        function[1] = coeff * p[0];
        for (int n = 2; n <= order; ++n) {

            // update and evaluate polynomial P_n(x)
            double v = 0;
            p[n - 1] = (1 - n) * p[n - 2];
            for (int k = n - 1; k >= 0; k -= 2) {
                v = v * x2 + p[k];
                if (k > 2) {
                    p[k - 2] = (k - 1) * p[k - 1] + (k - 2 * n) * p[k - 3];
                } else if (k == 2) {
                    p[0] = p[1];
                }
            }
            if ((n & 0x1) == 0) {
                v *= x;
            }

            coeff *= f;
            function[n] = coeff * v;

        }
    }

    // apply function composition
    compose(operand, operandOffset, function, result, resultOffset);

}
 
Example 16
Source File: SparseGradient.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public SparseGradient asinh() {
    return new SparseGradient(FastMath.asinh(value), 1.0 / FastMath.sqrt(value * value + 1.0), derivatives);
}
 
Example 17
Source File: Asinh.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public double value(double x) {
    return FastMath.asinh(x);
}
 
Example 18
Source File: Math_10_DSCompiler_s.java    From coming with MIT License 4 votes vote down vote up
/** Compute inverse hyperbolic sine of a derivative structure.
 * @param operand array holding the operand
 * @param operandOffset offset of the operand in its array
 * @param result array where result must be stored (for
 * inverse hyperbolic sine the result array <em>cannot</em> be the input
 * array)
 * @param resultOffset offset of the result in its array
 */
public void asinh(final double[] operand, final int operandOffset,
                 final double[] result, final int resultOffset) {

    // create the function value and derivatives
    double[] function = new double[1 + order];
    final double x = operand[operandOffset];
    function[0] = FastMath.asinh(x);
    if (order > 0) {
        // the nth order derivative of asinh has the form:
        // dn(asinh(x)/dxn = P_n(x) / [x^2 + 1]^((2n-1)/2)
        // where P_n(x) is a degree n-1 polynomial with same parity as n-1
        // P_1(x) = 1, P_2(x) = -x, P_3(x) = 2x^2 - 1 ...
        // the general recurrence relation for P_n is:
        // P_n(x) = (x^2+1) P_(n-1)'(x) - (2n-3) x P_(n-1)(x)
        // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array
        final double[] p = new double[order];
        p[0] = 1;
        final double x2    = x * x;
        final double f     = 1.0 / (1 + x2);
        double coeff = FastMath.sqrt(f);
        function[1] = coeff * p[0];
        for (int n = 2; n <= order; ++n) {

            // update and evaluate polynomial P_n(x)
            double v = 0;
            p[n - 1] = (1 - n) * p[n - 2];
            for (int k = n - 1; k >= 0; k -= 2) {
                v = v * x2 + p[k];
                if (k > 2) {
                    p[k - 2] = (k - 1) * p[k - 1] + (k - 2 * n) * p[k - 3];
                } else if (k == 2) {
                    p[0] = p[1];
                }
            }
            if ((n & 0x1) == 0) {
                v *= x;
            }

            coeff *= f;
            function[n] = coeff * v;

        }
    }

    // apply function composition
    compose(operand, operandOffset, function, result, resultOffset);

}
 
Example 19
Source File: Math_10_DSCompiler_t.java    From coming with MIT License 4 votes vote down vote up
/** Compute inverse hyperbolic sine of a derivative structure.
 * @param operand array holding the operand
 * @param operandOffset offset of the operand in its array
 * @param result array where result must be stored (for
 * inverse hyperbolic sine the result array <em>cannot</em> be the input
 * array)
 * @param resultOffset offset of the result in its array
 */
public void asinh(final double[] operand, final int operandOffset,
                 final double[] result, final int resultOffset) {

    // create the function value and derivatives
    double[] function = new double[1 + order];
    final double x = operand[operandOffset];
    function[0] = FastMath.asinh(x);
    if (order > 0) {
        // the nth order derivative of asinh has the form:
        // dn(asinh(x)/dxn = P_n(x) / [x^2 + 1]^((2n-1)/2)
        // where P_n(x) is a degree n-1 polynomial with same parity as n-1
        // P_1(x) = 1, P_2(x) = -x, P_3(x) = 2x^2 - 1 ...
        // the general recurrence relation for P_n is:
        // P_n(x) = (x^2+1) P_(n-1)'(x) - (2n-3) x P_(n-1)(x)
        // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array
        final double[] p = new double[order];
        p[0] = 1;
        final double x2    = x * x;
        final double f     = 1.0 / (1 + x2);
        double coeff = FastMath.sqrt(f);
        function[1] = coeff * p[0];
        for (int n = 2; n <= order; ++n) {

            // update and evaluate polynomial P_n(x)
            double v = 0;
            p[n - 1] = (1 - n) * p[n - 2];
            for (int k = n - 1; k >= 0; k -= 2) {
                v = v * x2 + p[k];
                if (k > 2) {
                    p[k - 2] = (k - 1) * p[k - 1] + (k - 2 * n) * p[k - 3];
                } else if (k == 2) {
                    p[0] = p[1];
                }
            }
            if ((n & 0x1) == 0) {
                v *= x;
            }

            coeff *= f;
            function[n] = coeff * v;

        }
    }

    // apply function composition
    compose(operand, operandOffset, function, result, resultOffset);

}
 
Example 20
Source File: ArcHyperbolicSine.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected double compute(double value) {
	return Double.isNaN(value) ? Double.NaN : FastMath.asinh(value);
}