/** * Returns the sum x + y. * @param x a complex number. * @param y a complex number. * @return the sum. */ public static Cdouble add(Cdouble x, Cdouble y) { return x.plus(y); }
/** * Sets the specified array with a specified linear ramp. * Array values are ca+i1*cb1+i2*cb2. * @param ca value of the first element. * @param cb1 gradient in 1st dimension. * @param cb2 gradient in 2nd dimension. * @param cx the array. */ public static void cramp(Cdouble ca, Cdouble cb1, Cdouble cb2, double[][] cx) { int n2 = cx.length; for (int i2=0; i2<n2; ++i2) cramp(ca.plus(cb2.times((double)i2)),cb1,cx[i2]); }
/** * Sets the specified array with a specified linear ramp. * Array values are ca+i1*cb1+i2*cb2+i3*cb3. * @param ca value of the first element. * @param cb1 gradient in 1st dimension. * @param cb2 gradient in 2nd dimension. * @param cb3 gradient in 3rd dimension. * @param cx the array. */ public static void cramp( Cdouble ca, Cdouble cb1, Cdouble cb2, Cdouble cb3, double[][][] cx) { int n3 = cx.length; for (int i3=0; i3<n3; ++i3) cramp(ca.plus(cb3.times((double)i3)),cb1,cb2,cx[i3]); }
/** * Evaluates residue of G(z) for the n'th derivative and j'th pole. */ private Cdouble gr(int nd, Cdouble polej, Cdouble[] poles, double gain) { Cdouble pj = polej; Cdouble qj = pj.inv(); Cdouble c1 = new Cdouble(1.0,0.0); Cdouble gz = new Cdouble(c1); if (nd==1) { gz.timesEquals(c1.minus(qj)); gz.timesEquals(c1.plus(pj)); gz.timesEquals(pj); gz.timesEquals(0.5); } else if (nd==2) { gz.timesEquals(c1.minus(qj)); gz.timesEquals(c1.minus(pj)); gz.timesEquals(-1.0); } Cdouble gp = new Cdouble(c1); int np = poles.length; for (int ip=0; ip<np; ++ip) { Cdouble pi = poles[ip]; if (!pi.equals(pj) && !pi.equals(pj.conj())) gp.timesEquals(c1.minus(pi.times(qj))); gp.timesEquals(c1.minus(pi.times(pj))); } return gz.over(gp).times(gain); }