/** * Returns the product x * y. * @param x a complex number. * @param y a complex number. * @return the product. */ public static Cfloat mul(Cfloat x, Cfloat y) { return x.times(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(Cfloat ca, Cfloat cb1, Cfloat cb2, float[][] cx) { int n2 = cx.length; for (int i2=0; i2<n2; ++i2) cramp(ca.plus(cb2.times((float)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( Cfloat ca, Cfloat cb1, Cfloat cb2, Cfloat cb3, float[][][] cx) { int n3 = cx.length; for (int i3=0; i3<n3; ++i3) cramp(ca.plus(cb3.times((float)i3)),cb1,cb2,cx[i3]); }
/** * 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 Cfloat pow(Cfloat x, Cfloat y) { if (x.r==0.0f && x.i==0.0f) return new Cfloat(); return exp(y.times(log(x))); }
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))); }