Multi-Precision Arithmetic by C++ with no use of assembler
SN library Copyright (C) 1999-2018 K.Tsuru

Reference of class functions part 10


12. SComplex class's member and friend functions
The prototype declarations are given in "scomplex.h". This is a multi-precision complex number class using the SDouble arithmetic.
It has two private members
   SDouble re, im;
where "re" holds the real part and "im" the imaginary part.
At the present time it does not support reading from a file. Using SDouble class's Put(s) you can write the real and imaginary parts to a file, separately. A statement such as
   z.Real().Puts();
can be used. Then you can read two SDoublevalues rp and ip from a file, and set a value by use of "z.Set(rp, ip );".

Constructors
form
SComplex(); default constructor
SComplex(double d ); This constructor enables us to write "return 0.0".
SComplex(const SDouble& rp ); constructor by SDouble
SComplex(const SDouble& rp, const SDouble& ip ); constructor by two SDouble values
SComplex(const SComplex& z ); copy constructor

substitution operators
form
SComplex& operator=(const SComplex& z);
SComplex& operator=(const SDouble& sd);

fundamental operators +, -, *, / and compound operators +=, -=, *= /=
These operators are overloaded. All the objects which are usable in the constructors can be used as operands.

relation operators ==, !=
These operators are overloaded.

relation operators >, <, >=, <=, ||, &&, !
These operators are not provided and cannot be used.

IsZero

function "z.IsZero()" returns non-zero value if "re == 0" and "im == 0", else zero.
form inline bool SComplex::IsZero() const;

SetZero

function "z.SetZero()" initializes both "re" and "im" by zeros.
form inline void SComplex::SetZero();

complexC
function "complexC(z );" returns the approximated value of z by "complex <double>". 
form complex <double> complexC(const SComplex& z );

CsMult, CsDiv(member functions)
function "z.CsMult(n )" returns "z*n" and "z.CsDiv(n )" returns "z/n".
form

    SComplex& SComplex::CsMult(ulong n);
    SComplex& SComplex::CsDiv(ulong n);
where 0<n<=ULONG_MAX/DRADIX.

CsMult, CsDiv(non member functions)
function "CsMult(z, n )" returns "z*n" and "CsDiv(z, n )" returns "z/n".
form
    inline SComplex CsMult(const SComplex& z, ulong n);
    inline SComplex CsDiv(const SComplex& z, ulong n);

enumerating constants
function It gives the definition of values for output function.
form enum { iFMT = 0, BracketFMT};

Put, Puts
function "z.Put(s)(...)" outputs the value of z to the present stream.
form
  
long SComplex::Put(bool crlf = 0, int fmt = iFMT) const;
   inline long SComplex::Puts(int fmt = iFMT) const;
comment 
Due to the value of "fmt" it outputs in the following form.
   iFMT : (real part)[+|-]i*(imaginary part), default
   BracketFMT : (real part, imaginary part)