Documentation of CSL
buildingBlock.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 BUILDINGBLOCK_H_INCLUDED
24 #define BUILDINGBLOCK_H_INCLUDED
25 
26 #include "abstract.h"
27 
28 namespace csl {
29 
35  public:
36 
38 
39  bool isBuildingBlock() const override { return true;}
40 
41  virtual bool commutesWith(Expr_info expr, int sign=-1) const override;
42 
43  std::optional<Expr> expand(bool full=false,
44  bool inplace=false) const override;
45 
46  std::optional<Expr> factor(bool full=false) const override;
47 
48  std::optional<Expr> factor(Expr_info expr, bool full=false) const override;
49 
50  std::optional<Expr> getTerm() const override;
51 
52  std::optional<Expr> getRealPart() const override;
53 
54  std::optional<Expr> getComplexModulus() const override;
55 
56  std::optional<Expr> getPolynomialTerm(
57  Expr_info expr, int order) const override;
58 
59  std::optional<Expr> findSubExpression(
60  Expr_info subExpression,
61  const Expr& newExpression) const override;
62 };
63 
64 /*************************************************/
65 // Inline functions (non virtual and short) //
66 /*************************************************/
67 inline AbstractBuildingBlock::AbstractBuildingBlock(): Abstract(){}
68 
70 
71  public:
72 
73  Complexified();
74 
75  bool isReal() const override;
76 
77  bool isPurelyImaginary() const override;
78 
79  bool isComplexConjugate() const override;
80 
81  std::optional<Expr> getRealPart() const override;
82 
83  Expr getImaginaryPart() const override;
84 
85  std::optional<Expr> getComplexConjugate() const override;
86 
87  void setConjugated(bool t_conjugated) override;
88 
89  void printProp(std::ostream& fout = std::cout) const override;
90 
91  csl::ComplexProperty getComplexProperty() const override;
92 
93  void setComplexProperty(csl::ComplexProperty prop) override;
94 
95  bool operator==(Expr_info other) const override;
96 
97  protected:
98 
99  void applyComplexPropertiesOn(const Expr& expr) const;
100 
101  void applyComplexPropertiesOn(unique_Expr& expr) const;
102 
103  protected:
104 
105  bool conjugated = false;
106 };
107 
108 } // End of namespace csl
109 
110 #endif
Definition: buildingBlock.h:69
Namespace for csl library.
Definition: abreviation.h:34
std::optional< Expr > getPolynomialTerm(Expr_info expr, int order) const override
Calculates and returns the polynomial term corresponding to *this with the variable t_variable at ord...
Definition: buildingBlock.cpp:57
Abstract class from which derive all building blocks of exprs, i.e. objects not function of further e...
Definition: buildingBlock.h:34
std::optional< Expr > getTerm() const override
This function returns the same expression as *this but amputated of its numerical factor...
Definition: buildingBlock.cpp:44
std::optional< Expr > getComplexModulus() const override
Evaluates the modulus in the complex plane of the Abstract and returns it.
Definition: buildingBlock.cpp:53
std::optional< Expr > factor(bool full=false) const override
Factors the Abstract.
Definition: buildingBlock.cpp:36
Abstract()
Default Constructor.
Definition: abstract.h:92
ComplexProperty
Contains all possible complex properties of objects. Real, purely imaginary, or complex.
Definition: enum.h:127
virtual bool operator==(int t_value) const
Definition: abstract.cpp:988
std::optional< Expr > getRealPart() const override
Evaluates the real part of the Abstract and returns it.
Definition: buildingBlock.cpp:49
virtual bool commutesWith(Expr_info expr, int sign=-1) const override
Tells if the object commutes with expr.
Definition: buildingBlock.cpp:75
Root class of the inheritance tree of abstracts.
Definition: abstract.h:76
std::optional< Expr > expand(bool full=false, bool inplace=false) const override
Develops the Abstract.
Definition: buildingBlock.cpp:32
virtual Expr getImaginaryPart() const
Evaluates the imaginary part of the Abstract and returns it.
Definition: abstract.cpp:667
Base classes for all exprs in the program.
std::optional< Expr > findSubExpression(Expr_info subExpression, const Expr &newExpression) const override
Searches a sub-expression and replaces it.
Definition: buildingBlock.cpp:66
virtual std::optional< Expr > getComplexConjugate() const
Calculates and returns the complex conjugate of the expression.
Definition: abstract.cpp:682
bool isBuildingBlock() const override
Tells if the expression is a Building Block or not.
Definition: buildingBlock.h:39
Expression type/.
Definition: abstract.h:1573