jv.number

## 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.Serializable

  Complex 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 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 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
    --- | ---
    `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 In case of zero division the following result occurs: {@code 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".

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### 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)

    - #### set

          public PuComplex set(PdVector p)

      this = (re, im)

    - #### copy

          public PuComplex copy(PuComplex v)

      this = (v.re, v.im)

    - #### toString

          public java.lang.String toString()

      Create a string in the form "a+b*i".
      Overrides:
        `toString` in class `java.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 static PuComplex add(PuComplex u,
                                      PuComplex v)

      w = u + v

    - #### add

          public PuComplex add(PuComplex v)

      this += v

    - #### add

          public static PuComplex add(PuComplex u,
                                      double r)

      w = u + r.

    - #### add

          public PuComplex add(double r)

      this += r.

    - #### sub

          public static PuComplex sub(PuComplex u,
                                      PuComplex v)

      w = u - v

    - #### sub

          public PuComplex sub(PuComplex v)

      this -= v

    - #### sub

          public static PuComplex sub(PuComplex u,
                                      double r)

      w = u - r.

    - #### sub

          public PuComplex sub(double r)

      this -= r.

    - #### mult

          public static PuComplex mult(PuComplex u,
                                       PuComplex v)

      w = u * v

    - #### mult

          public PuComplex mult(PuComplex v)

      this *= v

    - #### mult

          public static PuComplex mult(PuComplex u,
                                       double r)

      w = u * r.

    - #### mult

          public PuComplex mult(double r)

      this *= r.

    - #### div

          public static PuComplex div(PuComplex u,
                                      PuComplex v)

      w = u / 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.

    - #### div

          public static PuComplex div(double r,
                                      PuComplex v)

      w = r / 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.

    - #### div

          public PuComplex div(PuComplex v)

      this /=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'.

    - #### div

          public static PuComplex div(PuComplex u,
                                      double r)

      w = u / 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'.

    - #### div

          public PuComplex div(double r)

      this /= 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'.

    - #### sqr

          public static PuComplex sqr(PuComplex u)

      w = u * u

    - #### sqr

          public PuComplex sqr()

      u = this*this

    - #### cube

          public static PuComplex cube(PuComplex u)

      w = u ** 3.

    - #### 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./u

      In case of |u|==0 the following result occurs: w = PuComplex(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY)

    - #### inv

          public PuComplex inv()

      u = 1./this

      In 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 static PuComplex conj(PuComplex u)

      w = re(u) - i*im(u)

    - #### conj

          public PuComplex conj()

      u = re(this) - i*im(this)

    - #### neg

          public static PuComplex neg(PuComplex u)

      w = -u

    - #### neg

          public PuComplex neg()

      u = -this

    - #### rotJ

          public static PuComplex rotJ(PuComplex u)

      w = J*u

    - #### rotJ

          public PuComplex rotJ()

      u = J*this

    - #### rot

          public static PuComplex rot(PuComplex u,
                                      double f)

      w = J(f)*u

    - #### 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 static PuComplex exp(PuComplex u)

      w = exp(u)

    - #### exp_self

          public static PuComplex exp_self(PuComplex u)

      w = exp(u)

    - #### exp

          public PuComplex exp()

      u = exp(this)

    - #### log

          public static PuComplex log(PuComplex u)

      w = log(u)

    - #### 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, `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)>pi` will be considered as an element `w` such that `|w| =|z|` and `arg(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 static PuComplex sqrt(PuComplex u)

      w = sqrt(u)

    - #### sqrt

          public PuComplex sqrt()

      u= sqrt(this)

    - #### pow

          public static PuComplex pow(PuComplex u,
                                      PuComplex v)

      w = u**v

    - #### pow

          public static PuComplex pow(PuComplex u,
                                      double r)

      w = u**r.

    - #### pow

          public PuComplex pow(double r)

      u = this**r.

    - #### pow

          public static PuComplex pow(PuComplex u,
                                      int n)

      w = u**n

      For 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 static PuComplex sin(PuComplex u)

      w = sin(u)

    - #### sin

          public PuComplex sin()

      u = sin(this)

    - #### cos

          public static PuComplex cos(PuComplex u)

      w = cos(u)

    - #### cos

          public PuComplex cos()

      u = cos(this)

    - #### tan

          public static PuComplex tan(PuComplex u)

      w = tan(u)

    - #### tan

          public PuComplex tan()

      u = tan(this)

    - #### cot

          public static PuComplex cot(PuComplex u)

      w = cot(u)

    - #### cot

          public PuComplex cot()

      u = cot(this)

    - #### sinh

          public static PuComplex sinh(PuComplex u)

      w = sinh(u)

    - #### sinh

          public PuComplex sinh()

      u = sinh(this)

    - #### cosh

          public static PuComplex cosh(PuComplex u)

      w = cosh(u)

    - #### cosh

          public PuComplex cosh()

      u = cosh(this)

    - #### tanh

          public static PuComplex tanh(PuComplex u)

      w = tanh(u)

    - #### tanh

          public PuComplex tanh()

      u = tanh(this)

    - #### coth

          public static PuComplex coth(PuComplex u)

      w = coth(u)

    - #### coth

          public PuComplex coth()

      u = coth(this)

    - #### blend

          public static PuComplex blend(double a,
                                        PuComplex v,
                                        double b,
                                        PuComplex w)

      Create a new complex number `this = a*v + b*w`.
      Parameters:
        `a` - weight of first complex number
        `v` - first complex number
        `b` - weight of second complex number
        `w` - 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 number
        `b` - complex number
        `c` - complex number
        `d` - complex number
        `u` - 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 number
        `b` - double number
        `c` - double number
        `d` - double number
        `u` - complex number argument
      Returns:
        new complex number
      Since:
        JavaView 3.97.061
      Version:
        09.04.07, 1.00 created (kp)

"

The software JavaView? is copyright protected. All Rights Reserved.
"