當前位置: 首頁>>代碼示例>>Java>>正文


Java FastMath.tanh方法代碼示例

本文整理匯總了Java中org.apache.commons.math3.util.FastMath.tanh方法的典型用法代碼示例。如果您正苦於以下問題:Java FastMath.tanh方法的具體用法?Java FastMath.tanh怎麽用?Java FastMath.tanh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.math3.util.FastMath的用法示例。


在下文中一共展示了FastMath.tanh方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: derivative

import org.apache.commons.math3.util.FastMath; //導入方法依賴的package包/類
/** {@inheritDoc} */
public UnivariateFunction derivative() {
    return new UnivariateFunction() {
        /** {@inheritDoc} */
        public double value(double x) {
            final double tanhX = FastMath.tanh(x);
            return 1 - tanhX * tanhX;
        }
    };
}
 
開發者ID:jiaminghan,項目名稱:droidplanner-master,代碼行數:11,代碼來源:Tanh.java

示例2: value

import org.apache.commons.math3.util.FastMath; //導入方法依賴的package包/類
/** {@inheritDoc} */
public double value(double x) {
    return FastMath.tanh(x);
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:5,代碼來源:Tanh.java

示例3: tanh

import org.apache.commons.math3.util.FastMath; //導入方法依賴的package包/類
/** {@inheritDoc} */
public SparseGradient tanh() {
    final double t = FastMath.tanh(value);
    return new SparseGradient(t, 1 - t * t, derivatives);
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:6,代碼來源:SparseGradient.java

示例4: tanh

import org.apache.commons.math3.util.FastMath; //導入方法依賴的package包/類
/** Compute 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
 * hyperbolic tangent the result array <em>cannot</em> be the input
 * array)
 * @param resultOffset offset of the result in its array
 */
public void tanh(final double[] operand, final int operandOffset,
                 final double[] result, final int resultOffset) {

    // create the function value and derivatives
    final double[] function = new double[1 + order];
    final double t = FastMath.tanh(operand[operandOffset]);
    function[0] = t;

    if (order > 0) {

        // the nth order derivative of tanh has the form:
        // dn(tanh(x)/dxn = P_n(tanh(x))
        // where P_n(t) is a degree n+1 polynomial with same parity as n+1
        // P_0(t) = t, P_1(t) = 1 - t^2, P_2(t) = -2 t (1 - t^2) ...
        // the general recurrence relation for P_n is:
        // P_n(x) = (1-t^2) P_(n-1)'(t)
        // 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 + 2];
        p[1] = 1;
        final double t2 = t * t;
        for (int n = 1; n <= order; ++n) {

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

            function[n] = v;

        }
    }

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

}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:55,代碼來源:DSCompiler.java


注:本文中的org.apache.commons.math3.util.FastMath.tanh方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。