amath  1.8.5
Simple command line calculator
ComplexNumber Struct Reference

Represent a complex number with 2 components of 15 significant digits. More...

#include <cplex.h>

Inheritance diagram for ComplexNumber:
Collaboration diagram for ComplexNumber:

Public Member Functions

 ComplexNumber ()
 
 ComplexNumber (complex z)
 
 ComplexNumber (double real, double imag)
 
 ~ComplexNumber ()
 
NumberClone ()
 
int GetIntegerValue ()
 
double GetRealValue ()
 
double GetImagValue () const
 
complex GetComplexValue () const
 
bool PureComplexValue ()
 
int GetPrecedence ()
 
int GetDefaultPrecedence ()
 
bool IsNegative ()
 
bool IsZero ()
 
bool IsNaN ()
 Returns true if number is NaN. More...
 
bool IsInfinite ()
 Returns true if number is infinite. More...
 
bool IsNotImplemented ()
 
NumberUnary ()
 
NumberAdd (Number *other)
 
NumberSub (Number *other)
 
NumberMul (Number *other)
 
NumberDiv (Number *other)
 
NumberRaise (Number *exponent)
 
NumberSignum ()
 
NumberTrunc ()
 
NumberRound ()
 
NumberFloor ()
 
NumberCeiling ()
 
NumberAbsolute ()
 
NumberSquareRoot ()
 
NumberCubeRoot ()
 
NumberReciprocal ()
 
NumberFactorial ()
 
NumberLog ()
 
NumberLog2 ()
 
NumberLog10 ()
 
NumberSine ()
 
NumberCosine ()
 
NumberTangent ()
 
NumberCosecant ()
 
NumberSecant ()
 
NumberCotangent ()
 
NumberChord ()
 
NumberExSecant ()
 
NumberExCosecant ()
 
NumberArcSine ()
 
NumberArcCosine ()
 
NumberArcTangent ()
 
NumberArcCosecant ()
 
NumberArcSecant ()
 
NumberArcCotangent ()
 
NumberArcExSecant ()
 
NumberArcExCosecant ()
 
NumberArcChord ()
 
NumberHypSine ()
 
NumberHypCosine ()
 
NumberHypTangent ()
 
NumberHypCosecant ()
 
NumberHypSecant ()
 
NumberHypCotangent ()
 
NumberHypArcSine ()
 
NumberHypArcCosine ()
 
NumberHypArcTangent ()
 
NumberHypArcCosecant ()
 
NumberHypArcSecant ()
 
NumberHypArcCotangent ()
 
NumberVerSine ()
 
NumberVerCosine ()
 
NumberCoVerSine ()
 
NumberCoVerCosine ()
 
NumberHaVerSine ()
 
NumberHaVerCosine ()
 
NumberHaCoVerSine ()
 
NumberHaCoVerCosine ()
 
NumberArcVerSine ()
 
NumberArcVerCosine ()
 
NumberArcCoVerSine ()
 
NumberArcCoVerCosine ()
 
NumberArcHaVerSine ()
 
NumberArcHaVerCosine ()
 
NumberArcHaCoVerSine ()
 
NumberArcHaCoVerCosine ()
 
- Public Member Functions inherited from Number
 Number (NumberSystem system)
 
virtual ~Number ()
 

Private Attributes

complex z
 

Additional Inherited Members

- Protected Attributes inherited from Number
NumberSystem system
 

Detailed Description

Represent a complex number with 2 components of 15 significant digits.

Calculations are done using 64 bit IEEE 754 arithmetics.

Definition at line 46 of file cplex.h.

Constructor & Destructor Documentation

◆ ComplexNumber() [1/3]

ComplexNumber::ComplexNumber ( )

Definition at line 36 of file cplex.cpp.

References cpack(), nsyscomplex, Number::Number(), and z.

Referenced by Add(), Div(), Mul(), Raise(), and Sub().

37 {
38  z = cpack(0.0, 0.0);
39 }
complex cpack(double x, double y)
Pack two real numbers into a complex number.
Definition: prim.c:68
Number(NumberSystem system)
Definition: numb.h:69
complex z
Definition: cplex.h:141
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ComplexNumber() [2/3]

ComplexNumber::ComplexNumber ( complex  z)
explicit

◆ ComplexNumber() [3/3]

ComplexNumber::ComplexNumber ( double  real,
double  imag 
)

Definition at line 46 of file cplex.cpp.

References cpack(), nsyscomplex, Number::Number(), and z.

Referenced by ComplexiNode::ComplexiNode(), RealNumber::CubeRoot(), RealNumber::Log(), RealNumber::Log10(), RealNumber::Log2(), Parser::ParseNumber(), RealNumber::Raise(), and RealNumber::SquareRoot().

47 {
48  z = cpack(real, imag);
49 }
complex cpack(double x, double y)
Pack two real numbers into a complex number.
Definition: prim.c:68
Number(NumberSystem system)
Definition: numb.h:69
complex z
Definition: cplex.h:141
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~ComplexNumber()

ComplexNumber::~ComplexNumber ( )

Definition at line 51 of file cplex.cpp.

52 {
53 }

