Documentation of CSL
parent.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 
21 #ifndef PARENT_H_INCLUDED
22 #define PARENT_H_INCLUDED
23 
24 #include "abstract.h"
25 
26 namespace csl {
27 class Space;
28 class Permutation;
29 class Symmetry;
30 class ContractionChain;
31 }
32 
36 namespace cslParent{
37 
40 
41  Literal,
44  };
45 
47  enum Type{
48 
49  Constant,
50  Variable,
54  Epsilon,
57  };
58 }
59 
60 namespace csl {
61 
81 class AbstractParent: public std::enable_shared_from_this<AbstractParent>{
82 
83  protected:
84 
87  std::string name;
88 
91  std::string latexName;
92 
96  bool commutable;
97 
99 
102  std::vector<Equation*> props;
103 
104  public:
105 
108  AbstractParent();
109 
113  explicit AbstractParent(const std::string& t_name);
114 
117  AbstractParent(const AbstractParent& abstract) = default;
118 
121  virtual ~AbstractParent(){};
122 
123  Parent self();
124 
125  virtual bool isAnAbbreviation() const { return false; }
126 
129  std::string const &getName() const;
130 
131  std::string const &getLatexName() const;
132 
133  virtual std::string const &getBaseName() const;
134 
137  bool getCommutable() const;
138 
139  csl::ComplexProperty getComplexProp() const;
140 
143  virtual void setName(std::string t_name);
144 
145  virtual void setLatexName(const std::string& t_name);
146 
149  void setCommutable(bool t_commutable);
150 
151  virtual
152  void setComplexProperty(csl::ComplexProperty t_prop);
153 
157  void addProperty(Equation* prop);
158 
162  void removeProperty(Equation* prop);
163 
166  virtual cslParent::PrimaryType getPrimaryType() const = 0;
167 
170  virtual cslParent::Type getType() const = 0;
171 
174  virtual int getDim() const;
175 
176  virtual void printDefinition(
177  std::ostream &out = std::cout,
178  int indentSize = 4,
179  bool header = false
180  ) const = 0;
181 
182  void printPropDefinition(
183  std::ostream &out,
184  int indentSize,
185  bool header
186  ) const;
187 
188  virtual
189  void enableEvaluation();
190 
191  virtual
192  void disableEvaluation();
193 
194  virtual
195  void toggleEvaluation();
196 
197  virtual
198  std::optional<Expr> evaluate(
199  Expr_info self,
200  csl::eval::mode user_mode = csl::eval::base) const;
201 
202  virtual
203  Expr const &getEncapsulated() const;
204 
205  virtual
206  Expr getExactEncapsulated(Expr_info self) const;
207 
208  virtual
209  void setEncapsulated(Expr const &);
210 
216  virtual int getDim(const Space* t_space) const;
217 
218  virtual std::vector<const Space*> getSpace() const;
219 
220  virtual const Space* getFieldSpace() const;
221 
222  virtual void setFieldSpace(const Space* t_space);
223 
228  virtual bool getFullySymmetric() const;
229 
234  virtual bool getFullyAntiSymmetric() const;
235 
242  virtual std::vector<Permutation> getPermutation() const;
243 
244  virtual bool isValued() const;
245 
250  virtual Expr getTensor() const;
251 
252  virtual Expr getTensor(Expr_info expr) const;
253 
257  virtual Expr getTrace() const;
258 
264  virtual bool dependsOn(Expr_info expr) const;
265 
272  virtual bool dependsExplicitlyOn(Expr_info expr) const;
273 
276  virtual const std::vector<Equation*>& getProperties() const;
277 
281  virtual void addSpace(const Space* t_space);
282 
285  virtual void setFullySymmetric();
286 
289  virtual void setFullyAntiSymmetric();
290 
291  virtual bool isTraceLessIn(csl::Space const* space) const;
292  virtual void addTraceLessNess(csl::Space const* space);
293  virtual void removeTraceLessNess(csl::Space const* space);
294 
299  virtual void addSymmetry(int i1, int i2);
300 
305  virtual void addAntiSymmetry(int i1, int i2);
306 
312  virtual void setSymmetry(const Symmetry& t_symmetry);
313 
317  virtual void setTensor(const Expr& t_tensor);
318 
319  virtual void setTrace(const Expr& t_trace);
320 
328  virtual bool hasContractionProperty(const Abstract* self,
329  Expr_info B) const;
330 
337  virtual Expr contraction(const Abstract* self, Expr_info B) const;
338 
339  virtual bool hasChainContractionProperty() const;
340 
341  virtual std::vector<ContractionChain>
342  getContractionProperties() const;
343 
344  virtual void addContractionProperty(
345  csl::vector_expr const& leftHandSide,
346  const Expr& rightHandSide);
347 
348  virtual void removeContractionProperty(
349  csl::vector_expr const& leftHandSide,
350  const Expr& rightHandSide);
351 
358  virtual void addSelfContraction(
359  const Expr& A,
360  const Expr& B,
361  const Expr& res,
362  std::optional<std::function<bool(Expr_info, Expr_info)>>
363  condition = std::nullopt);
364 
365  virtual void removeSelfContraction(
366  const Expr& A,
367  const Expr& B
368  );
369 
370  virtual std::optional<Expr> getComplexProperty(
371  Expr_info self
372  ) const;
373 
374  virtual std::optional<Expr> getHermitianProperty(
375  Expr_info self,
376  const Space* space
377  ) const;
378 
379  virtual std::optional<Expr> getTransposedProperty(
380  Expr_info self,
381  const Space* space
382  ) const;
383 
384  virtual void addComplexProperty(const Expr& init,
385  const Expr& res);
386 
387  virtual void addHermitianProperty(const Space* space,
388  const Expr& init,
389  const Expr& res);
390 
391  virtual void addTransposedProperty(const Space* space,
392  const Expr& init,
393  const Expr& res);
394 
395  virtual
396  std::vector<Parent> getBrokenParts(const Space* broken) const;
397 
398  virtual
399  std::vector<Parent> breakSpace(
400  const Space* broken,
401  const std::vector<const Space*>& newSpace,
402  const std::vector<size_t>& pieces
403  ) const;
404 
410  virtual Expr operator()(Index index);
411 
412  virtual Expr operator()(const Tensor& point);
413 
419  virtual Expr operator()(std::vector<Index> indices);
420 
421  virtual Expr operator()(const std::vector<int>& indices);
422 
423  virtual Expr operator()(Index index,
424  const Tensor& point);
425 
426  virtual Expr operator()(std::vector<Index> indices,
427  const Tensor& point);
428 
429  virtual Expr operator()(const std::vector<int>& indices,
430  const Tensor& point);
431 
436  friend std::ostream& operator<<(std::ostream& fout, const AbstractParent&);
437 };
438 
439 class Parent: public std::shared_ptr<AbstractParent> {
440 
441  public:
442 
443  INHERIT_SHARED_PTR_CONSTRUCTOR(Parent, AbstractParent)
444 
445  template<class ...Args>
446  inline
447  Expr operator()(Args&& ...args)
448  {
449  return (**this)(args...);
450  }
451 
452  template<class ...Args>
453  inline
454  Expr operator()(std::vector<Index> indices, Args&& ...args)
455  {
456  return (**this)(indices, args...);
457  }
458 
459 };
460 
461 
462 } // End of namespace csl
463 
464 #endif
std::string name
Definition: parent.h:87
Definition: parent.h:51
Namespace for csl library.
Definition: abreviation.h:34
Definition: parent.h:439
Index object that is used for indicial objects.
Definition: index.h:75
Stores types of parents.
Handles the full symmetry properties of an TensorElement, i.e. a vector of Permutation objects...
Definition: symmetry.h:277
std::string latexName
Definition: parent.h:91
PrimaryType
Definition: parent.h:39
virtual ~AbstractParent()
Destructor.
Definition: parent.h:121
Definition: diagonalization.h:34
ComplexProperty
Contains all possible complex properties of objects. Real, purely imaginary, or complex.
Definition: enum.h:127
Definition: parent.h:52
Root class of the inheritance tree of abstracts.
Definition: abstract.h:76
Vector space that has a name, a dimension, a delta tensor and possibly a non-trivial metric...
Definition: space.h:64
Definition: parent.h:53
Base class for all parents (indicial, fields etc). All parents derive from this class.
Definition: parent.h:81
std::vector< Equation * > props
Definition: parent.h:102
Type
Definition: parent.h:47
Base classes for all exprs in the program.
Definition: equation.h:43
bool commutable
Definition: parent.h:96
Definition: indicial.h:675
Expression type/.
Definition: abstract.h:1573