KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > analysis > ComplexExponential


1 package JSci.maths.analysis;
2
3 import JSci.maths.Complex;
4
5 /**
6 * The complex exponential function.
7 * @version 1.0
8 * @author Mark Hale
9 */

10 public class ComplexExponential extends ComplexFunction {
11     private final Complex A;
12     private final Complex w;
13         /**
14         * Constructs an exponential function of the form <code>exp(iz)</code>.
15         */

16         public ComplexExponential() {
17         A = Complex.ONE;
18         w = Complex.ONE;
19         }
20         /**
21         * Constructs an exponential function of the form <code>A exp(iwz)</code>.
22         */

23         public ComplexExponential(Complex A, Complex w) {
24         this.A = A;
25         this.w = w;
26         }
27     public Complex map(double x, double y) {
28         final double iwzRe = -(w.imag()*x + w.real()*y);
29         final double iwzIm = w.real()*x - w.imag()*y;
30                 return A.multiply(new Complex(
31                         Math.exp(iwzRe)*Math.cos(iwzIm),
32                         Math.exp(iwzRe)*Math.sin(iwzIm)
33                 ));
34         }
35     public Complex map(Complex z) {
36         return map(z.real(), z.imag());
37     }
38         public ComplexFunction differentiate() {
39                 return new ComplexExponential(A.multiply(Complex.I.multiply(w)), w);
40         }
41     public ComplexFunction integrate() {
42                 return new ComplexExponential(A.divide(Complex.I.multiply(w)), w);
43     }
44 }
45
Popular Tags