Member Function Documentation

◆ Absolute()

Number * ComplexNumber::Absolute ( )
virtual

Implements Number.

Definition at line 280 of file cplex.cpp.

References cabs(), RealNumber::RealNumber(), and z.

281 {
282  return new RealNumber(cabs(z));
283 }
complex z
Definition: cplex.h:141
friend struct RealNumber
Definition: numb.h:167
double cabs(complex z)
Absolute value of complex number.
Definition: prim.c:54
Here is the call graph for this function:

◆ Add()

Number * ComplexNumber::Add ( Number other)
virtual

Implements Number.

Definition at line 170 of file cplex.cpp.

References cadd(), ComplexNumber(), cpack(), Number::IsNaN(), nnnan, NonNumber::NonNumber(), nsyscomplex, nsysreal, Number::system, RealNumber::x, and z.

171 {
172  if (other->IsNaN())
173  return new NonNumber(nnnan);
174 
175  if (other->system == nsyscomplex)
176  {
177  ComplexNumber *w = static_cast<ComplexNumber *>(other);
178  return new ComplexNumber(cadd(z, w->z));
179  }
180 
181  if (other->system == nsysreal)
182  {
183  RealNumber *a = static_cast<RealNumber *>(other);
184  return new ComplexNumber(cadd(z, cpack(a->x, 0.0)));
185  }
186 
187  return new ComplexNumber();
188 }
Represent a number which does not exists.
Definition: nnumb.h:51
complex cpack(double x, double y)
Pack two real numbers into a complex number.
Definition: prim.c:68
complex cadd(complex y, complex z)
Addition of two complex numbers.
Definition: prim.c:120
Definition: nnumb.h:42
NumberSystem system
Definition: numb.h:171
complex z
Definition: cplex.h:141
virtual bool IsNaN()=0
Represent a real number with 15 significant digits.
Definition: real.h:45
ComplexNumber()
Definition: cplex.cpp:36
double x
Definition: real.h:143
Represent a complex number with 2 components of 15 significant digits.
Definition: cplex.h:46
Definition: numb.h:61
Here is the call graph for this function:

◆ ArcChord()

Number * ComplexNumber::ArcChord ( )
virtual

Implements Number.

Definition at line 419 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

