当前位置: 首页>>代码示例>>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;未经允许,请勿转载。