Documentation of CSL
comparison.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 COMPARISON_H_INCLUDED
24 #define COMPARISON_H_INCLUDED
25 
26 #include "abstract.h"
27 #include "literal.h"
28 #include "numerical.h"
29 
30 namespace csl {
31 
48 class Arbitrary: public AbstractLiteral{
49 
50  public:
51 
52  /* \brief Constructor.
53  * \param n Index of the Arbitrary object, will determine its identity
54  * in comparisons.
55  * \param t_type Specific type that can be set. If given, the Arbitrary will
56  * be compared to only that type of expressions.
57  */
58  Arbitrary(int n, csl::Type t_type=csl::Type::NoType);
59 
60  Arbitrary(const Arbitrary& other) = default;
61 
64 
65  std::string const &getName() const override;
66 
67  bool isArbitrary() const override;
68 
69  csl::PrimaryType getPrimaryType() const override;
70 
71  csl::Type getType() const override;
72 
73  void print(int mode=0,
74  std::ostream& out=std::cout,
75  bool lib = false) const override;
76 
77  std::string printLaTeX(int mode=0) const override;
78 
79  std::optional<Expr> evaluate(
80  csl::eval::mode user_mode = csl::eval::base
81  ) const override;
82 
83  unique_Expr copy_unique() const override;
84 
85  long long int getNum() const override;
86 
87  bool operator==(Expr_info expr) const override;
88 
89  bool operator<(const Abstract* expr) const override;
90 
91 
92  private:
93 
96  int number;
97 
98  std::string name;
99 
104  csl::Type type;
105 };
106 
116 
117  friend class Arbitrary;
118  // Member functions
119 
120  public:
121 
127  static Expr dummy(int n, csl::Type type=csl::Type::NoType);
128 
137  static bool dummyComparison(Expr_info expr, Expr_info dummyExpr);
138 
139  static bool dummyComparison(Expr const& expr, Expr const& dummyExpr);
140 
141  static bool dummyVecIntComparison(Expr_info A,
142  Expr_info B);
143 
147  return freeIndexComparisonActive;
148  }
149 
150  static void setFreeIndexComparisonActive(bool t_activ);
151 
155  static std::string dummyName();
156 
164  static bool freeIndexComparison(const Abstract* A, Expr_info B);
165 
172  static bool compare(const Index& A, const Index& B);
173 
176  static void clear();
177 
180  static bool getDummyComparisonActive() {
181  return dummyComparisonActive;
182  }
183 
184  static bool getDummyVecIntComparisonActive() {
185  return dummyVecIntComparisonActive;
186  }
187 
190  static void setDummyComparisonActive(bool state);
191 
192  static void setDummyVecIntComparisonActive(bool state);
193 
194  private:
195 
202  static bool compare(Expr_info expr, Expr_info dummy);
203 
204  // Static Attributes
205 
206  public:
207 
214 
219  static std::map<Index,Index> indexCorrespondance;
220 
221  static bool dummyVecIntComparisonActive;
222 
223  private:
224 
227  static bool dummyComparisonActive;
228 
232  static std::map<int,Expr> arbitrary;
233 
240  static std::map<int,Expr> correspondance;
241 };
242 
243 } // End of namespace csl
244 
245 #endif
std::string printLaTeX(int mode=0) const override
Creates a LaTeX output for the Abstract.
Definition: comparison.cpp:78
~Arbitrary()
Destructor.
Definition: comparison.h:63
static bool freeIndexComparisonActive
Tells if the index comparison is active or not. If true, two different indices (even free indices) c...
Definition: comparison.h:213
Namespace for csl library.
Definition: abreviation.h:34
Index object that is used for indicial objects.
Definition: index.h:75
static bool getDummyComparisonActive()
Definition: comparison.h:180
static std::map< Index, Index > indexCorrespondance
Correspondance between indices during the comparison. Allows to keep track of all index comparisons w...
Definition: comparison.h:219
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: comparison.cpp:83
std::string const & getName() const override
Returns the Abstract&#39;s name.
Definition: comparison.cpp:53
PrimaryType
Stores enumerations of types for Abstract objects.
Definition: enum.h:31
Root class of the inheritance tree of abstracts.
Definition: abstract.h:76
Arbitrary object that can enter mathematical expressions.
Definition: comparison.h:48
void print(int mode=0, std::ostream &out=std::cout, bool lib=false) const override
Displays the abstract in standard output.
Definition: comparison.cpp:68
static bool getFreeIndexComparisonActive()
Definition: comparison.h:146
Base classes for all exprs in the program.
Abstract class from which derive literal building blocks: Constant, Variable, Imaginary and IntFactor...
Definition: literal.h:35
bool operator==(Expr_info expr) const override
Compares the Abstract with another.
Definition: comparison.cpp:97
long long int getNum() const override
Definition: comparison.cpp:63
csl::PrimaryType getPrimaryType() const override
Gives the primary type of Abstract.
Definition: comparison.cpp:43
csl::Type getType() const override
Gives the type of Abstract.
Definition: comparison.cpp:48
Bunch of functions that allow to do comparisons with Arbitrary expressions or expressions with dummy ...
Definition: comparison.h:115
Expression type/.
Definition: abstract.h:1573