29 lines
878 B
Java
29 lines
878 B
Java
package org.nfunk.jep.function;
|
|
|
|
import java.util.Stack;
|
|
import org.nfunk.jep.ParseException;
|
|
import org.nfunk.jep.type.Complex;
|
|
|
|
public class ArcTanH extends PostfixMathCommand {
|
|
public void run(Stack paramStack) throws ParseException {
|
|
checkStack(paramStack);
|
|
Object object = paramStack.pop();
|
|
paramStack.push(atanh(object));
|
|
}
|
|
|
|
public Object atanh(Object paramObject) throws ParseException {
|
|
if (paramObject instanceof Complex)
|
|
return ((Complex)paramObject).atanh();
|
|
if (paramObject instanceof Number) {
|
|
double d = ((Number)paramObject).doubleValue();
|
|
if (d > -1.0D && d < 1.0D) {
|
|
double d1 = Math.log((1.0D + d) / (1.0D - d)) / 2.0D;
|
|
return new Double(d1);
|
|
}
|
|
Complex complex = new Complex(d, 0.0D);
|
|
return complex.atanh();
|
|
}
|
|
throw new ParseException("Invalid parameter type");
|
|
}
|
|
}
|