Documentation of CSL
cslcomplex.h
Go to the documentation of this file.
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
23 #ifndef COMPLEX_H_INCLUDED
24 #define COMPLEX_H_INCLUDED
25 
26 #include "scalarFunc.h"
27 #include "operator.h"
28 
29 namespace csl {
30 
31 class RealPart: public Operator<AbstractFunc> {
32 
33  public:
34 
35  RealPart();
36 
37  RealPart(const Expr& t_argument);
38 
39  ~RealPart(){};
40 
41  csl::Type getType() const override;
42 
43  bool operatorAppliesOn(Expr_info arg) const override;
44 
45  Expr getOperand() const override;
46 
47  void setOperand(const Expr& t_operand) override;
48 
49  void print(int mode = 0,
50  std::ostream& out = std::cout,
51  bool lib = false) const override;
52 
53  std::string printLaTeX(int mode = 0) const override;
54 
55  LibDependency getLibDependency() const override;
56 
57  std::optional<Expr> evaluate(
58  csl::eval::mode user_mode = csl::eval::base
59  ) const override;
60 
61  unique_Expr copy_unique() const override;
62 
63  Expr deepCopy() const override;
64 
65  Expr refresh() const override;
66 
67  Expr deepRefresh() const override;
68 
69  bool isReal() const override;
70 
71  bool isPurelyImaginary() const override;
72 
73  std::optional<Expr> getComplexConjugate() const override;
74 
75  bool operator==(Expr_info other) const override;
76 };
77 
78 class ImaginaryPart: public Operator<AbstractFunc> {
79 
80  public:
81 
82  ImaginaryPart();
83 
84  ImaginaryPart(const Expr& t_argument);
85 
86  ~ImaginaryPart(){};
87 
88  csl::Type getType() const override;
89 
90  bool operatorAppliesOn(Expr_info arg) const override;
91 
92  Expr getOperand() const override;
93 
94  void setOperand(const Expr& t_operand) override;
95 
96  void print(int mode = 0,
97  std::ostream& out = std::cout,
98  bool lib = false) const override;
99 
100  std::string printLaTeX(int mode = 0) const override;
101 
102  LibDependency getLibDependency() const override;
103 
104  std::optional<Expr> evaluate(
105  csl::eval::mode user_mode = csl::eval::base
106  ) const override;
107 
108  unique_Expr copy_unique() const override;
109 
110  Expr deepCopy() const override;
111 
112  Expr refresh() const override;
113 
114  Expr deepRefresh() const override;
115 
116  bool isReal() const override;
117 
118  bool isPurelyImaginary() const override;
119 
120  std::optional<Expr> getComplexConjugate() const override;
121 
122  bool operator==(Expr_info other) const override;
123 };
124 
125 Expr real_s(const Expr& expr);
126 
127 Expr imaginary_s(const Expr& expr);
128 
129 Expr cconjugate_(const Expr& expr);
130 } // End of namespace csl
131 
132 #endif
bool operator==(Expr_info other) const override
Compares the Abstract with another.
Definition: cslcomplex.cpp:162
Namespace for csl library.
Definition: abreviation.h:34
Type
Enum of the different types of Abstract (i.e. list of all possible specializations).
Definition: enum.h:47
std::optional< Expr > evaluate(csl::eval::mode user_mode=csl::eval::base) const override
Evaluates the Abstract.
Definition: cslcomplex.cpp:99
Expr getOperand() const override
Returns the operand of an Operator.
Definition: cslcomplex.cpp:52
Generic template to handle operator expression, i.e. expression that applies on expressions on the ri...
Definition: librarydependency.h:33
Definition: cslcomplex.h:78
Root class of the inheritance tree of abstracts.
Definition: abstract.h:76
Base classes for scalar functions.
Definition: cslcomplex.h:31
csl::Type getType() const override
Gives the type of Abstract.
Definition: cslcomplex.cpp:42
void print(int mode=0, std::ostream &out=std::cout, bool lib=false) const override
Displays the abstract in standard output.
Definition: cslcomplex.cpp:62
std::string printLaTeX(int mode=0) const override
Creates a LaTeX output for the Abstract.
Definition: cslcomplex.cpp:82
Linear operator O(a*X+b*Y) = a*O(X) + b*O(Y)
Definition: operator.h:38
std::optional< Expr > getComplexConjugate() const override
Calculates and returns the complex conjugate of the expression.
Definition: cslcomplex.cpp:157
Expression type/.
Definition: abstract.h:1573
void setOperand(const Expr &t_operand) override
Sets the operand of an operator.
Definition: cslcomplex.cpp:57