net.sourceforge.javacomplex
Class Complex

java.lang.Object
  extended bynet.sourceforge.javacomplex.Complex

public abstract class Complex
extends java.lang.Object

JavaComplex is a complex number library for Java.

SourceForge.net Logo Project
Downloads

Version:
1.0b1
Author:
Nuno Cruces

Field Summary
static Complex E
          The Complex value closest to e, the base of the natural logarithms.
static Complex I
          The Complex value for i, the imaginary unit.
static Complex INFINITY
          The Complex value for , the point at infinity.
static Complex NaN
          The Complex not-a-number.
static Complex ONE
          The Complex value for 1, the multiplicative identity.
static Complex PI
          The Complex value closest to π, the ratio of a circle's circumference to its diameter.
static Complex ZERO
          The Complex value for 0, the additive identity.
 
Constructor Summary
Complex()
           
 
Method Summary
abstract  double abs()
          Returns the absolute value of this Complex value.
 Complex add(Complex z)
          Returns the addition of a given Complex with this Complex value.
abstract  double arg()
          Returns the argument of this Complex value.
static Complex arg(double arg)
          Creates a Complex value from its argument.
static Complex cart(double real, double imag)
          Creates a Complex value from its real and imaginary parts.
abstract  Complex conj()
          Returns the conjugate of this Complex value.
abstract  double decl()
          Returns the declination of this Complex value.
 Complex div(Complex z)
          Returns the division by a given Complex of this Complex value.
 boolean equals(java.lang.Object o)
          Indicates wheather a given Object is equal to this Complex value.
 int hashCode()
          Returns a hash code value for this Complex value.
abstract  double imag()
          Returns the imaginary part of this Complex value.
static Complex imag(double imag)
          Creates a Complex value from its imaginary part.
abstract  Complex inv()
          Returns the inverse of this Complex value.
 boolean isInfinite()
          Checks whether this Complex value is infinite.
 boolean isNaN()
          Checks whether this Complex value is not-a-number.
 Complex mul(Complex z)
          Returns the multiplication of a given Complex with this Complex value.
abstract  Complex neg()
          Returns the negation of this Complex value.
abstract  Complex opp()
          Returns the oposite of this Complex value.
static Complex polar(double abs, double arg)
          Creates a Complex value from its absolute value and argument.
abstract  double real()
          Returns the real part of this Complex value.
static Complex real(double real)
          Creates a Complex value from its real part.
static Complex riemann(double arg, double decl)
          Creates a Complex value from its argument and declination.
 Complex scale(double x)
          Returns this Complex value scaled by a given double number.
 Complex sqr()
          Returns the square of this Complex value.
 Complex sqrt()
          Returns the principal squareroot of this Complex value.
 Complex sub(Complex z)
          Returns the subtraction of a given Complex from this Complex value.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZERO

public static final Complex ZERO
The Complex value for 0, the additive identity.


ONE

public static final Complex ONE
The Complex value for 1, the multiplicative identity.


I

public static final Complex I
The Complex value for i, the imaginary unit.


E

public static final Complex E
The Complex value closest to e, the base of the natural logarithms.


PI

public static final Complex PI
The Complex value closest to π, the ratio of a circle's circumference to its diameter.


NaN

public static final Complex NaN
The Complex not-a-number.


INFINITY

public static final Complex INFINITY
The Complex value for , the point at infinity.

Constructor Detail

Complex

public Complex()
Method Detail

real

public static final Complex real(double real)
Creates a Complex value from its real part.

Factory method that creates a Complex object from its real part.

Special cases:

Parameters:
real - the real part
Returns:
the Complex of real part real and imaginary part 0

imag

public static final Complex imag(double imag)
Creates a Complex value from its imaginary part.

Factory method that creates a Complex object from its imaginary part.

Special cases:

Parameters:
imag - the imaginary part
Returns:
the Complex of imaginary part imag and real part 0

arg

public static final Complex arg(double arg)
Creates a Complex value from its argument.

Factory method that creates a Complex object from its argument.
This corresponds to the cis(x) = cos(x) + i sin(x) function.

Special case:

Parameters:
arg - the argument
Returns:
the Complex of and argument arg absolute value 1

cart

public static final Complex cart(double real,
                                 double imag)
