public final class Complex extends Object implements Serializable, Cloneable, CFun
re
and im
. Beyond complex numbers, this class is also suitable for
many other applications using such pairs like co-planary coordinates or
vectors.==
might be used instead of equals()
unhesitatingly.make()
). No objects can be made that contradict this
classes rules for complex o, NaN and infinity as well as others.re
(real part), im
(imaginary part) and
h
(hash value) are public (making getters dispensable).ComplDemo
. opReverse()
does only exist for non commutative
operations.NaN
) (having the hash value
0).NaN
operand end in the
"NaN cul-de-sac".ZERO
(hash value 9) with zero imaginary and real part
— and not four of this sort. A product with one zero is regarded
as zero (even if the other operand is infinite).ComplDemo
. This may require frame4j as installed extension or
by WebStart.CFun
,
Serialized FormModifier and Type | Field and Description |
---|---|
int |
h
Hash code / hash value.
|
static int |
HASH_MAP_LENGTH
Length of internal HashMap.
|
static Complex |
I
Complex Constant I respectively i = (0,1).
|
double |
im
Imaginary part / Imaginärteil
|
static Complex |
INF_0
Infinity 0 degrees.
|
static Complex |
INF_135
Infinity 135 degrees.
|
static Complex |
INF_180
Infinity 180 degrees.
|
static Complex |
INF_225
Infinity 225 degrees.
|
static Complex |
INF_270
Infinity 270 degrees.
|
static Complex |
INF_315
Infinity 315 degrees.
|
static Complex |
INF_45
Infinity 45 degrees.
|
static Complex |
INF_90
Infinity 90 degrees.
|
static String |
infString
Textual representation of infinity.
|
static Complex |
J
Complex Constant J respectively j = (0,1).
|
static Complex |
M_I
Complex Constant M_I respectively -i = (0,-1).
|
static Complex |
M_J
Complex Constant M_J respectively -j = (0,-1).
|
static Complex |
M_ONE
Complex Constant M_ONE (-1,0).
|
static Complex |
NaN
Complex Constant NaN (invalid complex number).
|
static Complex |
ONE
Complex Constant ONE (1,0).
|
double |
re
Real part / Realteil
|
static Complex |
ZERO
Complex Constant ZERO (0,0).
|
D_NaN, D_SIGN_MASK, D_VALUE_MASK, EPSILON_SMALL, FOUR_MC, NOSH, PI, PI_2, PI_3_4, PI_4
Modifier and Type | Method and Description |
---|---|
double |
abs()
The absolute value (modulus) of this Complex ( |z| ).
|
Complex |
acos()
The inverse cosine (arc cosine) of this Complex ( acos(this) ).
|
Complex |
acosh()
The inverse hyperbolic cosine of this Complex ( acosh(this) ).
|
double |
argument()
The argument (phase) of this Complex in radian measure.
|
Complex |
asin()
The inverse sine (arc sine) of this Complex ( asin(this) ).
|
Complex |
asinh()
The inverse hyperbolic sine of this Complex ( asinh(this) ).
|
Complex |
atan()
The inverse tangent (arc tangent) of this Complex ( atan(this) ).
|
Complex |
atanh()
Inverse hyperbolic tangent of this Complex ( atanh(this) ).
|
Object |
clone()
Copy of this Complex.
|
Complex |
conjugate()
The the complex conjugate.
|
Complex |
cos()
The cosine of this Complex ( cos(this) ).
|
Complex |
cosh()
The hyperbolic of this Complex ( cosh(this) ).
|
Complex |
divide(Complex z)
The quotient of two Complex objects (this / z).
|
Complex |
divide(double x)
The quotient of this Complex by double (this / x).
|
Complex |
divideI()
The quotient of this Complex and i (this / i).
|
Complex |
divideReverse(Complex z)
The quotient of two Complex objects (z / this).
|
Complex |
divideReverse(double x)
A double divided by this Complex object (x / this).
|
boolean |
equals(Object z)
Compare with another Complex.
|
Complex |
exp()
The exponential of this Complex ( exp(this) ).
|
Complex |
explode()
The product of this Complex and +infinity (this * infinit).
|
static char |
getPrefix()
Prefix for complex part / name of -1's square root.
|
int |
hashCode()
A hashcode for this Complex / hash value.
|
double |
imag()
The imaginary part of a Complex object.
|
boolean |
isFinite()
Tests if finite.
|
boolean |
isImFinite()
Tests if imaginary is part finite.
|
boolean |
isNaN()
Tests if NaN.
|
boolean |
isReFinite()
Tests if real part is finite.
|
Complex |
log()
The logarithm of this Complex ( log(this) ).
|
static Complex |
make(double re)
Factory of Complex objects representing a real number.
|
static Complex |
make(double re,
double im)
Factory of Complex objects.
|
Complex |
minus(Complex z)
The difference of two Complex objects (this - z).
|
Complex |
minus(double x)
The difference of this Complex and a double (this - x).
|
Complex |
minusReverse(Complex z)
The difference of two Complex objects (z - this).
|
Complex |
minusReverse(double x)
The difference of a double and this Complex (x - this).
|
Complex |
negative()
The negative of a Complex object (akind of -this).
|
Complex |
plus(Complex z)
The sum of two Complex objects (this + z).
|
Complex |
plus(double x)
The sum of this Complex and a double x (this + x).
|
Complex |
pow(Complex z)
This Complex raised to the Complex z power (this ** z).
|
Complex |
pow(double x)
Returns this Complex raised to the x power ( this**x ).
|
protected Object |
readResolve()
De-serialising a Complex object.
|
double |
real()
The real part of a Complex object.
|
static void |
setPrefix(char prefix)
Prefix for complex part / name of -1's square root.
|
Complex |
sin()
The sine of this Complex ( sin(this) ).
|
Complex |
sinh()
The hyperbolic sine of this Complex ( sinh(this) ).
|
Complex |
sqrt()
The square root of this Complex.
|
Complex |
square()
The square of this Complex object (this * this).
|
Complex |
tan()
The tangent of this Complex ( tan(this) ).
|
Complex |
tanh()
The hyperbolic tanh of this Complex ( tanh(this) ).
|
Complex |
times(Complex z)
The product of two Complex objects (this * z).
|
Complex |
times(double x)
The product of this Complex and a double (this * x).
|
Complex |
timesI()
The product of this Complex and i (this * i) .
|
String |
toString()
A String representation for this Complex.
|
String |
toString(int prec)
A String representation for this Complex.
|
static Complex |
valueOf(String s)
Parses a string into a Complex.
|
public final double re
public final double im
public final int h
Zahl | re | im | Hash-Wert |
---|---|---|---|
NaN | (Double.) NaN | (Double.) NaN | 0 |
INF_0 | +unendl. | 0.0 | 1 |
INF_45 |
+unendl. | +unendl. | 2 |
INF_90 | 0.0 | +infinit. | 3 |
INF_135 | -infinit. | +infinit. | 4 |
INF_180 | -infinit. | 0.0 | 5 |
INF_225 | -infinit. | -infinit. | 6 |
INF_270 | 0.0 | -infinit. | 7 |
INF_315 | +infinit. | -infinit. | 8 |
ZERO | 0.0 | 0.0 | 9 |
ONE | 1.0 | 0.0 | 10 |
I bzw. J | 0.0 | 1.0 | 11 |
M_ONE | -1.0 | 0.0 | 12 |
M_I bzw. M_J |
0.0 | -1.0 | 13 |
ZERO
, ONE
and I
respectively
J
do have a positive 0.0 part.CFun.hashCode(double, double)
public static final Complex NaN
public static final Complex INF_0
public static final Complex INF_45
public static final Complex INF_90
public static final Complex INF_135
public static final Complex INF_180
public static final Complex INF_225
public static final Complex INF_270
public static final Complex INF_315
public static final Complex ZERO
public static final Complex ONE
public static final Complex M_ONE
public static final Complex I
public static final Complex J
public static final Complex M_I
public static final Complex M_J
public static String infString
getPrefix()
,
setPrefix()
,
toString()
public static final int HASH_MAP_LENGTH
CFun.NOSH
(14) ones) of the table for
reusable Complex objects.CFun.NOSH
,
CFun.hashCode(double, double)
,
h
,
Constant Field Valuespublic static char getPrefix()
setPrefix(char)
ignores all others.infString
,
toString()
public static void setPrefix(char prefix)
infString
,
toString()
,
getPrefix()
public boolean equals(Object z)
z
) is a Complex and
if this and z
are equal in both real and imaginary part.z
are NaN
this method returns false
(according to the rule that no two invalid numbers should be considered
as equal). The operator ==
on the other hand would get true
in this case, as this class impedes the making of two complex
NaN
s.equals
in class Object
isNaN()
,
h
,
CFun.hashCode(double, double)
public Object clone()
clone
in class Object
equals(Object)
,
h
,
CFun.hashCode(double, double)
public int hashCode()
hashCode
in class Object
h
,
CFun.hashCode(double, double)
public String toString()
prefix
.infString
.toString
in class Object
infString
,
getPrefix()
,
setPrefix(char)
,
h
,
valueOf(java.lang.String)
public String toString(int prec)
toString()
the precision can
be specified. The formatting will be delegated to
CFun
.append()
.prec
- the precision (2..16) default 4protected Object readResolve() throws ObjectStreamException
CFun.NOSH
.ObjectStreamException
- will never be thrownpublic static Complex make(double re, double im)
re
- the real part of the complex numberim
- the imaginary part of the complex numberre
,
im
,
make(double)
public static Complex make(double re)
re
- the real part of the complex numberre
,
im
,
make(double, double)
public boolean isNaN()
co.isNaN()
is equivalent toco == Complex.NaN
as well as toco.h == 0
.NaN
,
h
,
CFun.hashCode(double, double)
public boolean isFinite()
co.isfinite()
is equivalent toco.h >= 9
.NaN
,
h
,
CFun.hashCode(double, double)
,
isReFinite()
,
isImFinite()
public boolean isImFinite()
isFinite()
,
isReFinite()
,
NaN
,
h
,
CFun.hashCode(double, double)
public boolean isReFinite()
isFinite()
,
isImFinite()
,
NaN
,
h
,
CFun.hashCode(double, double)
public double real()
re
) and
imaginary (im
) parts, those could be accessed directly as
well.public double imag()
re
) and
imaginary (im
) parts, those could be accessed directly as
well.public Complex negative()
public Complex conjugate()
public Complex plus(double x)
public Complex minusReverse(Complex z)
public Complex minus(double x)
public Complex minusReverse(double x)
public Complex square()
public Complex timesI()
public Complex times(double x)
public Complex explode()
public Complex divide(Complex z)
Complex.ZERO
or z is infinite
Complex.ZERO
is returned.public Complex divideI()
public Complex divideReverse(Complex z)
divide(Complex)
public Complex divide(double x)
ZERO
or x is infinite Complex.ZERO
is
returned.public Complex divideReverse(double x)
public double abs()
public double argument()
public Complex sqrt()
public Complex exp()
public Complex log()
public Complex sinh()
public Complex sin()
public Complex cos()
public Complex tan()
public Complex asin()
public Complex acos()
public Complex atan()
public Complex cosh()
public Complex tanh()
public Complex pow(double x)
ONE
).public Complex asinh()
public Complex acosh()
public Complex atanh()
public static Complex valueOf(String s) throws NumberFormatException
toString()
. Examples:s
- the complex number (as text)NumberFormatException
- if s can't be interpreted as number