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 ArcCosineH extends PostfixMathCommand 22 { 23 public ArcCosineH() 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(acosh(param)); return; 35 } 36 37 public Object acosh(Object param) 38 throws ParseException 39 { 40 if (param instanceof Complex) 41 { 42 return ((Complex)param).acosh(); 43 } 44 else if (param instanceof Number ) 45 { 46 double val = ((Number )param).doubleValue(); 47 if(val >= 1.0) { 48 double res = Math.log(val+Math.sqrt(val*val-1)); 49 return new Double (res); 50 } 51 else 52 { 53 Complex temp = new Complex(((Number )param).doubleValue(),0.0); 54 return temp.acosh(); 55 } 56 } 57 58 throw new ParseException("Invalid parameter type"); 59 } 60 } 61 | Popular Tags |