1 9 package org.nfunk.jep.function; 10 11 import java.util.*; 12 import org.nfunk.jep.*; 13 import org.nfunk.jep.type.*; 14 15 21 public class ArcTanH extends PostfixMathCommand 22 { 23 public ArcTanH() 24 { 25 numberOfParameters = 1; 26 } 27 28 public void run(Stack inStack) 29 throws ParseException 30 { 31 checkStack(inStack); Object param = inStack.pop(); 33 inStack.push(atanh(param)); return; 35 } 36 37 public Object atanh(Object param) 38 throws ParseException 39 { 40 if (param instanceof Complex) 41 { 42 return ((Complex)param).atanh(); 43 } 44 else if (param instanceof Number ) 45 { 46 double val = ((Number )param).doubleValue(); 47 if(val > -1.0 && val < 1) { 48 double res = Math.log((1+val)/(1-val))/2; 49 return new Double (res); 50 } 51 else 52 { 53 Complex temp = new Complex(val,0.0); 54 return temp.atanh(); 55 } 56 } 57 58 throw new ParseException("Invalid parameter type"); 59 } 60 61 } 62 | Popular Tags |