/** * Returns the exponential of a complex number. * @param x a complex number. * @return the exponential. */ public static Cfloat exp(Cfloat x) { return polar(exp(x.r),x.i); }
/** * Returns x to the y'th power. * @param x a real number. * @param y a complex number. * @return x to the y'th power. */ public static Cfloat pow(float x, Cfloat y) { if (x==0.0f) return new Cfloat(); return polar(pow(x,y.r),y.i*log(x)); }
/** * Returns x to the y'th power. * @param x a complex number. * @param y a real number. * @return x to the y'th power. */ public static Cfloat pow(Cfloat x, float y) { if (x.i==0.0f) return new Cfloat(pow(x.r,y)); Cfloat t = log(x); return polar(exp(y*t.r),y*t.i); }
public void test() { Cfloat a = new Cfloat(FLT_PI,FLT_E); Cfloat b = new Cfloat(FLT_E,FLT_PI); assertEquals(a,sub(add(a,b),b)); assertEquals(a,div(mul(a,b),b)); assertEquals(a,conj(conj(a))); assertEquals(a,polar(abs(a),arg(a))); assertEquals(a,exp(log(a))); assertEquals(a,pow(sqrt(a),2.0f)); assertEquals(pow(a,b),exp(b.times(log(a)))); assertEquals(pow(a,b),exp(b.times(log(a)))); assertEquals(sin(FLT_I.times(a)), FLT_I.times(sinh(a))); assertEquals(cos(FLT_I.times(a)),cosh(a)); assertEquals(tan(FLT_I.times(a)), FLT_I.times(tanh(a))); }