Class PuComplex
- java.lang.Object
-
- jv.number.PuComplex
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
public class PuComplex extends java.lang.Object implements java.lang.Cloneable, java.io.SerializableComplex number and basic complex functions.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- See Also:
- Serialized Form
- Author:
- Konrad Polthier and Ulrich Reitebuch
- Version:
- 09.04.07, 2.40 revised (kp) New methods rot(), rotJ, pow(.,int), blend(), moebius().
04.08.03, 2.30 revised (pl) Added toString method.
26.09.99, 2.20 revised (kp) Methods set and copy added. Now most methods return 'this'.
14.06.99, 2.10 revised (kp) isNaN and others added. In case of error function now return NaN etc.
00.05.99, 2.00 revised (ur) Converted to Java and revisions.
29.06.98, 1.00 created (kp)
-
-
Field Summary
Fields Modifier and Type Field and Description static PuComplexIdoubleimstatic PuComplexNEG_Istatic PuComplexNEG_ONEstatic PuComplexONEstatic PuComplexPI_OVER_4static PuComplexPI3_OVER_4static PuComplexPI5_OVER_4static PuComplexPI7_OVER_4doublerestatic PuComplexZERO
-
Constructor Summary
Constructors Constructor and Description PuComplex()PuComplex(double r)PuComplex(double aReal, double aImag)PuComplex(PuComplex u)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description doubleabs()r = |this|static doubleabs(PuComplex u)r = |u|PuComplexadd(double r)this += r.PuComplexadd(PuComplex v)this += vstatic PuComplexadd(PuComplex u, double r)w = u + r.static PuComplexadd(PuComplex u, PuComplex v)w = u + vdoublearg()r = arg(this) in [0,2Pi), with slit at positive real axis.static doublearg(PuComplex u)r = arg(u) in [0,2Pi), with slit at positive real axis.doubleargPB()r = argPB(this) in [0,2Pi), principal branch with slit at negative real axis.static doubleargPB(PuComplex u)r = argPB(u) in [-Pi,Pi), principal branch with slit at negative real axis.static PuComplexblend(double a, PuComplex v, double b, PuComplex w)Create a new complex numberthis = a*v + b*w.PuComplexconj()u = re(this) - i*im(this)static PuComplexconj(PuComplex u)w = re(u) - i*im(u)PuComplexcopy(PuComplex v)this = (v.re, v.im)PuComplexcos()u = cos(this)static PuComplexcos(PuComplex u)w = cos(u)PuComplexcosh()u = cosh(this)static PuComplexcosh(PuComplex u)w = cosh(u)PuComplexcot()u = cot(this)static PuComplexcot(PuComplex u)w = cot(u)PuComplexcoth()u = coth(this)static PuComplexcoth(PuComplex u)w = coth(u)PuComplexcube()u = this**3.static PuComplexcube(PuComplex u)w = u ** 3.PuComplexdiv(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 PuComplexdiv(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.PuComplexdiv(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 PuComplexdiv(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 PuComplexdiv(PuComplex u, PuComplex v)w = u / v In case of zero division the following result occurs: {@code If |v|==0 and u.re==0 then w.re==Double.NaN.booleanequals(PuComplex z, double tolerance)Compare two complex numbers of (nearly) equality.static booleanequals(PuComplex w, PuComplex z, double tolerance)Compare two complex numbers of (nearly) equality.static PuComplexexp_self(PuComplex u)w = exp(u)PuComplexexp()u = exp(this)static PuComplexexp(PuComplex u)w = exp(u)doubleim()r = im(this)static doubleim(PuComplex u)Deprecated.since JavaView 3.97.061, use this.im() instead.PuComplexinv()u = 1.static PuComplexinv(PuComplex u)w = 1.booleanisInfinite()booleanisNaN()PuComplexlog()u = log(this)static PuComplexlog(PuComplex u)w = log(u)PuComplexlogPB()u = logPB(this), principal branch with slit at negative real axis.static PuComplexlogPB(PuComplex u)w = logPB(u), principal branch of complex logarithm with slit at negative real axis.static PuComplexmoebius(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 PuComplexmoebius(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.PuComplexmult(double r)this *= r.PuComplexmult(PuComplex v)this *= vstatic PuComplexmult(PuComplex u, double r)w = u * r.static PuComplexmult(PuComplex u, PuComplex v)w = u * vPuComplexneg()u = -thisstatic PuComplexneg(PuComplex u)w = -ustatic PuComplexpolarToRect(double r, double f)w = r*exp(i*f)PuComplexpow(double r)u = this**r.static PuComplexpow(PuComplex u, double r)w = u**r.static PuComplexpow(PuComplex u, int n)w = u**n For small integer exponents, including negative exponents.static PuComplexpow(PuComplex u, PuComplex v)w = u**vdoublere()r = re(this)static doublere(PuComplex u)Deprecated.since JavaView 3.97.061, use this.re() instead.PuComplexrot(double f)u = J(f)*thisstatic PuComplexrot(PuComplex u, double f)w = J(f)*uPuComplexrotJ()u = J*thisstatic PuComplexrotJ(PuComplex u)w = J*uPuComplexset(double aReal, double aImag)this = (re, im)PuComplexset(PdVector p)this = (re, im)PuComplexsin()u = sin(this)static PuComplexsin(PuComplex u)w = sin(u)PuComplexsinh()u = sinh(this)static PuComplexsinh(PuComplex u)w = sinh(u)PuComplexsqr()u = this*thisstatic PuComplexsqr(PuComplex u)w = u * udoublesqrAbs()r = |this|^2PuComplexsqrt()u= sqrt(this)static PuComplexsqrt(PuComplex u)w = sqrt(u)PuComplexsub(double r)this -= r.PuComplexsub(PuComplex v)this -= vstatic PuComplexsub(PuComplex u, double r)w = u - r.static PuComplexsub(PuComplex u, PuComplex v)w = u - vPuComplextan()u = tan(this)static PuComplextan(PuComplex u)w = tan(u)PuComplextanh()u = tanh(this)static PuComplextanh(PuComplex u)w = tanh(u)java.lang.StringtoString()Create a string in the form "a+b*i".
-
-
-
Field Detail
-
ZERO
public static final PuComplex ZERO
-
ONE
public static final PuComplex ONE
-
I
public static final PuComplex I
-
NEG_ONE
public static final PuComplex NEG_ONE
-
NEG_I
public static final PuComplex NEG_I
-
PI_OVER_4
public static final PuComplex PI_OVER_4
-
PI3_OVER_4
public static final PuComplex PI3_OVER_4
-
PI5_OVER_4
public static final PuComplex PI5_OVER_4
-
PI7_OVER_4
public static final PuComplex PI7_OVER_4
-
re
public double re
-
im
public double im
-
-
Constructor Detail
-
PuComplex
public PuComplex()
-
PuComplex
public PuComplex(double r)
-
PuComplex
public PuComplex(PuComplex u)
-
PuComplex
public PuComplex(double aReal, double aImag)
-
-
Method Detail
-
set
public PuComplex set(double aReal, double aImag)
this = (re, im)
-
toString
public java.lang.String toString()
Create a string in the form "a+b*i".- Overrides:
toStringin classjava.lang.Object- Since:
- JavaView 2.90.001
- Author:
- Peter Liepa
- Version:
- 29.08.08, 2.00 revised (kp) String has a multiplication star in front of i.
10.08.03, 1.00 created (pl)
-
isInfinite
public boolean isInfinite()
-
isNaN
public boolean isNaN()
-
equals
public static boolean equals(PuComplex w, PuComplex z, double tolerance)
Compare two complex numbers of (nearly) equality.- Version:
- 21.04.13, 1.50 revised (kp) Changed to 'static' since now access to an instance.
-
equals
public boolean equals(PuComplex z, double tolerance)
Compare two complex numbers of (nearly) equality. Calls static method.
-
add
public PuComplex add(double r)
this += r.
-
sub
public PuComplex sub(double r)
this -= r.
-
mult
public PuComplex mult(double r)
this *= r.
-
div
public static PuComplex div(PuComplex u, PuComplex v)
w = u / vIn case of zero division the following result occurs:
Same handling is taken for imaginary part of u.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.
-
div
public static PuComplex div(double r, PuComplex v)
w = r / vIn 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.
-
div
public PuComplex div(PuComplex v)
this /=vIn case of zero division the following result occurs:
Same handling is taken for imaginary part of 'this'.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.
-
div
public static PuComplex div(PuComplex u, double r)
w = u / rIn 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'.
-
div
public PuComplex div(double r)
this /= rIn 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'.
-
sqr
public PuComplex sqr()
u = this*this
-
cube
public PuComplex cube()
u = this**3.
-
abs
public static double abs(PuComplex u)
r = |u|
-
abs
public double abs()
r = |this|
-
sqrAbs
public double sqrAbs()
r = |this|^2
-
inv
public static PuComplex inv(PuComplex u)
w = 1./uIn case of |u|==0 the following result occurs: w = PuComplex(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY)
-
inv
public PuComplex inv()
u = 1./thisIn case of |u|==0 the following result occurs: u.re = Double.POSITIVE_INFINITY, u.im = Double.POSITIVE_INFINITY.
-
re
public static double re(PuComplex u)
Deprecated. since JavaView 3.97.061, use this.re() instead.r = re(u)
-
re
public double re()
r = re(this)
-
im
public static double im(PuComplex u)
Deprecated. since JavaView 3.97.061, use this.im() instead.r = im(u)
-
im
public double im()
r = im(this)
-
conj
public PuComplex conj()
u = re(this) - i*im(this)
-
neg
public PuComplex neg()
u = -this
-
rotJ
public PuComplex rotJ()
u = J*this
-
rot
public PuComplex rot(double f)
u = J(f)*this
-
arg
public static double arg(PuComplex u)
r = arg(u) in [0,2Pi), with slit at positive real axis.
-
arg
public double arg()
r = arg(this) in [0,2Pi), with slit at positive real axis.
-
argPB
public static double argPB(PuComplex u)
r = argPB(u) in [-Pi,Pi), principal branch with slit at negative real axis.
-
argPB
public double argPB()
r = argPB(this) in [0,2Pi), principal branch with slit at negative real axis.
-
polarToRect
public static PuComplex polarToRect(double r, double f)
w = r*exp(i*f)
-
exp
public PuComplex exp()
u = exp(this)
-
log
public PuComplex log()
u = log(this)
-
logPB
public static PuComplex logPB(PuComplex u)
w = logPB(u), principal branch of complex logarithm with slit at negative real axis.By definition,
logPBis 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 parameterzis considered as an element in C-. This interpretation does not affect the norm, but the argument ofz.Note that every
zwitharg(z)>piwill be considered as an elementwsuch that|w| =|z|andarg(w)=arg(z)-2pi;.- Returns:
- the principal branch of
z, i.e.w=logPB(z) = ln|z|+i*arg(z).
-
logPB
public PuComplex logPB()
u = logPB(this), principal branch with slit at negative real axis.
-
sqrt
public PuComplex sqrt()
u= sqrt(this)
-
pow
public PuComplex pow(double r)
u = this**r.
-
pow
public static PuComplex pow(PuComplex u, int n)
w = u**nFor small integer exponents, including negative exponents. Method avoids transcendental functions and uses float multiplication only.
- Since:
- JavaView 3.97.061
- Version:
- 09.04.07, 1.00 created (kp)
-
sin
public PuComplex sin()
u = sin(this)
-
cos
public PuComplex cos()
u = cos(this)
-
tan
public PuComplex tan()
u = tan(this)
-
cot
public PuComplex cot()
u = cot(this)
-
sinh
public PuComplex sinh()
u = sinh(this)
-
cosh
public PuComplex cosh()
u = cosh(this)
-
tanh
public PuComplex tanh()
u = tanh(this)
-
coth
public PuComplex coth()
u = coth(this)
-
blend
public static PuComplex blend(double a, PuComplex v, double b, PuComplex w)
Create a new complex numberthis = a*v + b*w.- Parameters:
a- weight of first complex numberv- first complex numberb- weight of second complex numberw- second complex number- Returns:
- new complex number
- Since:
- JavaView 3.97.061
- Version:
- 08.04.07, 1.00 created (kp)
-
moebius
public 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.au + b w = moebius(u) = ------ with complex a,b,c,d,u. cu + d- Parameters:
a- complex numberb- complex numberc- complex numberd- complex numberu- complex number argument- Returns:
- new complex number
- Since:
- JavaView 3.97.061
- Version:
- 09.04.07, 1.00 created (kp)
-
moebius
public 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.au + b w = moebius(u) = ------ with double a,b,c,d and complex u. cu + d- Parameters:
a- double numberb- double numberc- double numberd- double numberu- complex number argument- Returns:
- new complex number
- Since:
- JavaView 3.97.061
- Version:
- 09.04.07, 1.00 created (kp)
-
-
"