Java Code Examples for org.apache.commons.math3.util.FastMath#atanh()
The following examples show how to use
org.apache.commons.math3.util.FastMath#atanh() .
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: Atanh.java From astor with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public double value(double x) { return FastMath.atanh(x); }
Example 2
Source File: DSCompiler.java From astor with GNU General Public License v2.0 | 4 votes |
/** Compute inverse hyperbolic tangent 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 tangent the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void atanh(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.atanh(x); if (order > 0) { // the nth order derivative of atanh has the form: // dn(atanh(x)/dxn = Q_n(x) / (1 - x^2)^n // where Q_n(x) is a degree n-1 polynomial with same parity as n-1 // Q_1(x) = 1, Q_2(x) = 2x, Q_3(x) = 6x^2 + 2 ... // the general recurrence relation for Q_n is: // Q_n(x) = (1-x^2) Q_(n-1)'(x) + 2(n-1) x Q_(n-1)(x) // as per polynomial parity, we can store coefficients of both Q_(n-1) and Q_n in the same array final double[] q = new double[order]; q[0] = 1; final double x2 = x * x; final double f = 1.0 / (1 - x2); double coeff = f; function[1] = coeff * q[0]; for (int n = 2; n <= order; ++n) { // update and evaluate polynomial Q_n(x) double v = 0; q[n - 1] = n * q[n - 2]; for (int k = n - 1; k >= 0; k -= 2) { v = v * x2 + q[k]; if (k > 2) { q[k - 2] = (k - 1) * q[k - 1] + (2 * n - k + 1) * q[k - 3]; } else if (k == 2) { q[0] = q[1]; } } if ((n & 0x1) == 0) { v *= x; } coeff *= f; function[n] = coeff * v; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); }
Example 3
Source File: SparseGradient.java From astor with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public SparseGradient atanh() { return new SparseGradient(FastMath.atanh(value), 1.0 / (1.0 - value * value), derivatives); }
Example 4
Source File: Atanh.java From astor with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public double value(double x) { return FastMath.atanh(x); }
Example 5
Source File: DSCompiler.java From astor with GNU General Public License v2.0 | 4 votes |
/** Compute inverse hyperbolic tangent 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 tangent the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void atanh(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.atanh(x); if (order > 0) { // the nth order derivative of atanh has the form: // dn(atanh(x)/dxn = Q_n(x) / (1 - x^2)^n // where Q_n(x) is a degree n-1 polynomial with same parity as n-1 // Q_1(x) = 1, Q_2(x) = 2x, Q_3(x) = 6x^2 + 2 ... // the general recurrence relation for Q_n is: // Q_n(x) = (1-x^2) Q_(n-1)'(x) + 2(n-1) x Q_(n-1)(x) // as per polynomial parity, we can store coefficients of both Q_(n-1) and Q_n in the same array final double[] q = new double[order]; q[0] = 1; final double x2 = x * x; final double f = 1.0 / (1 - x2); double coeff = f; function[1] = coeff * q[0]; for (int n = 2; n <= order; ++n) { // update and evaluate polynomial Q_n(x) double v = 0; q[n - 1] = n * q[n - 2]; for (int k = n - 1; k >= 0; k -= 2) { v = v * x2 + q[k]; if (k > 2) { q[k - 2] = (k - 1) * q[k - 1] + (2 * n - k + 1) * q[k - 3]; } else if (k == 2) { q[0] = q[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: Atanh.java From astor with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public double value(double x) { return FastMath.atanh(x); }
Example 7
Source File: DSCompiler.java From astor with GNU General Public License v2.0 | 4 votes |
/** Compute inverse hyperbolic tangent 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 tangent the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void atanh(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.atanh(x); if (order > 0) { // the nth order derivative of atanh has the form: // dn(atanh(x)/dxn = Q_n(x) / (1 - x^2)^n // where Q_n(x) is a degree n-1 polynomial with same parity as n-1 // Q_1(x) = 1, Q_2(x) = 2x, Q_3(x) = 6x^2 + 2 ... // the general recurrence relation for Q_n is: // Q_n(x) = (1-x^2) Q_(n-1)'(x) + 2(n-1) x Q_(n-1)(x) // as per polynomial parity, we can store coefficients of both Q_(n-1) and Q_n in the same array final double[] q = new double[order]; q[0] = 1; final double x2 = x * x; final double f = 1.0 / (1 - x2); double coeff = f; function[1] = coeff * q[0]; for (int n = 2; n <= order; ++n) { // update and evaluate polynomial Q_n(x) double v = 0; q[n - 1] = n * q[n - 2]; for (int k = n - 1; k >= 0; k -= 2) { v = v * x2 + q[k]; if (k > 2) { q[k - 2] = (k - 1) * q[k - 1] + (2 * n - k + 1) * q[k - 3]; } else if (k == 2) { q[0] = q[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: Atanh.java From astor with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public double value(double x) { return FastMath.atanh(x); }
Example 9
Source File: Atanh.java From astor with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public double value(double x) { return FastMath.atanh(x); }
Example 10
Source File: DSCompiler.java From astor with GNU General Public License v2.0 | 4 votes |
/** Compute inverse hyperbolic tangent 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 tangent the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void atanh(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.atanh(x); if (order > 0) { // the nth order derivative of atanh has the form: // dn(atanh(x)/dxn = Q_n(x) / (1 - x^2)^n // where Q_n(x) is a degree n-1 polynomial with same parity as n-1 // Q_1(x) = 1, Q_2(x) = 2x, Q_3(x) = 6x^2 + 2 ... // the general recurrence relation for Q_n is: // Q_n(x) = (1-x^2) Q_(n-1)'(x) + 2(n-1) x Q_(n-1)(x) // as per polynomial parity, we can store coefficients of both Q_(n-1) and Q_n in the same array final double[] q = new double[order]; q[0] = 1; final double x2 = x * x; final double f = 1.0 / (1 - x2); double coeff = f; function[1] = coeff * q[0]; for (int n = 2; n <= order; ++n) { // update and evaluate polynomial Q_n(x) double v = 0; q[n - 1] = n * q[n - 2]; for (int k = n - 1; k >= 0; k -= 2) { v = v * x2 + q[k]; if (k > 2) { q[k - 2] = (k - 1) * q[k - 1] + (2 * n - k + 1) * q[k - 3]; } else if (k == 2) { q[0] = q[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: ArcHyperbolicTangent.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
@Override protected double compute(double value) { return Double.isNaN(value) ? Double.NaN : FastMath.atanh(value); }
Example 12
Source File: Atanh.java From astor with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public double value(double x) { return FastMath.atanh(x); }
Example 13
Source File: DSCompiler.java From astor with GNU General Public License v2.0 | 4 votes |
/** Compute inverse hyperbolic tangent 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 tangent the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void atanh(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.atanh(x); if (order > 0) { // the nth order derivative of atanh has the form: // dn(atanh(x)/dxn = Q_n(x) / (1 - x^2)^n // where Q_n(x) is a degree n-1 polynomial with same parity as n-1 // Q_1(x) = 1, Q_2(x) = 2x, Q_3(x) = 6x^2 + 2 ... // the general recurrence relation for Q_n is: // Q_n(x) = (1-x^2) Q_(n-1)'(x) + 2(n-1) x Q_(n-1)(x) // as per polynomial parity, we can store coefficients of both Q_(n-1) and Q_n in the same array final double[] q = new double[order]; q[0] = 1; final double x2 = x * x; final double f = 1.0 / (1 - x2); double coeff = f; function[1] = coeff * q[0]; for (int n = 2; n <= order; ++n) { // update and evaluate polynomial Q_n(x) double v = 0; q[n - 1] = n * q[n - 2]; for (int k = n - 1; k >= 0; k -= 2) { v = v * x2 + q[k]; if (k > 2) { q[k - 2] = (k - 1) * q[k - 1] + (2 * n - k + 1) * q[k - 3]; } else if (k == 2) { q[0] = q[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: Atanh.java From astor with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public double value(double x) { return FastMath.atanh(x); }
Example 15
Source File: DSCompiler.java From astor with GNU General Public License v2.0 | 4 votes |
/** Compute inverse hyperbolic tangent 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 tangent the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void atanh(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.atanh(x); if (order > 0) { // the nth order derivative of atanh has the form: // dn(atanh(x)/dxn = Q_n(x) / (1 - x^2)^n // where Q_n(x) is a degree n-1 polynomial with same parity as n-1 // Q_1(x) = 1, Q_2(x) = 2x, Q_3(x) = 6x^2 + 2 ... // the general recurrence relation for Q_n is: // Q_n(x) = (1-x^2) Q_(n-1)'(x) + 2(n-1) x Q_(n-1)(x) // as per polynomial parity, we can store coefficients of both Q_(n-1) and Q_n in the same array final double[] q = new double[order]; q[0] = 1; final double x2 = x * x; final double f = 1.0 / (1 - x2); double coeff = f; function[1] = coeff * q[0]; for (int n = 2; n <= order; ++n) { // update and evaluate polynomial Q_n(x) double v = 0; q[n - 1] = n * q[n - 2]; for (int k = n - 1; k >= 0; k -= 2) { v = v * x2 + q[k]; if (k > 2) { q[k - 2] = (k - 1) * q[k - 1] + (2 * n - k + 1) * q[k - 3]; } else if (k == 2) { q[0] = q[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 |
/** {@inheritDoc} */ public SparseGradient atanh() { return new SparseGradient(FastMath.atanh(value), 1.0 / (1.0 - value * value), derivatives); }
Example 17
Source File: Atanh.java From astor with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public double value(double x) { return FastMath.atanh(x); }
Example 18
Source File: Math_10_DSCompiler_s.java From coming with MIT License | 4 votes |
/** Compute inverse hyperbolic tangent 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 tangent the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void atanh(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.atanh(x); if (order > 0) { // the nth order derivative of atanh has the form: // dn(atanh(x)/dxn = Q_n(x) / (1 - x^2)^n // where Q_n(x) is a degree n-1 polynomial with same parity as n-1 // Q_1(x) = 1, Q_2(x) = 2x, Q_3(x) = 6x^2 + 2 ... // the general recurrence relation for Q_n is: // Q_n(x) = (1-x^2) Q_(n-1)'(x) + 2(n-1) x Q_(n-1)(x) // as per polynomial parity, we can store coefficients of both Q_(n-1) and Q_n in the same array final double[] q = new double[order]; q[0] = 1; final double x2 = x * x; final double f = 1.0 / (1 - x2); double coeff = f; function[1] = coeff * q[0]; for (int n = 2; n <= order; ++n) { // update and evaluate polynomial Q_n(x) double v = 0; q[n - 1] = n * q[n - 2]; for (int k = n - 1; k >= 0; k -= 2) { v = v * x2 + q[k]; if (k > 2) { q[k - 2] = (k - 1) * q[k - 1] + (2 * n - k + 1) * q[k - 3]; } else if (k == 2) { q[0] = q[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 |
/** Compute inverse hyperbolic tangent 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 tangent the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void atanh(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.atanh(x); if (order > 0) { // the nth order derivative of atanh has the form: // dn(atanh(x)/dxn = Q_n(x) / (1 - x^2)^n // where Q_n(x) is a degree n-1 polynomial with same parity as n-1 // Q_1(x) = 1, Q_2(x) = 2x, Q_3(x) = 6x^2 + 2 ... // the general recurrence relation for Q_n is: // Q_n(x) = (1-x^2) Q_(n-1)'(x) + 2(n-1) x Q_(n-1)(x) // as per polynomial parity, we can store coefficients of both Q_(n-1) and Q_n in the same array final double[] q = new double[order]; q[0] = 1; final double x2 = x * x; final double f = 1.0 / (1 - x2); double coeff = f; function[1] = coeff * q[0]; for (int n = 2; n <= order; ++n) { // update and evaluate polynomial Q_n(x) double v = 0; q[n - 1] = n * q[n - 2]; for (int k = n - 1; k >= 0; k -= 2) { v = v * x2 + q[k]; if (k > 2) { q[k - 2] = (k - 1) * q[k - 1] + (2 * n - k + 1) * q[k - 3]; } else if (k == 2) { q[0] = q[1]; } } if ((n & 0x1) == 0) { v *= x; } coeff *= f; function[n] = coeff * v; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); }