420 {
421  return new NonNumber(nnnimp);
422 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ ArcCosecant()

Number * ComplexNumber::ArcCosecant ( )
virtual

Implements Number.

Definition at line 409 of file cplex.cpp.

References cacsc(), ComplexNumber(), and z.

410 {
411  return new ComplexNumber(cacsc(z));
412 }
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
complex cacsc(complex z)
Inverse cosecant of complex number.
Definition: cacsc.c:42
Here is the call graph for this function:

◆ ArcCosine()

Number * ComplexNumber::ArcCosine ( )
virtual

Implements Number.

Definition at line 394 of file cplex.cpp.

References cacos(), ComplexNumber(), and z.

395 {
396  return new ComplexNumber(cacos(z));
397 }
complex cacos(complex z)
Inverse cosine of complex number.
Definition: cacos.c:42
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ ArcCotangent()

Number * ComplexNumber::ArcCotangent ( )
virtual

Implements Number.

Definition at line 414 of file cplex.cpp.

References cacot(), ComplexNumber(), and z.

415 {
416  return new ComplexNumber(cacot(z));
417 }
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
complex cacot(complex z)
Inverse cotangent of complex number.
Definition: cacot.c:42
Here is the call graph for this function:

◆ ArcCoVerCosine()

Number * ComplexNumber::ArcCoVerCosine ( )
virtual

Implements Number.

Definition at line 549 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

550 {
551  return new NonNumber(nnnimp);
552 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ ArcCoVerSine()

Number * ComplexNumber::ArcCoVerSine ( )
virtual

Implements Number.

Definition at line 544 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

545 {
546  return new NonNumber(nnnimp);
547 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ ArcExCosecant()

Number * ComplexNumber::ArcExCosecant ( )
virtual

Implements Number.

Definition at line 429 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

430 {
431  return new NonNumber(nnnimp);
432 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ ArcExSecant()

Number * ComplexNumber::ArcExSecant ( )
virtual

Implements Number.

Definition at line 424 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

425 {
426  return new NonNumber(nnnimp);
427 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ ArcHaCoVerCosine()

Number * ComplexNumber::ArcHaCoVerCosine ( )
virtual

Implements Number.

Definition at line 569 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

570 {
571  return new NonNumber(nnnimp);
572 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ ArcHaCoVerSine()

Number * ComplexNumber::ArcHaCoVerSine ( )
virtual

Implements Number.

Definition at line 564 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

565 {
566  return new NonNumber(nnnimp);
567 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ ArcHaVerCosine()

Number * ComplexNumber::ArcHaVerCosine ( )
virtual

Implements Number.

Definition at line 559 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

560 {
561  return new NonNumber(nnnimp);
562 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ ArcHaVerSine()

Number * ComplexNumber::ArcHaVerSine ( )
virtual

Implements Number.

Definition at line 554 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

555 {
556  return new NonNumber(nnnimp);
557 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ ArcSecant()

Number * ComplexNumber::ArcSecant ( )
virtual

Implements Number.

Definition at line 404 of file cplex.cpp.

References casec(), ComplexNumber(), and z.

405 {
406  return new ComplexNumber(casec(z));
407 }
complex z
Definition: cplex.h:141
complex casec(complex z)
Inverse secant expressed using complex logarithms:
Definition: casec.c:42
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ ArcSine()

Number * ComplexNumber::ArcSine ( )
virtual

Implements Number.

Definition at line 389 of file cplex.cpp.

References casin(), ComplexNumber(), and z.

390 {
391  return new ComplexNumber(casin(z));
392 }
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
complex casin(complex z)
Inverse sine of complex number.
Definition: casin.c:42
Here is the call graph for this function:

◆ ArcTangent()

Number * ComplexNumber::ArcTangent ( )
virtual

Implements Number.

Definition at line 399 of file cplex.cpp.

References catan(), ComplexNumber(), and z.

400 {
401  return new ComplexNumber(catan(z));
402 }
complex catan(complex z)
Inverse tangent of complex number.
Definition: catan.c:42
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ ArcVerCosine()

Number * ComplexNumber::ArcVerCosine ( )
virtual

Implements Number.

Definition at line 539 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

540 {
541  return new NonNumber(nnnimp);
542 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ ArcVerSine()

Number * ComplexNumber::ArcVerSine ( )
virtual

Implements Number.

Definition at line 534 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

535 {
536  return new NonNumber(nnnimp);
537 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ Ceiling()

Number * ComplexNumber::Ceiling ( )
virtual

Implements Number.

Definition at line 300 of file cplex.cpp.

References cceil(), ComplexNumber(), and z.

301 {
302  return new ComplexNumber(cceil(z));
303 }
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
complex cceil(complex z)
Ceiling value of complex number.
Definition: prim.c:100
Here is the call graph for this function:

◆ Chord()

Number * ComplexNumber::Chord ( )
virtual

Implements Number.

Definition at line 374 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

375 {
376  return new NonNumber(nnnimp);
377 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ Clone()

Number * ComplexNumber::Clone ( )
virtual

Implements Number.

Definition at line 55 of file cplex.cpp.

References ComplexNumber(), and z.

56 {
57  return new ComplexNumber(z);
58 }
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ Cosecant()

Number * ComplexNumber::Cosecant ( )
virtual

Implements Number.

Definition at line 364 of file cplex.cpp.

References ccsc(), ComplexNumber(), and z.

365 {
366  return new ComplexNumber(ccsc(z));
367 }
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
complex ccsc(complex z)
Cosecant of a complex number.
Definition: ccsc.c:48
Here is the call graph for this function:

◆ Cosine()

Number * ComplexNumber::Cosine ( )
virtual

Implements Number.

Definition at line 349 of file cplex.cpp.

References ccos(), ComplexNumber(), and z.

350 {
351  return new ComplexNumber(ccos(z));
352 }
complex z
Definition: cplex.h:141
complex ccos(complex z)
Cosine of complex number.
Definition: ccos.c:45
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ Cotangent()

Number * ComplexNumber::Cotangent ( )
virtual

Implements Number.

Definition at line 369 of file cplex.cpp.

References ccot(), ComplexNumber(), and z.

370 {
371  return new ComplexNumber(ccot(z));
372 }
complex ccot(complex z)
Cotangent of a complex number.
Definition: ccot.c:48
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ CoVerCosine()

Number * ComplexNumber::CoVerCosine ( )
virtual

Implements Number.

Definition at line 509 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

510 {
511  return new NonNumber(nnnimp);
512 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ CoVerSine()

Number * ComplexNumber::CoVerSine ( )
virtual

Implements Number.

Definition at line 504 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

505 {
506  return new NonNumber(nnnimp);
507 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ CubeRoot()

Number * ComplexNumber::CubeRoot ( )
virtual

Implements Number.

Definition at line 315 of file cplex.cpp.

References ccbrt(), ComplexNumber(), and z.

316 {
317  return new ComplexNumber(ccbrt(z));
318 }
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
complex ccbrt(complex z)
Cube root of complex number.
Definition: ccbrt.c:41
Here is the call graph for this function:

◆ Div()

Number * ComplexNumber::Div ( Number other)
virtual

Implements Number.

Definition at line 230 of file cplex.cpp.

References cdiv(), ComplexNumber(), cpack(), Number::IsNaN(), Number::IsZero(), nnnan, NonNumber::NonNumber(), nsyscomplex, nsysreal, Number::system, RealNumber::x, and z.

231 {
232  if (other->IsZero() || other->IsNaN())
233  return new NonNumber(nnnan);
234 
235  if (other->system == nsyscomplex)
236  {
237  ComplexNumber *w = static_cast<ComplexNumber *>(other);
238  return new ComplexNumber(cdiv(z, w->z));
239  }
240 
241  if (other->system == nsysreal)
242  {
243  RealNumber *a = static_cast<RealNumber *>(other);
244  return new ComplexNumber(cdiv(z, cpack(a->x, 0.0)));
245  }
246 
247  return new ComplexNumber();
248 }
complex cdiv(complex y, complex z)
Division of two complex numbers.
Definition: prim.c:159
Represent a number which does not exists.
Definition: nnumb.h:51
complex cpack(double x, double y)
Pack two real numbers into a complex number.
Definition: prim.c:68
Definition: nnumb.h:42
NumberSystem system
Definition: numb.h:171
virtual bool IsZero()=0
complex z
Definition: cplex.h:141
virtual bool IsNaN()=0
Represent a real number with 15 significant digits.
Definition: real.h:45
ComplexNumber()
Definition: cplex.cpp:36
double x
Definition: real.h:143
Represent a complex number with 2 components of 15 significant digits.
Definition: cplex.h:46
Definition: numb.h:61
Here is the call graph for this function:

◆ ExCosecant()

Number * ComplexNumber::ExCosecant ( )
virtual

Implements Number.

Definition at line 384 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

385 {
386  return new NonNumber(nnnimp);
387 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ ExSecant()

Number * ComplexNumber::ExSecant ( )
virtual

Implements Number.

Definition at line 379 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

380 {
381  return new NonNumber(nnnimp);
382 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ Factorial()

Number * ComplexNumber::Factorial ( )
virtual

Implements Number.

Definition at line 270 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

271 {
272  return new NonNumber(nnnimp);
273 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ Floor()

Number * ComplexNumber::Floor ( )
virtual

Implements Number.

Definition at line 295 of file cplex.cpp.

References cfloor(), ComplexNumber(), and z.

296 {
297  return new ComplexNumber(cfloor(z));
298 }
complex cfloor(complex z)
Floor value of complex number.
Definition: prim.c:90
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ GetComplexValue()

complex ComplexNumber::GetComplexValue ( ) const

Definition at line 75 of file cplex.cpp.

References z.

Referenced by DecimalSystem::GetText(), and PositionalNumeralSystem::GetText().

76 {
77  return z;
78 }
complex z
Definition: cplex.h:141
Here is the caller graph for this function:

◆ GetDefaultPrecedence()

int ComplexNumber::GetDefaultPrecedence ( )
virtual

Implements Number.

Definition at line 101 of file cplex.cpp.

References cimag(), creal(), and z.

102 {
103  return (creal(z) != 0.0 && cimag(z) != 0.0) ? 2 : 0;
104 }
double cimag(complex z)
Imaginary part of complex number.
Definition: prim.c:46
complex z
Definition: cplex.h:141
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
Here is the call graph for this function:

◆ GetImagValue()

double ComplexNumber::GetImagValue ( ) const

Definition at line 70 of file cplex.cpp.

References cimag(), and z.

71 {
72  return cimag(z);
73 }
double cimag(complex z)
Imaginary part of complex number.
Definition: prim.c:46
complex z
Definition: cplex.h:141
Here is the call graph for this function:

◆ GetIntegerValue()

int ComplexNumber::GetIntegerValue ( )
virtual

Implements Number.

Definition at line 60 of file cplex.cpp.

References creal(), and z.

61 {
62  return static_cast<int>(creal(z));
63 }
complex z
Definition: cplex.h:141
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
Here is the call graph for this function:

◆ GetPrecedence()

int ComplexNumber::GetPrecedence ( )
virtual

Implements Number.

Definition at line 85 of file cplex.cpp.

References cimag(), creal(), and z.

86 {
87  if ((creal(z) < 0.0) || (creal(z) == 0.0 && cimag(z) < 0.0))
88  {
89  return -1;
90  }
91  else if (creal(z) != 0.0 && cimag(z) != 0.0)
92  {
93  return 2;
94  }
95  else
96  {
97  return 0;
98  }
99 }
double cimag(complex z)
Imaginary part of complex number.
Definition: prim.c:46
complex z
Definition: cplex.h:141
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
Here is the call graph for this function:

◆ GetRealValue()

double ComplexNumber::GetRealValue ( )
virtual

Implements Number.

Definition at line 65 of file cplex.cpp.

References creal(), and z.

66 {
67  return creal(z);
68 }
complex z
Definition: cplex.h:141
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
Here is the call graph for this function:

◆ HaCoVerCosine()

Number * ComplexNumber::HaCoVerCosine ( )
virtual

Implements Number.

Definition at line 529 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

530 {
531  return new NonNumber(nnnimp);
532 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ HaCoVerSine()

Number * ComplexNumber::HaCoVerSine ( )
virtual

Implements Number.

Definition at line 524 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

525 {
526  return new NonNumber(nnnimp);
527 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ HaVerCosine()

Number * ComplexNumber::HaVerCosine ( )
virtual

Implements Number.

Definition at line 519 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

520 {
521  return new NonNumber(nnnimp);
522 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ HaVerSine()

Number * ComplexNumber::HaVerSine ( )
virtual

Implements Number.

Definition at line 514 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

515 {
516  return new NonNumber(nnnimp);
517 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ HypArcCosecant()

Number * ComplexNumber::HypArcCosecant ( )
virtual

Implements Number.

Definition at line 484 of file cplex.cpp.

References cacsch(), ComplexNumber(), and z.

485 {
486  return new ComplexNumber(cacsch(z));
487 }
complex z
Definition: cplex.h:141
complex cacsch(complex z)
Inverse hyperbolic cosecant of complex number.
Definition: cacsch.c:42
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ HypArcCosine()

Number * ComplexNumber::HypArcCosine ( )
virtual

Implements Number.

Definition at line 469 of file cplex.cpp.

References cacosh(), ComplexNumber(), and z.

470 {
471  return new ComplexNumber(cacosh(z));
472 }
complex z
Definition: cplex.h:141
complex cacosh(complex z)
Inverse hyperbolic cosine of complex number.
Definition: cacosh.c:42
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ HypArcCotangent()

Number * ComplexNumber::HypArcCotangent ( )
virtual

Implements Number.

Definition at line 489 of file cplex.cpp.

References cacoth(), ComplexNumber(), and z.

490 {
491  return new ComplexNumber(cacoth(z));
492 }
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
complex cacoth(complex z)
Inverse hyperbolic cotangent of complex number.
Definition: cacoth.c:42
Here is the call graph for this function:

◆ HypArcSecant()

Number * ComplexNumber::HypArcSecant ( )
virtual

Implements Number.

Definition at line 479 of file cplex.cpp.

References casech(), ComplexNumber(), and z.

480 {
481  return new ComplexNumber(casech(z));
482 }
complex casech(complex z)
Inverse hyperbolic secant of complex numbers.
Definition: casech.c:42
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ HypArcSine()

Number * ComplexNumber::HypArcSine ( )
virtual

Implements Number.

Definition at line 464 of file cplex.cpp.

References casinh(), ComplexNumber(), and z.

465 {
466  return new ComplexNumber(casinh(z));
467 }
complex casinh(complex z)
Inverse hyperbolic sine of complex number.
Definition: casinh.c:47
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ HypArcTangent()

Number * ComplexNumber::HypArcTangent ( )
virtual

Implements Number.

Definition at line 474 of file cplex.cpp.

References catanh(), ComplexNumber(), and z.

475 {
476  return new ComplexNumber(catanh(z));
477 }
complex catanh(complex z)
Inverse hyperbolic tangent of complex number.
Definition: catanh.c:42
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ HypCosecant()

Number * ComplexNumber::HypCosecant ( )
virtual

Implements Number.

Definition at line 454 of file cplex.cpp.

References ccsch(), ComplexNumber(), and z.

455 {
456  return new ComplexNumber(ccsch(z));
457 }
complex ccsch(complex z)
Hyperbolic secant of a complex number.
Definition: ccsch.c:48
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ HypCosine()

Number * ComplexNumber::HypCosine ( )
virtual

Implements Number.

Definition at line 439 of file cplex.cpp.

References ccosh(), ComplexNumber(), and z.

440 {
441  return new ComplexNumber(ccosh(z));
442 }
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
complex ccosh(complex z)
Hyperbolic cosine of a complex number.
Definition: ccosh.c:48
Here is the call graph for this function:

◆ HypCotangent()

Number * ComplexNumber::HypCotangent ( )
virtual

Implements Number.

Definition at line 459 of file cplex.cpp.

References ccoth(), ComplexNumber(), and z.

460 {
461  return new ComplexNumber(ccoth(z));
462 }
complex ccoth(complex z)
Hyperbolic cotangent of a complex number.
Definition: ccoth.c:50
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ HypSecant()

Number * ComplexNumber::HypSecant ( )
virtual

Implements Number.

Definition at line 449 of file cplex.cpp.

References ComplexNumber(), csech(), and z.

450 {
451  return new ComplexNumber(csech(z));
452 }
complex z
Definition: cplex.h:141
complex csech(complex z)
Hyperbolic secant of a complex number.
Definition: csech.c:48
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ HypSine()

Number * ComplexNumber::HypSine ( )
virtual

Implements Number.

Definition at line 434 of file cplex.cpp.

References ComplexNumber(), csinh(), and z.

435 {
436  return new ComplexNumber(csinh(z));
437 }
complex z
Definition: cplex.h:141
complex csinh(complex z)
Hyperbolic sine of a complex number.
Definition: csinh.c:50
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ HypTangent()

Number * ComplexNumber::HypTangent ( )
virtual

Implements Number.

Definition at line 444 of file cplex.cpp.

References ComplexNumber(), ctanh(), and z.

445 {
446  return new ComplexNumber(ctanh(z));
447 }
complex z
Definition: cplex.h:141
complex ctanh(complex z)
Hyperbolic tangent of a complex number.
Definition: ctanh.c:53
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ IsInfinite()

bool ComplexNumber::IsInfinite ( )
virtual

Returns true if number is infinite.

Implements Number.

Definition at line 136 of file cplex.cpp.

References cimag(), creal(), FloatUnion64::floatingPoint, FloatUnion64::IsInf(), FloatUnion64::IsMaxNegative(), FloatUnion64::IsMaxPositive(), and z.

137 {
138  double a = creal(z);
139  double b = cimag(z);
140 
141  // Handle subnormal values
142  bool subInf =
143  (a > 0 && a <= 1e-308) || (a < 0 && a >= -1e-308) ||
144  (b > 0 && b <= 1e-308) || (b < 0 && b >= -1e-308);
145 
146  if (subInf)
147  {
148  return true;
149  }
150 
151  FloatUnion64 d, e;
152  d.floatingPoint = a;
153  e.floatingPoint = b;
154  return d.IsInf() || e.IsInf() ||
155  d.IsMaxPositive() || d.IsMaxNegative() ||
156  e.IsMaxPositive() || e.IsMaxNegative();
157 }
double cimag(complex z)
Imaginary part of complex number.
Definition: prim.c:46
complex z
Definition: cplex.h:141
bool IsInf() const
Definition: numb.h:47
bool IsMaxNegative() const
Definition: numb.h:50
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
double floatingPoint
Definition: numb.h:53
bool IsMaxPositive() const
Definition: numb.h:49
Here is the call graph for this function:

◆ IsNaN()

bool ComplexNumber::IsNaN ( )
virtual

Returns true if number is NaN.

Implements Number.

Definition at line 125 of file cplex.cpp.

References cimag(), creal(), FloatUnion64::floatingPoint, FloatUnion64::IsNaN(), and z.

126 {
127  FloatUnion64 d, e;
128  d.floatingPoint = creal(z);
129  e.floatingPoint = cimag(z);
130  return d.IsNaN() || e.IsNaN();
131 }
bool IsNaN() const
Definition: numb.h:48
double cimag(complex z)
Imaginary part of complex number.
Definition: prim.c:46
complex z
Definition: cplex.h:141
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
double floatingPoint
Definition: numb.h:53
Here is the call graph for this function:

◆ IsNegative()

bool ComplexNumber::IsNegative ( )
virtual

Implements Number.

Definition at line 106 of file cplex.cpp.

References cimag(), creal(), FloatUnion64::floatingPoint, FloatUnion64::IsNegative(), and z.

107 {
108  FloatUnion64 d, e;
109  d.floatingPoint = creal(z);
110  e.floatingPoint = cimag(z);
111  return d.IsNegative() && e.IsNegative();
112 }
double cimag(complex z)
Imaginary part of complex number.
Definition: prim.c:46
complex z
Definition: cplex.h:141
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
bool IsNegative() const
Definition: numb.h:45
double floatingPoint
Definition: numb.h:53
Here is the call graph for this function:

◆ IsNotImplemented()

bool ComplexNumber::IsNotImplemented ( )
virtual

Implements Number.

Definition at line 159 of file cplex.cpp.

160 {
161  return false;
162 }

◆ IsZero()

bool ComplexNumber::IsZero ( )
virtual

Implements Number.

Definition at line 114 of file cplex.cpp.

References cimag(), creal(), FloatUnion64::floatingPoint, FloatUnion64::IsZero(), and z.

115 {
116  FloatUnion64 d, e;
117  d.floatingPoint = creal(z);
118  e.floatingPoint = cimag(z);
119  return d.IsZero() && e.IsZero();
120 }
double cimag(complex z)
Imaginary part of complex number.
Definition: prim.c:46
complex z
Definition: cplex.h:141
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
double floatingPoint
Definition: numb.h:53
bool IsZero() const
Definition: numb.h:46
Here is the call graph for this function:

◆ Log()

Number * ComplexNumber::Log ( )
virtual

Implements Number.

Definition at line 320 of file cplex.cpp.

References cimag(), clog(), ComplexNumber(), creal(), nnnan, NonNumber::NonNumber(), and z.

321 {
322  if (creal(z) == 0.0 && cimag(z) == 0.0)
323  return new NonNumber(nnnan);
324 
325  return new ComplexNumber(clog(z));
326 }
Represent a number which does not exists.
Definition: nnumb.h:51
double cimag(complex z)
Imaginary part of complex number.
Definition: prim.c:46
Definition: nnumb.h:42
complex z
Definition: cplex.h:141
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
ComplexNumber()
Definition: cplex.cpp:36
complex clog(complex z)
Natural logarithm of a complex number.
Definition: clog.c:42
Here is the call graph for this function:

◆ Log10()

Number * ComplexNumber::Log10 ( )
virtual

Implements Number.

Definition at line 336 of file cplex.cpp.

References cimag(), clog10(), ComplexNumber(), creal(), nnnan, NonNumber::NonNumber(), and z.

337 {
338  if (creal(z) == 0.0 && cimag(z) == 0.0)
339  return new NonNumber(nnnan);
340 
341  return new ComplexNumber(clog10(z));
342 }
Represent a number which does not exists.
Definition: nnumb.h:51
complex clog10(complex z)
Base 10 logarithmic value of complex number.
Definition: clog10.c:41
double cimag(complex z)
Imaginary part of complex number.
Definition: prim.c:46
Definition: nnumb.h:42
complex z
Definition: cplex.h:141
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ Log2()

Number * ComplexNumber::Log2 ( )
virtual

Implements Number.

Definition at line 328 of file cplex.cpp.

References cimag(), clogb(), ComplexNumber(), creal(), nnnan, NonNumber::NonNumber(), and z.

329 {
330  if (creal(z) == 0.0 && cimag(z) == 0.0)
331  return new NonNumber(nnnan);
332 
333  return new ComplexNumber(clogb(z));
334 }
Represent a number which does not exists.
Definition: nnumb.h:51
double cimag(complex z)
Imaginary part of complex number.
Definition: prim.c:46
Definition: nnumb.h:42
complex z
Definition: cplex.h:141
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
ComplexNumber()
Definition: cplex.cpp:36
complex clogb(complex z)
Base 2 logarithmic value of complex number.
Definition: clogb.c:41
Here is the call graph for this function:

◆ Mul()

Number * ComplexNumber::Mul ( Number other)
virtual

Implements Number.

Definition at line 210 of file cplex.cpp.

References cmul(), ComplexNumber(), cpack(), Number::IsNaN(), nnnan, NonNumber::NonNumber(), nsyscomplex, nsysreal, Number::system, RealNumber::x, and z.

211 {
212  if (other->IsNaN())
213  return new NonNumber(nnnan);
214 
215  if (other->system == nsyscomplex)
216  {
217  ComplexNumber *w = static_cast<ComplexNumber *>(other);
218  return new ComplexNumber(cmul(z, w->z));
219  }
220 
221  if (other->system == nsysreal)
222  {
223  RealNumber *a = static_cast<RealNumber *>(other);
224  return new ComplexNumber(cmul(z, cpack(a->x, 0.0)));
225  }
226 
227  return new ComplexNumber();
228 }
Represent a number which does not exists.
Definition: nnumb.h:51
complex cmul(complex y, complex z)
Multiplication of two complex numbers.
Definition: prim.c:140
complex cpack(double x, double y)
Pack two real numbers into a complex number.
Definition: prim.c:68
Definition: nnumb.h:42
NumberSystem system
Definition: numb.h:171
complex z
Definition: cplex.h:141
virtual bool IsNaN()=0
Represent a real number with 15 significant digits.
Definition: real.h:45
ComplexNumber()
Definition: cplex.cpp:36
double x
Definition: real.h:143
Represent a complex number with 2 components of 15 significant digits.
Definition: cplex.h:46
Definition: numb.h:61
Here is the call graph for this function:

◆ PureComplexValue()

bool ComplexNumber::PureComplexValue ( )
virtual

Implements Number.

Definition at line 80 of file cplex.cpp.

References creal(), and z.

81 {
82  return (creal(z) == 0.0);
83 }
complex z
Definition: cplex.h:141
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
Here is the call graph for this function:

◆ Raise()

Number * ComplexNumber::Raise ( Number exponent)
virtual

Implements Number.

Definition at line 250 of file cplex.cpp.

References ComplexNumber(), cpack(), cpow(), Number::IsNaN(), nnnan, NonNumber::NonNumber(), nsyscomplex, nsysreal, Number::system, RealNumber::x, and z.

Referenced by RealNumber::Raise().

251 {
252  if (exponent->IsNaN())
253  return new NonNumber(nnnan);
254 
255  if (exponent->system == nsyscomplex)
256  {
257  ComplexNumber *w = static_cast<ComplexNumber *>(exponent);
258  return new ComplexNumber(cpow(z, w->z));
259  }
260 
261  if (exponent->system == nsysreal)
262  {
263  RealNumber *a = static_cast<RealNumber *>(exponent);
264  return new ComplexNumber(cpow(z, cpack(a->x, 0.0)));
265  }
266 
267  return new ComplexNumber();
268 }
Represent a number which does not exists.
Definition: nnumb.h:51
complex cpack(double x, double y)
Pack two real numbers into a complex number.
Definition: prim.c:68
Definition: nnumb.h:42
NumberSystem system
Definition: numb.h:171
complex z
Definition: cplex.h:141
virtual bool IsNaN()=0
complex cpow(complex a, complex z)
Complex number raised to a power.
Definition: cpow.c:42
Represent a real number with 15 significant digits.
Definition: real.h:45
ComplexNumber()
Definition: cplex.cpp:36
double x
Definition: real.h:143
Represent a complex number with 2 components of 15 significant digits.
Definition: cplex.h:46
Definition: numb.h:61
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Reciprocal()

Number * ComplexNumber::Reciprocal ( )
virtual

Implements Number.

Definition at line 310 of file cplex.cpp.

References ComplexNumber(), creci(), and z.

311 {
312  return new ComplexNumber(creci(z));
313 }
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
complex creci(complex z)
Reciprocal value of complex number.
Definition: prim.c:181
Here is the call graph for this function:

◆ Round()

Number * ComplexNumber::Round ( )
virtual

Implements Number.

Definition at line 290 of file cplex.cpp.

References ComplexNumber(), cround(), and z.

291 {
292  return new ComplexNumber(cround(z));
293 }
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
complex cround(complex z)
Division of two complex numbers.
Definition: prim.c:110
Here is the call graph for this function:

◆ Secant()

Number * ComplexNumber::Secant ( )
virtual

Implements Number.

Definition at line 359 of file cplex.cpp.

References ComplexNumber(), csec(), and z.

360 {
361  return new ComplexNumber(csec(z));
362 }
complex z
Definition: cplex.h:141
complex csec(complex z)
Secant of a complex number.
Definition: csec.c:48
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ Signum()

Number * ComplexNumber::Signum ( )
virtual

Implements Number.

Definition at line 275 of file cplex.cpp.

References csgn(), RealNumber::RealNumber(), and z.

276 {
277  return new RealNumber(csgn(z));
278 }
complex z
Definition: cplex.h:141
double csgn(complex z)
Complex signum.
Definition: csgn.c:38
friend struct RealNumber
Definition: numb.h:167
Here is the call graph for this function:

◆ Sine()

Number * ComplexNumber::Sine ( )
virtual

Implements Number.

Definition at line 344 of file cplex.cpp.

References ComplexNumber(), csin(), and z.

345 {
346  return new ComplexNumber(csin(z));
347 }
complex z
Definition: cplex.h:141
complex csin(complex z)
Sine of a complex number.
Definition: csin.c:50
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ SquareRoot()

Number * ComplexNumber::SquareRoot ( )
virtual

Implements Number.

Definition at line 305 of file cplex.cpp.

References ComplexNumber(), csqrt(), and z.

306 {
307  return new ComplexNumber(csqrt(z));
308 }
complex csqrt(complex z)
Square root of complex number.
Definition: csqrt.c:42
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ Sub()

Number * ComplexNumber::Sub ( Number other)
virtual

Implements Number.

Definition at line 190 of file cplex.cpp.

References ComplexNumber(), cpack(), csub(), Number::IsNaN(), nnnan, NonNumber::NonNumber(), nsyscomplex, nsysreal, Number::system, RealNumber::x, and z.

191 {
192  if (other->IsNaN())
193  return new NonNumber(nnnan);
194 
195  if (other->system == nsyscomplex)
196  {
197  ComplexNumber *w = static_cast<ComplexNumber *>(other);
198  return new ComplexNumber(csub(z, w->z));
199  }
200 
201  if (other->system == nsysreal)
202  {
203  RealNumber *a = static_cast<RealNumber *>(other);
204  return new ComplexNumber(csub(z, cpack(a->x, 0.0)));
205  }
206 
207  return new ComplexNumber();
208 }
complex csub(complex y, complex z)
Subtraction of two complex numbers.
Definition: prim.c:130
Represent a number which does not exists.
Definition: nnumb.h:51
complex cpack(double x, double y)
Pack two real numbers into a complex number.
Definition: prim.c:68
Definition: nnumb.h:42
NumberSystem system
Definition: numb.h:171
complex z
Definition: cplex.h:141
virtual bool IsNaN()=0
Represent a real number with 15 significant digits.
Definition: real.h:45
ComplexNumber()
Definition: cplex.cpp:36
double x
Definition: real.h:143
Represent a complex number with 2 components of 15 significant digits.
Definition: cplex.h:46
Definition: numb.h:61
Here is the call graph for this function:

◆ Tangent()

Number * ComplexNumber::Tangent ( )
virtual

Implements Number.

Definition at line 354 of file cplex.cpp.

References ComplexNumber(), ctan(), and z.

355 {
356  return new ComplexNumber(ctan(z));
357 }
complex z
Definition: cplex.h:141
complex ctan(complex z)
Tangent of a complex number.
Definition: ctan.c:55
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ Trunc()

Number * ComplexNumber::Trunc ( )
virtual

Implements Number.

Definition at line 285 of file cplex.cpp.

References ComplexNumber(), ctrunc(), and z.

286 {
287  return new ComplexNumber(ctrunc(z));
288 }
complex ctrunc(complex z)
Truncated value of complex number.
Definition: prim.c:80
complex z
Definition: cplex.h:141
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ Unary()

Number * ComplexNumber::Unary ( )
virtual

Implements Number.

Definition at line 164 of file cplex.cpp.

References cimag(), ComplexNumber(), cpack(), creal(), and z.

165 {
166  complex w = cpack(-creal(z), -cimag(z));
167  return new ComplexNumber(w);
168 }
Definition: mathi.h:48
complex cpack(double x, double y)
Pack two real numbers into a complex number.
Definition: prim.c:68
double cimag(complex z)
Imaginary part of complex number.
Definition: prim.c:46
complex z
Definition: cplex.h:141
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
ComplexNumber()
Definition: cplex.cpp:36
Here is the call graph for this function:

◆ VerCosine()

Number * ComplexNumber::VerCosine ( )
virtual

Implements Number.

Definition at line 499 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

500 {
501  return new NonNumber(nnnimp);
502 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

◆ VerSine()

Number * ComplexNumber::VerSine ( )
virtual

Implements Number.

Definition at line 494 of file cplex.cpp.

References nnnimp, and NonNumber::NonNumber().

495 {
496  return new NonNumber(nnnimp);
497 }
Represent a number which does not exists.
Definition: nnumb.h:51
Definition: nnumb.h:45
Here is the call graph for this function:

Member Data Documentation

◆ z


The documentation for this struct was generated from the following files: