Tabnine Logo
Math.tanh
Code IndexAdd Tabnine to your IDE (free)

How to use
tanh
method
in
java.lang.Math

Best Java code snippets using java.lang.Math.tanh (Showing top 20 results out of 1,224)

origin: h2oai/h2o-2

@Override protected void fprop(long seed, boolean training) {
 for( int o = 0; o < _a.length; o++ ) {
  _a[o] = 0;
  for( int i = 0; i < _previous._a.length; i++ )
   _a[o] += _w[i * _a.length + o] * _previous._a[i];
  _a[o] += _b[o];
  _a[o] = (float)Math.tanh(_a[o]);
 }
}
origin: h2oai/h2o-2

class ASTTanh extends ASTUniPrefixOp { @Override String opStr(){ return "tanh";  } @Override ASTOp make() {return new ASTTanh ();} @Override double op(double d) { return Math.tanh(d);}}

origin: apache/incubator-druid

 @Override
 protected ExprEval eval(double param)
 {
  return ExprEval.of(Math.tanh(param));
 }
}
origin: stackoverflow.com

 Random random = new Random();
double[] array = new double[10000000];
for (int i = 0; i < array.length; i++) {
  array[i] = Math.tanh(random.nextDouble());
}
origin: plantuml/plantuml

  public BigDecimal eval(List<? extends Number> parameters) {
    assertNotNull(parameters.get(0));
    /** Formula: coth(x) = 1 / tanh(x) */
    double one = 1;
    double d = Math.tanh(parameters.get(0).doubleValue());
    return new BigDecimal((one / d), mc);
  }
});
origin: plantuml/plantuml

  public BigDecimal eval(List<? extends Number> parameters) {
    assertNotNull(parameters.get(0));
    double d = Math.tanh(parameters.get(0).doubleValue());
    return new BigDecimal(d, mc);
  }
});
origin: h2oai/h2o-3

private static double HyperTanFunction(double x) {
 return Math.tanh(x);
}
origin: h2oai/h2o-2

private static double HyperTanFunction(double x) {
 return Math.tanh(x);
}
origin: h2oai/h2o-2

private static double HyperTanFunction(double x) {
 return Math.tanh(x);
}
origin: EngineHub/WorldEdit

public static double tanh(RValue x) throws EvaluationException {
  return Math.tanh(x.getValue());
}
origin: stanfordnlp/CoreNLP

