KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > math > CComplex


1 // Copyright (c) 1997 Per M.A. Bothner.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.math;
5 import java.io.*;
6
7 /** General Cartesian Complex number.
8  * Use this instead of DComplex if you want exact complex numbers.
9  * @author Per Bothner
10  */

11
12 public class CComplex extends Complex implements Externalizable
13 {
14   RealNum real;
15   RealNum imag;
16
17   public CComplex ()
18   {
19   }
20
21   public CComplex (RealNum real, RealNum imag)
22   {
23     this.real = real;
24     this.imag = imag;
25   }
26
27   public RealNum re() { return real; }
28   public RealNum im() { return imag; }
29
30   /**
31    * @serialData Write the real and imaginary parts, as Objects.
32    */

33   public void writeExternal(ObjectOutput out) throws IOException
34   {
35     out.writeObject(real);
36     out.writeObject(imag);
37   }
38
39   public void readExternal(ObjectInput in)
40     throws IOException, ClassNotFoundException JavaDoc
41   {
42     real = (RealNum) in.readObject();
43     imag = (RealNum) in.readObject();
44   }
45 }
46
Popular Tags