Creates a Complex value from its real and imaginary parts.

Factory method that creates a Complex object from its real and imaginary parts.

Special cases:

Parameters:
real - the real part
imag - the imaginary part
Returns:
the Complex of real part real and imaginary part imag

polar

public static final Complex polar(double abs,
                                  double arg)
Creates a Complex value from its absolute value and argument.

Factory method that creates a Complex object from its absolute value and argument.

Special cases:

Parameters:
abs - theabsolute value
arg - the argument
Returns:
the Complex of absolute value abs and argument arg

riemann

public static final Complex riemann(double arg,
                                    double decl)
Creates a Complex value from its argument and declination.

Factory method that creates a Complex object from argument and declination.

Special cases:

Parameters:
arg - the argument
decl - the declination
Returns:
the Complex with argument arg and declination decl
See Also:
decl()

isNaN

public final boolean isNaN()
Checks whether this Complex value is not-a-number.

Returns:
true if the value represented by this object is nan, false otherwise

isInfinite

public final boolean isInfinite()
Checks whether this Complex value is infinite.

Returns:
true if the value represented by this object is infinity, false otherwise

real

public abstract double real()
Returns the real part of this Complex value.

Special cases:

Returns:
the real part of the value represented by this object

imag

public abstract double imag()
Returns the imaginary part of this Complex value.

Special cases:

Returns:
the imaginary part of the value represented by this object

abs

public abstract double abs()
Returns the absolute value of this Complex value.

Special cases:

Returns:
the absolute value of the value represented by this object

arg

public abstract double arg()
Returns the argument of this Complex value.

Special cases:

Returns:
the argument of the value represented by this object

decl

public abstract double decl()
Returns the declination of this Complex value.

The declination is the angular distance mesured north from the south pole of Riemann's sphere. Also, note that this value belongs to [0+2kπ, π+2kπ] for some integer k.

Special cases:

Returns:
the declination of the value represented by this object

conj

public abstract Complex conj()
Returns the conjugate of this Complex value.

Special cases:

Returns:
the conjugate of the value represented by this object

neg

public abstract Complex neg()
Returns the negation of this Complex value.

Special cases:

Returns:
the negation of the value represented by this object

inv

public abstract Complex inv()
Returns the inverse of this Complex value.

Special cases:

Returns:
the inverse of the value represented by this object

opp

public abstract Complex opp()
Returns the oposite of this Complex value.

The opposite of a Complex value is the value that oposes it in the Riemann sphere representation of complex numbers.

Special cases:

Returns:
the oposite of the value represented by this object

equals

public final boolean equals(java.lang.Object o)
Indicates wheather a given Object is equal to this Complex value.

Complex objects are equal if and only if their real and imaginary parts are equal.
The equals method implements an equivalence relation, being reflexive, symmetric and transitive.

Exceptional cases:

Parameters:
o - the reference object with which to compare
Returns:
true if this Complex value is the same as o, false otherwise

hashCode

public final int hashCode()
Returns a hash code value for this Complex value.

If two Complex values are equal according to the equals(Object) method, then calling the hashCode() method on each of those Complex values produces the same integer result.

Returns:
a hash code value for this Complex value
See Also:
equals(Object)

add

public Complex add(Complex z)
Returns the addition of a given Complex with this Complex value.

Special cases:

Returns:
the value represented by this object added to the argument

sub

public Complex sub(Complex z)
Returns the subtraction of a given Complex from this Complex value.

Special cases:

Returns:
the value represented by this object minus the argument

mul

public Complex mul(Complex z)
Returns the multiplication of a given Complex with this Complex value.

Special cases:

Returns:
the value represented by this object multiplied by the argument

div

public Complex div(Complex z)
Returns the division by a given Complex of this Complex value.

Special cases:

Returns:
the value represented by this object divided by the argument

scale

public Complex scale(double x)
Returns this Complex value scaled by a given double number.

Special cases:

Returns:
the value represented by this object multiplied by the argument

sqr

public Complex sqr()
Returns the square of this Complex value.

Special cases:

Returns:
the value represented by this object multiplied by itself

sqrt

public Complex sqrt()
Returns the principal squareroot of this Complex value.

Special cases:

Returns:
the principal squareroot of the value represented by this object