amath  1.8.5
Simple command line calculator
cplex.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  * Project homepage:
26  * https://amath.innolan.net
27  *
28  */
29 
30 #ifndef AMATH_COMPLEX_NUMBER_H
31 #define AMATH_COMPLEX_NUMBER_H
32 
33 /**
34  * @file cplex.h
35  * @brief Class based handling of complex numbers
36  */
37 
38 #include "numb.h"
39 #include "mathi.h"
40 
41 /**
42  * @brief Represent a complex number with 2 components of 15 significant digits
43  * @details
44  * Calculations are done using 64 bit IEEE 754 arithmetics.
45  */
46 struct ComplexNumber : public Number
47 {
48 public:
49  ComplexNumber();
50  explicit ComplexNumber(complex z);
51  ComplexNumber(double real, double imag);
52  ~ComplexNumber();
53 
54  Number* Clone();
55  int GetIntegerValue();
56  double GetRealValue();
57  double GetImagValue() const;
58  complex GetComplexValue() const;
59  bool PureComplexValue();
60  int GetPrecedence();
62  bool IsNegative();
63  bool IsZero();
64  bool IsNaN();
65  bool IsInfinite();
66  bool IsNotImplemented();
67 
68  Number* Unary();
69  Number* Add(Number* other);
70  Number* Sub(Number* other);
71  Number* Mul(Number* other);
72  Number* Div(Number* other);
73  Number* Raise(Number* exponent);
74 
75  Number* Signum();
76  Number* Trunc();
77  Number* Round();
78  Number* Floor();
79  Number* Ceiling();
80  Number* Absolute();
81  Number* SquareRoot();
82  Number* CubeRoot();
83  Number* Reciprocal();
84  Number* Factorial();
85 
86  Number* Log();
87  Number* Log2();
88  Number* Log10();
89 
90  Number* Sine();
91  Number* Cosine();
92  Number* Tangent();
93  Number* Cosecant();
94  Number* Secant();
95  Number* Cotangent();
96  Number* Chord();
97  Number* ExSecant();
98  Number* ExCosecant();
99  Number* ArcSine();
100  Number* ArcCosine();
101  Number* ArcTangent();
102  Number* ArcCosecant();
103  Number* ArcSecant();
104  Number* ArcCotangent();
105  Number* ArcExSecant();
107  Number* ArcChord();
108 
109  Number* HypSine();
110  Number* HypCosine();
111  Number* HypTangent();
112  Number* HypCosecant();
113  Number* HypSecant();
114  Number* HypCotangent();
115  Number* HypArcSine();
116  Number* HypArcCosine();
119  Number* HypArcSecant();
121 
122  Number* VerSine();
123  Number* VerCosine();
124  Number* CoVerSine();
125  Number* CoVerCosine();
126  Number* HaVerSine();
127  Number* HaVerCosine();
128  Number* HaCoVerSine();
130 
131  Number* ArcVerSine();
132  Number* ArcVerCosine();
133  Number* ArcCoVerSine();
135  Number* ArcHaVerSine();
139 
140 private:
141  complex z;
142 };
143 
144 #endif
Number * ArcVerSine()
Definition: cplex.cpp:534
Number * Floor()
Definition: cplex.cpp:295
Number * ArcExCosecant()
Definition: cplex.cpp:429
ComplexNumber(complex z)
Definition: cplex.cpp:41
Number * ArcTangent()
Definition: cplex.cpp:399
Number * HypArcCotangent()
Definition: cplex.cpp:489
Number * HypCosecant()
Definition: cplex.cpp:454
int GetPrecedence()
Definition: cplex.cpp:85
Number * HaVerCosine()
Definition: cplex.cpp:519
Number * HypCotangent()
Definition: cplex.cpp:459
Number * Cotangent()
Definition: cplex.cpp:369
int GetIntegerValue()
Definition: cplex.cpp:60
Number * SquareRoot()
Definition: cplex.cpp:305
Number * HaCoVerSine()
Definition: cplex.cpp:524
Number * ArcCoVerSine()
Definition: cplex.cpp:544
Number * Log()
Definition: cplex.cpp:320
Number * CoVerSine()
Definition: cplex.cpp:504
Number * HypArcSecant()
Definition: cplex.cpp:479
Number * Secant()
Definition: cplex.cpp:359
Number * VerSine()
Definition: cplex.cpp:494
Number * Reciprocal()
Definition: cplex.cpp:310
complex z
Definition: cplex.h:141
Number * Unary()
Definition: cplex.cpp:164
int GetDefaultPrecedence()
Definition: cplex.cpp:101
Number * ArcExSecant()
Definition: cplex.cpp:424
Number * HypTangent()
Definition: cplex.cpp:444
Definition: numb.h:66
Number * Clone()
Definition: cplex.cpp:55
Number * Tangent()
Definition: cplex.cpp:354
Number * HypSecant()
Definition: cplex.cpp:449
Number * HypArcTangent()
Definition: cplex.cpp:474
Number * ArcCosine()
Definition: cplex.cpp:394
Number * HypArcCosecant()
Definition: cplex.cpp:484
double GetRealValue()
Definition: cplex.cpp:65
bool IsNegative()
Definition: cplex.cpp:106
Number * Div(Number *other)
Definition: cplex.cpp:230
Number * Trunc()
Definition: cplex.cpp:285
Number * ArcHaCoVerCosine()
Definition: cplex.cpp:569
Number * Add(Number *other)
Definition: cplex.cpp:170
Number * ArcHaVerCosine()
Definition: cplex.cpp:559
Number * ArcVerCosine()
Definition: cplex.cpp:539
bool IsZero()
Definition: cplex.cpp:114
Number * HypSine()
Definition: cplex.cpp:434
ComplexNumber()
Definition: cplex.cpp:36
Number * HypCosine()
Definition: cplex.cpp:439
Number * ArcChord()
Definition: cplex.cpp:419
Number * HaCoVerCosine()
Definition: cplex.cpp:529
Number * HaVerSine()
Definition: cplex.cpp:514
Number * Log10()
Definition: cplex.cpp:336
Number * Cosecant()
Definition: cplex.cpp:364
Number * Absolute()
Definition: cplex.cpp:280
Number * ArcHaCoVerSine()
Definition: cplex.cpp:564
Represent a complex number with 2 components of 15 significant digits.
Definition: cplex.h:46
bool IsNaN()
Returns true if number is NaN.
Definition: cplex.cpp:125
Number * Sine()
Definition: cplex.cpp:344
Number * VerCosine()
Definition: cplex.cpp:499
complex GetComplexValue() const
Definition: cplex.cpp:75
Number * ExSecant()
Definition: cplex.cpp:379
Number * Sub(Number *other)
Definition: cplex.cpp:190
Number * ArcSine()
Definition: cplex.cpp:389
Number * Signum()
Definition: cplex.cpp:275
Number * HypArcCosine()
Definition: cplex.cpp:469
Number * Round()
Definition: cplex.cpp:290
ComplexNumber(double real, double imag)
Definition: cplex.cpp:46
Number * ExCosecant()
Definition: cplex.cpp:384
Number * Ceiling()
Definition: cplex.cpp:300
~ComplexNumber()
Definition: cplex.cpp:51
Number * HypArcSine()
Definition: cplex.cpp:464
Number * Chord()
Definition: cplex.cpp:374
Number * ArcCosecant()
Definition: cplex.cpp:409
Number * CubeRoot()
Definition: cplex.cpp:315
Number * ArcCoVerCosine()
Definition: cplex.cpp:549
Number * ArcSecant()
Definition: cplex.cpp:404
double GetImagValue() const
Definition: cplex.cpp:70
Number * ArcHaVerSine()
Definition: cplex.cpp:554
Number * Log2()
Definition: cplex.cpp:328
bool PureComplexValue()
Definition: cplex.cpp:80
bool IsNotImplemented()
Definition: cplex.cpp:159
Number * CoVerCosine()
Definition: cplex.cpp:509
Number * ArcCotangent()
Definition: cplex.cpp:414
Number * Cosine()
Definition: cplex.cpp:349
bool IsInfinite()
Returns true if number is infinite.
Definition: cplex.cpp:136
Number * Mul(Number *other)
Definition: cplex.cpp:210
Number * Raise(Number *exponent)
Definition: cplex.cpp:250
Number * Factorial()
Definition: cplex.cpp:270