24 lines
724 B
Java
24 lines
724 B
Java
package org.nfunk.jep.function;
|
|
|
|
import java.util.Stack;
|
|
import org.nfunk.jep.ParseException;
|
|
import org.nfunk.jep.type.Complex;
|
|
|
|
public class CosineH extends PostfixMathCommand {
|
|
public void run(Stack paramStack) throws ParseException {
|
|
checkStack(paramStack);
|
|
Object object = paramStack.pop();
|
|
paramStack.push(cosh(object));
|
|
}
|
|
|
|
public Object cosh(Object paramObject) throws ParseException {
|
|
if (paramObject instanceof Complex)
|
|
return ((Complex)paramObject).cosh();
|
|
if (paramObject instanceof Number) {
|
|
double d = ((Number)paramObject).doubleValue();
|
|
return new Double((Math.exp(d) + Math.exp(-d)) / 2.0D);
|
|
}
|
|
throw new ParseException("Invalid parameter type");
|
|
}
|
|
}
|