Esempio n. 1
0
  public Object power(Number d, Complex c) {
    Complex base = new Complex(d.doubleValue(), 0.0);
    Complex temp = base.power(c);

    if (temp.im() == 0) return new Double(temp.re());
    else return temp;
  }
Esempio n. 2
0
  public Object acosh(Object param) throws ParseException {
    if (param instanceof Complex) {
      return ((Complex) param).acosh();
    } else if (param instanceof Number) {
      double val = ((Number) param).doubleValue();
      if (val >= 1.0) {
        double res = Math.log(val + Math.sqrt(val * val - 1));
        return new Double(res);
      } else {
        Complex temp = new Complex(((Number) param).doubleValue(), 0.0);
        return temp.acosh();
      }
    }

    throw new ParseException("Invalid parameter type");
  }
Esempio n. 3
0
 public void complexValueTest(String expr, Complex expected, double tol) throws Exception {
   Node node = j.parse(expr);
   Object res = j.evaluate(node);
   assertTrue(
       "<" + expr + "> expected: <" + expected + "> but was <" + res + ">",
       expected.equals((Complex) res, tol));
   System.out.println("Sucess value of <" + expr + "> is " + res);
 }
Esempio n. 4
0
 public Complex sub(Number d, Complex c) {
   return new Complex(d.doubleValue() - c.re(), -c.im());
 }
Esempio n. 5
0
 public Complex sub(Complex c, Number d) {
   return new Complex(c.re() - d.doubleValue(), c.im());
 }
Esempio n. 6
0
 public Complex sub(Complex c1, Complex c2) {
   return new Complex(c1.re() - c2.re(), c1.im() - c2.im());
 }
Esempio n. 7
0
  public Object power(Complex c, Number d) {
    Complex temp = c.power(d.doubleValue());

    if (temp.im() == 0) return new Double(temp.re());
    else return temp;
  }
Esempio n. 8
0
  public Object power(Complex c1, Complex c2) {
    Complex temp = c1.power(c2);

    if (temp.im() == 0) return new Double(temp.re());
    else return temp;
  }
Esempio n. 9
0
 public Object power(Number d1, Number d2) {
   if (d1.doubleValue() < 0 && d2.doubleValue() != d2.intValue()) {
     Complex c = new Complex(d1.doubleValue(), 0.0);
     return c.power(d2.doubleValue());
   } else return new Double(Math.pow(d1.doubleValue(), d2.doubleValue()));
 }