/** * Returns the natural logarithm of this complex number. * @return the natural logarithm. */ public Cdouble log() { return log(this); }
void apply(double[] cx, double[] cy) { Cdouble ct = new Cdouble(); int n1 = cx.length/2; for (int ir=0,ii=1,nn=2*n1; ir<nn; ir+=2,ii+=2) { ct.r = cx[ir]; ct.i = cx[ii]; Cdouble ce = Cdouble.log(ct); cy[ir] = ce.r; cy[ii] = ce.i; } } };
/** * Returns x to the y'th power. * @param x a complex number. * @param y a complex number. * @return x to the y'th power. */ public static Cdouble pow(Cdouble x, Cdouble y) { if (x.r==0.0 && x.i==0.0) return new Cdouble(); return exp(y.times(log(x))); }
/** * 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 Cdouble pow(double x, Cdouble y) { if (x==0.0) return new Cdouble(); return polar(pow(x,y.r),y.i*log(x)); }
/** * Returns the natural logarithm of a complex number. * @param x a complex number. * @return the natural logarithm. */ public static Cdouble log(Cdouble x) { return new Cdouble(log(abs(x)),arg(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 Cdouble pow(Cdouble x, double y) { if (x.i==0.0) return new Cdouble(pow(x.r,y)); Cdouble t = log(x); return polar(exp(y*t.r),y*t.i); }