01: // Copyright (c) 1997 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.math;
05:
06: import java.io.*;
07:
08: /** General Cartesian Complex number.
09: * Use this instead of DComplex if you want exact complex numbers.
10: * @author Per Bothner
11: */
12:
13: public class CComplex extends Complex implements Externalizable {
14: RealNum real;
15: RealNum imag;
16:
17: public CComplex() {
18: }
19:
20: public CComplex(RealNum real, RealNum imag) {
21: this .real = real;
22: this .imag = imag;
23: }
24:
25: public RealNum re() {
26: return real;
27: }
28:
29: public RealNum im() {
30: return imag;
31: }
32:
33: /**
34: * @serialData Write the real and imaginary parts, as Objects.
35: */
36: public void writeExternal(ObjectOutput out) throws IOException {
37: out.writeObject(real);
38: out.writeObject(imag);
39: }
40:
41: public void readExternal(ObjectInput in) throws IOException,
42: ClassNotFoundException {
43: real = (RealNum) in.readObject();
44: imag = (RealNum) in.readObject();
45: }
46: }
|