public double[] hiddenLayerOutput(double[][] inputLayerWeights, int[] nodeCliqueFeatures, SeqClassifierFlags aFlag, double[] featureVal) {
 int layerOneSize = inputLayerWeights.length;
 if (layerOneCache == null || layerOneSize != layerOneCache.length)
  layerOneCache = new double[layerOneSize];
 for (int i = 0; i < layerOneSize; i++) {
  double[] ws = inputLayerWeights[i];
  double lOneW = 0;
  for (int m = 0; m < nodeCliqueFeatures.length; m++) {
   double dotProd = ws[nodeCliqueFeatures[m]];
   if (featureVal != null)
    dotProd *= featureVal[m];
   lOneW += dotProd;
  }
  layerOneCache[i] = lOneW;
 }
 if (!aFlag.useHiddenLayer)
  return layerOneCache;
 // transform layer one through hidden
 if (hiddenLayerCache == null || layerOneSize != hiddenLayerCache.length)
  hiddenLayerCache = new double[layerOneSize];
 for (int i = 0; i < layerOneSize; i++) {
  if (aFlag.useSigmoid) {
   hiddenLayerCache[i] = sigmoid(layerOneCache[i]);
  } else {
   hiddenLayerCache[i] = Math.tanh(layerOneCache[i]);
  }
 }
 return hiddenLayerCache;
}
origin: stanfordnlp/CoreNLP

 hlCache[i] = sigmoid(layerCache[i]);
} else {
 hlCache[i] = Math.tanh(layerCache[i]);
origin: deeplearning4j/nd4j

/**
 * The hyperbolic tangent.
 *
 * @param x The argument.
 * @return The tanh(x) = sinh(x)/cosh(x).
 */
static public BigDecimal tanh(final BigDecimal x) {
  if (x.compareTo(BigDecimal.ZERO) < 0) {
    return tanh(x.negate()).negate();
  } else if (x.compareTo(BigDecimal.ZERO) == 0) {
    return BigDecimal.ZERO;
  } else {
    BigDecimal xhighpr = scalePrec(x, 2);
    /* tanh(x) = (1-e^(-2x))/(1+e^(-2x)) .
     */
    BigDecimal exp2x = exp(xhighpr.multiply(new BigDecimal(-2)));
    /* The error in tanh x is err(x)/cosh^2(x).
     */
    double eps = 0.5 * x.ulp().doubleValue() / Math.pow(Math.cosh(x.doubleValue()), 2.0);
    MathContext mc = new MathContext(err2prec(Math.tanh(x.doubleValue()), eps));
    return BigDecimal.ONE.subtract(exp2x).divide(BigDecimal.ONE.add(exp2x), mc);
  }
} /* BigDecimalMath.tanh */
origin: spotbugs/spotbugs

a = Math.sqrt(1.0);
a = Math.tan(0.0);
a = Math.tanh(0.0);
a = Math.toDegrees(0.0);
a = Math.toDegrees(1.0);
origin: prestodb/presto

@Test
public void testTanh()
{
  for (double doubleValue : DOUBLE_VALUES) {
    assertFunction("tanh(" + doubleValue + ")", DOUBLE, Math.tanh(doubleValue));
    assertFunction("tanh(REAL '" + doubleValue + "')", DOUBLE, Math.tanh((float) doubleValue));
  }
  assertFunction("tanh(NULL)", DOUBLE, null);
}
origin: prestodb/presto

@Description("hyperbolic tangent")
@ScalarFunction
@SqlType(StandardTypes.DOUBLE)
public static double tanh(@SqlType(StandardTypes.DOUBLE) double num)
{
  return Math.tanh(num);
}
origin: deeplearning4j/nd4j

double eps = Math.tanh(x.doubleValue());
MathContext mc = new MathContext(err2prec(0.5 * x.ulp().doubleValue() / eps));
origin: stanfordnlp/CoreNLP

/**
 * Applies tanh to each of the entries in the matrix.  Returns a new matrix.
 */
public static SimpleMatrix elementwiseApplyTanh(SimpleMatrix input) {
 SimpleMatrix output = new SimpleMatrix(input);
 for (int i = 0; i < output.numRows(); ++i) {
  for (int j = 0; j < output.numCols(); ++j) {
   output.set(i, j, Math.tanh(output.get(i, j)));
  }
 }
 return output;
}
origin: guoguibing/librec

double distance = Math.sqrt(1 - Math.tanh(itemCorrs.get(posItemIdx, negItemIdx) * simFilter));
double itemWeightValue = itemWeights.get(negItemIdx);
origin: com.h2database/h2

  break;
case TANH:
  result = ValueDouble.get(Math.tanh(v0.getDouble()));
  break;
case SECURE_RAND:
java.langMathtanh

Javadoc

Returns the closest double approximation of the hyperbolic tangent of the argument. The absolute value is always less than 1. The returned result is within 2.5 ulps (units in the last place) of the real result. If the real result is within 0.5ulp of 1 or -1, it should return exactly +1 or -1.

Special cases:

  • tanh(+0.0) = +0.0
  • tanh(-0.0) = -0.0
  • tanh(+infinity) = +1.0
  • tanh(-infinity) = -1.0
  • tanh(NaN) = NaN

Popular methods of Math

  • min
    Returns the smaller of two long values. That is, the result is the argument closer to the value of L
  • max
    Returns the greater of two long values. That is, the result is the argument closer to the value of L
  • abs
    Returns the absolute value of a long value. If the argument is not negative, the argument is returne
  • round
    Returns the closest int to the argument, with ties rounding up. Special cases: * If the argument is
  • pow
    Returns the value of the first argument raised to the power of the second argument. Special cases: *
  • sqrt
    Returns the correctly rounded positive square root of a double value. Special cases: * If the argume
  • ceil
    Returns the smallest (closest to negative infinity) double value that is greater than or equal to th
  • floor
    Returns the largest (closest to positive infinity) double value that is less than or equal to the ar
  • random
    Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returne
  • sin
    Returns the trigonometric sine of an angle. Special cases: * If the argument is NaN or an infinit
  • cos
    Returns the trigonometric cosine of an angle. Special cases: * If the argument is NaN or an infin
  • log
    Returns the natural logarithm (base e) of a doublevalue. Special cases: * If the argument is NaN
  • cos,
  • log,
  • exp,
  • toRadians,
  • atan2,
  • log10,
  • acos,
  • tan,
  • toDegrees,
  • atan

Popular in Java

  • Reading from database using SQL prepared statement
  • notifyDataSetChanged (ArrayAdapter)
  • onRequestPermissionsResult (Fragment)
  • setContentView (Activity)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • JTable (javax.swing)
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now