public class PuComplex
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Static methods typically allocate a new complex number as return value while non-static methods try to avoid allocations as far as possible.
Here is a listing with all implemented functions.
set(re, im) u=(re,im) with u PuComplex, re, im double
copy(v) u=(v.re,v.im) with u PuComplex, v PuComplex
add(u,v) w=u+v with u PuComplex, v PuComplex or double
u.add(v) u+=v with u PuComplex, v PuComplex or double
sub(u,v) w=u-v with u PuComplex, v PuComplex or double
u.sub(v) u-=v with u PuComplex, v PuComplex or double
mult(u,v) w=u*v with u PuComplex, v PuComplex or double
u.mult(v) u*=v with u PuComplex, v PuComplex or double
div(u,v) w=u/v with u PuComplex, v PuComplex or double
u.div(v) u/=v with u PuComplex, v PuComplex or double
sqr(u) w=u*u with u PuComplex
u.sqr() u=u*u with u PuComplex
cube(u) w=u*u*u with u PuComplex
u.cube() u=u*u*u with u PuComplex
abs(u) r=|u| with u PuComplex
u.abs() r=|u| with u PuComplex
u.sqrAbs() r=|u|^2 with u PuComplex
inv(u) w=1/u with u PuComplex
u.inv() u=1/u with u PuComplex
re(u) r=re(u) with u PuComplex
u.re() r=re(u) with u PuComplex
im(u) r=im(u) with u PuComplex
u.im() r=im(u) with u PuComplex
conj(u) w=re(u)-i*im(u) with u PuComplex
u.conj() u=re(u)-i*im(u) with u PuComplex
neg(u) w=-u with u PuComplex
u.neg() u=-u with u PuComplex
rot(u, f) w=u*exp(i*f) with u PuComplex, f double
rot(u, f) u=u*exp(i*f) with u PuComplex, f double
rotJ(u) w=J*u with u PuComplex
rotJ() u=J*u with u PuComplex
arg(u) r=arg(u) with u PuComplex
u.arg() r=arg(u) with u PuComplex
argPB(u) r=argPB(u) with u PuComplex
u.argPB() r=argPB(u) with u PuComplex
polarToRect(r,f) w=r*exp(i*f) with r double, f double
exp(u) w=exp(u) with u PuComplex
u.exp() u=exp(u) with u PuComplex
log(u) w=log(u) with u PuComplex
u.log() u=log(u) with u PuComplex
logPB(u) w=logPB(u) with u PuComplex
u.logPB() u=logPB(u) with u PuComplex
sqrt(u) w=sqrt(u) with u PuComplex, result with im >= 0.
u.sqrt() u=sqrt(u) with u PuComplex, result with im >= 0.
pow(u,v) w=u**v with u PuComplex, v PuComplex
pow(u,d) w=u**d with u PuComplex, d double
pow(u,i) w=u**i with u PuComplex, i integer
sin(u) w=sin(u) with u PuComplex
cos(u) w=cos(u) with u PuComplex
sinh(u) w=sinh(u) with u PuComplex
cosh(u) w=cosh(u) with u PuComplex
blend(a, u, b, v) w=a*u+b*v with u,v PuComplex, a,b double
moebius(a, b, c, d, v) w=(a*u+b)/(c*u+d) with u PuComplex, a,b,c,d double
moebius(a, b, c, d, v) w=(a*u+b)/(c*u+d) with u PuComplex, a,b,c,d PuComplex
Modifier and Type | Field and Description |
---|---|
static PuComplex |
I |
double |
im |
static PuComplex |
NEG_I |
static PuComplex |
NEG_ONE |
static PuComplex |
ONE |
static PuComplex |
PI_OVER_4 |
static PuComplex |
PI3_OVER_4 |
static PuComplex |
PI5_OVER_4 |
static PuComplex |
PI7_OVER_4 |
double |
re |
static PuComplex |
ZERO |
Constructor and Description |
---|
PuComplex() |
PuComplex(double r) |
PuComplex(double aReal,
double aImag) |
PuComplex(PuComplex u) |
Modifier and Type | Method and Description |
---|---|
double |
abs()
r = |this|
|
static double |
abs(PuComplex u)
r = |u|
|
PuComplex |
add(double r)
this += r.
|
PuComplex |
add(PuComplex v)
this += v
|
static PuComplex |
add(PuComplex u,
double r)
w = u + r.
|
static PuComplex |
add(PuComplex u,
PuComplex v)
w = u + v
|
double |
arg()
r = arg(this) in [0,2Pi), with slit at positive real axis.
|
static double |
arg(PuComplex u)
r = arg(u) in [0,2Pi), with slit at positive real axis.
|
double |
argPB()
r = argPB(this) in [0,2Pi), principal branch with slit at negative real axis.
|
static double |
argPB(PuComplex u)
r = argPB(u) in [-Pi,Pi), principal branch with slit at negative real axis.
|
static PuComplex |
blend(double a,
PuComplex v,
double b,
PuComplex w)
Create a new complex number
this = a*v + b*w . |
PuComplex |
conj()
u = re(this) - i*im(this)
|
static PuComplex |
conj(PuComplex u)
w = re(u) - i*im(u)
|
PuComplex |
copy(PuComplex v)
this = (v.re, v.im)
|
PuComplex |
cos()
u = cos(this)
|
static PuComplex |
cos(PuComplex u)
w = cos(u)
|
PuComplex |
cosh()
u = cosh(this)
|
static PuComplex |
cosh(PuComplex u)
w = cosh(u)
|
PuComplex |
cot()
u = cot(this)
|
static PuComplex |
cot(PuComplex u)
w = cot(u)
|
PuComplex |
coth()
u = coth(this)
|
static PuComplex |
coth(PuComplex u)
w = coth(u)
|
PuComplex |
cube()
u = this**3.
|
static PuComplex |
cube(PuComplex u)
w = u ** 3.
|
PuComplex |
div(double r)
this /= r
In case of zero division the following result occurs:
{@code
If |r|==0 and re==0 then re==Double.NaN.
|
static PuComplex |
div(double r,
PuComplex v)
w = r / v
In case of zero division the following result occurs:
{@code
If |v|==0 and r==0 then w.re==Double.NaN.
|
PuComplex |
div(PuComplex v)
this /=v
In case of zero division the following result occurs:
{@code
If |v|==0 and re==0 then re==Double.NaN.
|
static PuComplex |
div(PuComplex u,
double r)
w = u / r
In case of zero division the following result occurs:
{@code
If |r|==0 and re==0 then re==Double.NaN.
|
static PuComplex |
div(PuComplex u,
PuComplex v)
w = u / v
{@code
In case of zero division the following result occurs:
If |v|==0 and u.re==0 then w.re==Double.NaN.
|
boolean |
equals(PuComplex z,
double tolerance)
Compare two complex numbers of (nearly) equality.
|
static boolean |
equals(PuComplex w,
PuComplex z,
double tolerance)
Compare two complex numbers of (nearly) equality.
|
static PuComplex |
exp_self(PuComplex u)
w = exp(u)
|
PuComplex |
exp()
u = exp(this)
|
static PuComplex |
exp(PuComplex u)
w = exp(u)
|
double |
im()
r = im(this)
|
static double |
im(PuComplex u)
Deprecated.
since JavaView 3.97.061, use this.im() instead.
|
PuComplex |
inv()
u = 1.
|
static PuComplex |
inv(PuComplex u)
w = 1.
|
boolean |
isInfinite() |
boolean |
isNaN() |
PuComplex |
log()
u = log(this)
|
static PuComplex |
log(PuComplex u)
w = log(u)
|
PuComplex |
logPB()
u = logPB(this), principal branch with slit at negative real axis.
|
static PuComplex |
logPB(PuComplex u)
w = logPB(u), principal branch of complex logarithm with slit at negative real axis.
|
static PuComplex |
moebius(double a,
double b,
double c,
double d,
PuComplex u)
Applies Moebius transformation given by real parameters a,b,c,d to complex argument u.
|
static PuComplex |
moebius(PuComplex a,
PuComplex b,
PuComplex c,
PuComplex d,
PuComplex u)
Applies Moebius transformation given by complex parameters a,b,c,d to complex argument u.
|
PuComplex |
mult(double r)
this *= r.
|
PuComplex |
mult(PuComplex v)
this *= v
|
static PuComplex |
mult(PuComplex u,
double r)
w = u * r.
|
static PuComplex |
mult(PuComplex u,
PuComplex v)
w = u * v
|
PuComplex |
neg()
u = -this
|
static PuComplex |
neg(PuComplex u)
w = -u
|
static PuComplex |
polarToRect(double r,
double f)
w = r*exp(i*f)
|
PuComplex |
pow(double r)
u = this**r.
|
static PuComplex |
pow(PuComplex u,
double r)
w = u**r.
|
static PuComplex |
pow(PuComplex u,
int n)
w = u**n
For small integer exponents, including negative exponents.
|
static PuComplex |
pow(PuComplex u,
PuComplex v)
w = u**v
|
double |
re()
r = re(this)
|
static double |
re(PuComplex u)
Deprecated.
since JavaView 3.97.061, use this.re() instead.
|
PuComplex |
rot(double f)
u = J(f)*this
|
static PuComplex |
rot(PuComplex u,
double f)
w = J(f)*u
|
PuComplex |
rotJ()
u = J*this
|
static PuComplex |
rotJ(PuComplex u)
w = J*u
|
PuComplex |
set(double aReal,
double aImag)
this = (re, im)
|
PuComplex |
set(PdVector p)
this = (re, im)
|
PuComplex |
sin()
u = sin(this)
|
static PuComplex |
sin(PuComplex u)
w = sin(u)
|
PuComplex |
sinh()
u = sinh(this)
|
static PuComplex |
sinh(PuComplex u)
w = sinh(u)
|
PuComplex |
sqr()
u = this*this
|
static PuComplex |
sqr(PuComplex u)
w = u * u
|
double |
sqrAbs()
r = |this|^2
|
PuComplex |
sqrt()
u= sqrt(this)
|
static PuComplex |
sqrt(PuComplex u)
w = sqrt(u)
|
PuComplex |
sub(double r)
this -= r.
|
PuComplex |
sub(PuComplex v)
this -= v
|
static PuComplex |
sub(PuComplex u,
double r)
w = u - r.
|
static PuComplex |
sub(PuComplex u,
PuComplex v)
w = u - v
|
PuComplex |
tan()
u = tan(this)
|
static PuComplex |
tan(PuComplex u)
w = tan(u)
|
PuComplex |
tanh()
u = tanh(this)
|
static PuComplex |
tanh(PuComplex u)
w = tanh(u)
|
java.lang.String |
toString()
Create a string in the form "a+b*i".
|
public static final PuComplex ZERO
public static final PuComplex ONE
public static final PuComplex I
public static final PuComplex NEG_ONE
public static final PuComplex NEG_I
public static final PuComplex PI_OVER_4
public static final PuComplex PI3_OVER_4
public static final PuComplex PI5_OVER_4
public static final PuComplex PI7_OVER_4
public double re
public double im
public PuComplex()
public PuComplex(double r)
public PuComplex(PuComplex u)
public PuComplex(double aReal, double aImag)
public PuComplex set(double aReal, double aImag)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isInfinite()
public boolean isNaN()
public static boolean equals(PuComplex w, PuComplex z, double tolerance)
public boolean equals(PuComplex z, double tolerance)
public PuComplex add(double r)
public PuComplex sub(double r)
public PuComplex mult(double r)
public static PuComplex div(PuComplex u, PuComplex v)
In case of zero division the following result occurs:
If |v|==0 and u.re==0 then w.re==Double.NaN.
If |v|==0 and u.re>0 then w.re==Double.POSITIVE_INFINITY.
If |v|==0 and u.re<0 then w.re==Double.NEGATIVE_INFINITY.
Same handling is taken for imaginary part of u.
public static PuComplex div(double r, PuComplex v)
In case of zero division the following result occurs:
If |v|==0 and r==0 then w.re==Double.NaN.
If |v|==0 and r>0 then w.re==Double.POSITIVE_INFINITY.
If |v|==0 and r<0 then w.re==Double.NEGATIVE_INFINITY.
public PuComplex div(PuComplex v)
In case of zero division the following result occurs:
If |v|==0 and re==0 then re==Double.NaN.
If |v|==0 and re>0 then re==Double.POSITIVE_INFINITY.
If |v|==0 and re<0 then re==Double.NEGATIVE_INFINITY.
Same handling is taken for imaginary part of 'this'.
public static PuComplex div(PuComplex u, double r)
In case of zero division the following result occurs:
If |r|==0 and re==0 then re==Double.NaN.
If |r|==0 and re>0 then re==Double.POSITIVE_INFINITY.
If |r|==0 and re<0 then re==Double.NEGATIVE_INFINITY.
Same handling is taken for imaginary part of 'this'.
public PuComplex div(double r)
In case of zero division the following result occurs:
If |r|==0 and re==0 then re==Double.NaN.
If |r|==0 and re>0 then re==Double.POSITIVE_INFINITY.
If |r|==0 and re<0 then re==Double.NEGATIVE_INFINITY.
Same handling is taken for imaginary part of 'this'.
public PuComplex sqr()
public PuComplex cube()
public static double abs(PuComplex u)
public double abs()
public double sqrAbs()
public static PuComplex inv(PuComplex u)
In case of |u|==0 the following result occurs: w = PuComplex(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY)
public PuComplex inv()
In case of |u|==0 the following result occurs: u.re = Double.POSITIVE_INFINITY, u.im = Double.POSITIVE_INFINITY.
public static double re(PuComplex u)
public double re()
public static double im(PuComplex u)
public double im()
public PuComplex conj()
public PuComplex neg()
public PuComplex rotJ()
public PuComplex rot(double f)
public static double arg(PuComplex u)
public double arg()
public static double argPB(PuComplex u)
public double argPB()
public static PuComplex polarToRect(double r, double f)
public PuComplex exp()
public PuComplex log()
public static PuComplex logPB(PuComplex u)
By definition, logPB is defined on the complex plane slit at the negative real axis, denoted by C-.
Thus, the argument is expected to be greater than -π and less or equal than π. Therefore, the given parameter z is
considered as an element in C-. This interpretation does not affect the norm, but the argument of z.
Note that every z with arg(z)>π will be considered as an element w
such that |w| =|z| and arg(w)=arg(z)-2π.
w=logPB(z) = ln|z|+i*arg(z)
.public PuComplex logPB()
public PuComplex sqrt()
public PuComplex pow(double r)
public static PuComplex pow(PuComplex u, int n)
For small integer exponents, including negative exponents. Method avoids transcendental functions and uses float multiplication only.
public PuComplex sin()
public PuComplex cos()
public PuComplex tan()
public PuComplex cot()
public PuComplex sinh()
public PuComplex cosh()
public PuComplex tanh()
public PuComplex coth()
public static PuComplex blend(double a, PuComplex v, double b, PuComplex w)
this = a*v + b*w
.a
- weight of first complex numberv
- first complex numberb
- weight of second complex numberw
- second complex numberpublic static PuComplex moebius(PuComplex a, PuComplex b, PuComplex c, PuComplex d, PuComplex u)
au + b w = moebius(u) = ------ with complex a,b,c,d,u. cu + d
a
- complex numberb
- complex numberc
- complex numberd
- complex numberu
- complex number argumentpublic static PuComplex moebius(double a, double b, double c, double d, PuComplex u)
au + b w = moebius(u) = ------ with double a,b,c,d and complex u. cu + d
a
- double numberb
- double numberc
- double numberd
- double numberu
- complex number argument"