All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Jampack.Znum

java.lang.Object
   |
   +----Jampack.Znum

public class Znum
extends Object
Znum is a mutable complex variable class. It is designed to perform complex arithmetic without creating a new Znum at each operation. Specifically, binary operations have the form c.op(a,b), in which a, b, and c need not be different. The method places the complex number a.op.b in c. The method also returns a pointer to c. Thus the class supports two styles of programming. For example to compute e = a*b + c*d you can write

z1.Times(a,b)
z2.Times(c,d)
e.Plus(z1,z2)

or

e.Plus(z1.Times(a,b), z2.Times(a,b))

Since objects of class Znum are mutable, the use of the assignment operator "=" with these objects is deprecated. Use Eq.

The functions are reasonably resistent to overflow and underflow. But the more complicated ones could almost certainly be improved.


Variable Index

 o I
Imaginary unit.
 o im
The imaginary part of Znum.
 o ONE
Complex 1.
 o re
The real part of Znum.
 o ZERO
Complex 0.

Constructor Index

 o Znum()
Creates a Znum and initializes it to zero.
 o Znum(double)
Creates a Znum and initializes its real part.
 o Znum(double, double)
Creates a Znum and initializes its real and imaginary parts.
 o Znum(Znum)
Creates a Znum and initializes it to another Znum.

Method Index

 o abs(Znum)
Computes the absolute value of a Znum.
 o abs1(Znum)
Computes the 1-norm of a Znum
 o Conj(Znum)
Computes the conjugate of a Znum.
 o Div(Znum, double)
Computes the quotient of a Znum and a double.
 o Div(Znum, Znum)
Computes the quotient of two Znum's.
 o Eq(double, double)
Resets the real and imaginary parts of a Znum.
 o Eq(Znum)
Resets the real and imaginary parts of a Znum to those of another Znum.
 o Exch(Znum)
Interchanges the real and imaginary parts of two Znum's.
 o IsEqual(Znum, Znum)
Tests two Znum'z for equality.
 o Minus(Znum)
Computes unary minus of a Znum.
 o Minus(Znum, Znum)
Computes the difference of two Znum's.
 o Plus(Znum, Znum)
Computes the sum of two Znum's.
 o Sqrt(Znum)
Computes the principal value of the square root of a Znum.
 o Times(double, Znum)
Computes the product of a double and a Znum.
 o Times(Znum, Znum)
Computes the product of two Znum's.

Variables

 o ONE
 public static final Znum ONE
Complex 1.

 o ZERO
 public static final Znum ZERO
Complex 0.

 o I
 public static final Znum I
Imaginary unit.

 o re
 public double re
The real part of Znum.

 o im
 public double im
The imaginary part of Znum.

Constructors

 o Znum
 public Znum()
Creates a Znum and initializes it to zero.

Returns:
a Znum initialized to zero.
 o Znum
 public Znum(double x,
             double y)
Creates a Znum and initializes its real and imaginary parts.

Parameters:
x - a double
y - a double
Returns:
x + iy
 o Znum
 public Znum(double x)
Creates a Znum and initializes its real part.

Parameters:
x - a double
Returns:
x + i*0
 o Znum
 public Znum(Znum a)
Creates a Znum and initializes it to another Znum.

Parameters:
a - a Znum
Returns:
a

Methods

 o IsEqual
 public boolean IsEqual(Znum z1,
                        Znum z2)
Tests two Znum'z for equality.

Parameters:
z1 - a Znum
z2 - a Znum
Returns:
true if z1=z2, otherwise false
 o Eq
 public Znum Eq(Znum a)
Resets the real and imaginary parts of a Znum to those of another Znum.

Parameters:
a - a Znum
Returns:
this = a;
 o Eq
 public Znum Eq(double a,
                double b)
Resets the real and imaginary parts of a Znum.

Parameters:
a - a double
b - a double
Returns:
this = a + ib
 o Exch
 public Znum Exch(Znum a)
Interchanges the real and imaginary parts of two Znum's.

Parameters:
a - a Znum
Returns:
this = a, with a set to the original value of this.
 o abs1
 public static double abs1(Znum z)
Computes the 1-norm of a Znum

 o abs
 public static double abs(Znum z)
Computes the absolute value of a Znum.

Parameters:
z - a Znum
Returns:
the absolute vaue of Znum
 o Conj
 public Znum Conj(Znum a)
Computes the conjugate of a Znum.

Parameters:
a - a Znum
Returns:
this = conj(a);
 o Minus
 public Znum Minus(Znum a)
Computes unary minus of a Znum.

Parameters:
a - a Znum
Returns:
this = -a;
 o Plus
 public Znum Plus(Znum a,
                  Znum b)
Computes the sum of two Znum's.

Parameters:
a - a Znum
b - a Znum
Returns:
this = a + b
 o Minus
 public Znum Minus(Znum a,
                   Znum b)
Computes the difference of two Znum's.

Parameters:
a - a Znum
b - a Znum
Returns:
this = a - b
 o Times
 public Znum Times(Znum a,
                   Znum b)
Computes the product of two Znum's.

Parameters:
a - a Znum
b - a Znum
Returns:
this = ab
 o Times
 public Znum Times(double a,
                   Znum b)
Computes the product of a double and a Znum.

Parameters:
a - a double
b - a Znum
Returns:
this = ab
 o Div
 public Znum Div(Znum a,
                 Znum b) throws JampackException
Computes the quotient of two Znum's. Throws a JampackException if the denominator is zero.

Parameters:
a - a Znum
b - a Znum
Returns:
this = a/b
Throws: JampackException
Thrown if b is zero.
 o Div
 public Znum Div(Znum a,
                 double b) throws JampackException
Computes the quotient of a Znum and a double. Throws a JampackException if the denominator is zero.

Parameters:
a - a Znum
b - a double
Returns:
this = a/b
Throws: JampackException
Thrown if b is zero.
 o Sqrt
 public Znum Sqrt(Znum a)
Computes the principal value of the square root of a Znum.

Parameters:
a - a Znum
this - = sqrt(a)

All Packages  Class Hierarchy  This Package  Previous  Next  Index