/** * Pops a value off the stack and returns its hyperbolic cosecant. * @param evaluator The current evaluation. * @return The hyperbolic cosecant of the popped node. */ double HyperbolicCosecantNode::evaluate(Evaluator& evaluator) const { double arg = evaluator.pop(); double ex = exp(arg); return (2 * ex) / (ex * ex - 1); }
/** * Pops two values off the stack and returns the first raised to the power of the reciprocal of the second. * @param evaluator The current evaluation. * @return The second value'th root of the first popped value. */ double RootNode::evaluate(Evaluator& evaluator) const { double arg2 = evaluator.pop(); double arg1 = evaluator.pop(); return pow(arg1, 1.0 / arg2); }
/** * Pops a value off the stack and returns its hyperbolic tangent. * @param evaluator The current evaluation. * @return The hyperbolic tangent of the popped node. */ double HyperbolicTangentNode::evaluate(Evaluator& evaluator) const { double arg = evaluator.pop(); double ex = exp(2 * arg); return (ex - 1) / (ex + 1); }
/** * Pops a value off the stack and returns its hyperbolic sine. * @param evaluator The current evaluation. * @return The hyperbolic sine of the popped node. */ double HyperbolicSineNode::evaluate(Evaluator& evaluator) const { double arg = evaluator.pop(); double ex = exp(arg); return (ex * ex - 1) / (2 * ex); }
/** * Pops a value off the stack and returns its decadic logarithm. * @param evaluator The current evaluation. * @return The decadic logarithm of the popped value. */ double DecadicLogarithmNode::evaluate(Evaluator& evaluator) const { double arg = evaluator.pop(); return log10(arg); }
/** * Pops a value off the stack and returns its hyperbolic arc cosecant. * @param evaluator The current evaluation. * @return The hyperbolic arc cosecant of the popped node. */ double HyperbolicArcCosecantNode::evaluate(Evaluator& evaluator) const { double arg = evaluator.pop(); double inv = 1.0 / arg; return log(inv + sqrt(inv * inv + 1)); }
/** * Pops a value off the stack and returns its absolute value. * @param evaluator The current evaluation. * @return The absolute value of the popped node. */ double AbsoluteValueNode::evaluate(Evaluator& evaluator) const { double arg = evaluator.pop(); return fabs(arg); }