Documentation of CSL
interface.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 INTERFACE_H_INCLUDED
24 #define INTERFACE_H_INCLUDED
25 
26 #include "abstract.h"
27 #include "parent.h"
28 #include "options.h"
29 
30 namespace csl {
31 
32 class TensorField;
33 class TDerivative;
34 
35 template<class T>
36 [[nodiscard]]
37 inline csl::Type GetType(T const &expr)
38 {
39  return expr->getType();
40 }
41 template<class T>
42 [[nodiscard]]
43 inline csl::Type GetPrimaryType(T const &expr)
44 {
45  return expr->getPrimaryType();
46 }
47 
48 [[nodiscard]]
49 inline size_t Size(Expr const &expr)
50 {
51  return expr->size();
52 }
53 
54 [[nodiscard]]
55 inline Expr GetArgument(
56  Expr const &expr,
57  size_t pos = 0
58  )
59 {
60  return expr->getArgument(int(pos));
61 }
62 
63 [[nodiscard]]
64 inline bool GetCommutable(csl::Expr const &expr)
65 {
66  return !csl::option::checkCommutations || expr->getCommutable();
67 }
68 
69 [[nodiscard]]
70 inline bool GetCommutable(csl::Expr_info expr)
71 {
72  return !csl::option::checkCommutations || expr->getCommutable();
73 }
74 
75 [[nodiscard]]
76 inline bool GetCommutable(csl::Abstract const &expr)
77 {
78  return !csl::option::checkCommutations || expr.getCommutable();
79 }
80 
81 [[nodiscard]]
82 Expr GetSymbol(
83  std::string_view name,
84  Expr const &init
85  );
86 
87 [[nodiscard]]
88 Parent GetParent(
89  std::string_view name,
90  Expr const &init
91  );
92 
93 [[nodiscard]]
94 inline bool DependsOn(
95  Expr const &init,
96  Expr const &x)
97 {
98  return init->dependsOn(x.get());
99 }
100 
101 [[nodiscard]]
102 inline bool DependsExplicitlyOn(
103  Expr const &init,
104  Expr const &x)
105 {
106  return init->dependsExplicitlyOn(x.get());
107 }
108 
109 [[nodiscard]]
110 inline bool DependsOn(
111  Expr const &init,
112  csl::Parent const &x)
113 {
114  return init->dependsOn(x.get());
115 }
116 
117 [[nodiscard]]
118 inline bool DependsExplicitlyOn(
119  Expr const &init,
120  csl::Parent const &x)
121 {
122  return init->dependsExplicitlyOn(x.get());
123 }
124 
125 void Expand(Expr& expression,
126  bool full = false,
127  bool inplace = false);
128 
129 [[nodiscard]]
130 Expr Expanded(const Expr& expression,
131  bool full = false,
132  bool inplace = false);
133 
134 void ExpandIf(Expr& expression,
135  std::function<bool(Expr const&)> const& f,
136  bool full = false,
137  bool inplace = false);
138 
139 [[nodiscard]]
140 Expr ExpandedIf(const Expr& expression,
141  std::function<bool(Expr const&)> const& f,
142  bool full = false,
143  bool inplace = false);
144 
145 inline void DeepExpand(
146  Expr &expression,
147  bool inplace = false
148  )
149 {
150  Expand(expression, true, inplace);
151 }
152 
153 [[nodiscard]]
154 inline Expr DeepExpanded(
155  Expr const &expression,
156  bool inplace = false
157  )
158 {
159  return Expanded(expression, true, inplace);
160 }
161 
162 inline void DeepExpandIf(
163  Expr &expression,
164  std::function<bool(Expr const&)> const& f,
165  bool inplace = false
166  )
167 {
168  ExpandIf(expression, f, true, inplace);
169 }
170 
171 [[nodiscard]]
172 inline Expr DeepExpandedIf(
173  Expr const &expression,
174  std::function<bool(Expr const&)> const& f,
175  bool inplace = false
176  )
177 {
178  return ExpandedIf(expression, f, true, inplace);
179 }
180 
181 void DeepExpandIf_lock(
182  Expr &expression,
183  std::function<bool(Expr const&)> const &f,
184  int lockId = 0,
185  bool inplace = false,
186  bool refactor = false
187  );
188 
189 [[nodiscard]]
190 Expr DeepExpandedIf_lock(
191  Expr const &expression,
192  std::function<bool(Expr const&)> const &f,
193  int lockId = 0,
194  bool inplace = false,
195  bool refactor = false
196  );
197 
198 void Factor(Expr& expression,
199  bool full = false);
200 
201 void Factor(Expr& expression,
202  Expr_info factor,
203  bool full = false);
204 
205 inline void Factor(
206  Expr &expression,
207  Expr const &factor,
208  bool full = false)
209 {
210  Factor(expression, factor.get(), full);
211 }
212 
213 [[nodiscard]]
214 Expr Factored(const Expr& expression,
215  bool full = false);
216 
217 [[nodiscard]]
218 Expr Factored(const Expr& expression,
219  Expr_info factor,
220  bool full = false);
221 
222 [[nodiscard]]
223 inline Expr Factored(
224  const Expr& expression,
225  const Expr& factor,
226  bool full = false)
227 {
228  return Factored(expression, factor.get(), full);
229 }
230 
231 inline void DeepFactor(
232  Expr& expression
233  )
234 {
235  Factor(expression, true);
236 }
237 
238 inline void DeepFactor(
239  Expr& expression,
240  Expr_info factor
241  )
242 {
243  Factor(expression, factor, true);
244 }
245 
246 inline void DeepFactor(
247  Expr &expression,
248  Expr const &factor
249  )
250 {
251  Factor(expression, factor, true);
252 }
253 
254 [[nodiscard]]
255 inline Expr DeepFactored(
256  const Expr& expression
257  )
258 {
259  return Factored(expression, true);
260 }
261 
262 [[nodiscard]]
263 inline Expr DeepFactored(
264  const Expr& expression,
265  Expr_info factor
266  )
267 {
268  return Factored(expression, factor, true);
269 }
270 
271 [[nodiscard]]
272 inline Expr DeepFactored(
273  const Expr& expression,
274  const Expr& factor
275  )
276 {
277  return Factored(expression, factor, true);
278 }
279 
280 void Collect(
281  Expr &expr,
282  std::vector<Expr> const &factors
283  );
284 void DeepCollect(
285  Expr &expr,
286  std::vector<Expr> const &factors
287  );
288 [[nodiscard]]
289 Expr Collected(
290  Expr const &expr,
291  std::vector<Expr> const &factors
292  );
293 [[nodiscard]]
294 Expr DeepCollected(
295  Expr const &expr,
296  std::vector<Expr> const &factors
297  );
298 
299 [[nodiscard]]
300 Expr Distributed(Expr const& expression,
301  Expr_info factor,
302  bool full = false);
303 
304 void Distribute(Expr& expression,
305  Expr_info factor,
306  bool full = false);
307 
308 [[nodiscard]]
309 inline Expr Distributed(
310  Expr const& expression,
311  Expr const& factor,
312  bool full = false)
313 {
314  return Distributed(expression, factor.get(), full);
315 }
316 
317 inline void Distribute(
318  Expr& expression,
319  Expr const& factor,
320  bool full = false)
321 {
322  Distribute(expression, factor.get(), full);
323 }
324 
325 [[nodiscard]]
326 inline Expr DeepDistributed(
327  Expr const& expression,
328  Expr_info factor
329  )
330 {
331  return Distributed(expression, factor, true);
332 }
333 
334 inline void DeepDistribute(
335  Expr& expression,
336  Expr_info factor
337  )
338 {
339  Distribute(expression, factor, true);
340 }
341 
342 [[nodiscard]]
343 inline Expr DeepDistributed(
344  Expr const& expression,
345  Expr const& factor)
346 {
347  return Distributed(expression, factor, true);
348 }
349 
350 inline void DeepDistribute(
351  Expr& expression,
352  Expr const& factor
353  )
354 {
355  Distribute(expression, factor, true);
356 }
357 
358 [[nodiscard]]
359 Expr Distributed(Expr const& expression,
360  Parent_info factor,
361  bool full = false);
362 
363 void Distribute(Expr& expression,
364  Parent_info factor,
365  bool full = false);
366 
367 [[nodiscard]]
368 inline Expr Distributed(
369  Expr const& expression,
370  Parent const& factor,
371  bool full = false)
372 {
373  return Distributed(expression, factor.get(), full);
374 }
375 
376 inline void Distribute(
377  Expr& expression,
378  Parent const& factor,
379  bool full = false)
380 {
381  Distribute(expression, factor.get(), full);
382 }
383 
384 [[nodiscard]]
385 inline Expr DeepDistributed(
386  Expr const& expression,
387  Parent_info factor
388  )
389 {
390  return Distributed(expression, factor, true);
391 }
392 
393 inline void DeepDistribute(
394  Expr& expression,
395  Parent_info factor
396  )
397 {
398  Distribute(expression, factor, true);
399 }
400 
401 [[nodiscard]]
402 inline Expr DeepDistributed(
403  Expr const& expression,
404  Parent const& factor)
405 {
406  return Distributed(expression, factor, true);
407 }
408 
409 inline void DeepDistribute(
410  Expr& expression,
411  Parent const& factor
412  )
413 {
414  Distribute(expression, factor, true);
415 }
416 
417 [[nodiscard]]
418 Expr DistributedIf(
419  Expr const& expression,
420  std::function<bool(Expr const&)> f,
421  bool full = false
422  );
423 
424 void DistributeIf(
425  Expr& expression,
426  std::function<bool(Expr const&)> f,
427  bool full = false
428  );
429 
430 [[nodiscard]]
431 inline Expr DeepDistributedIf(
432  Expr const& expression,
433  std::function<bool(Expr const&)> f
434  )
435 {
436  return DistributedIf(expression, f, true);
437 }
438 
439 inline void DeepDistributeIf(
440  Expr& expression,
441  std::function<bool(Expr const&)> f
442  )
443 {
444  return DistributeIf(expression, f, true);
445 }
446 
447 [[nodiscard]]
448 Expr GetTerm(const Expr& expression);
449 
450 [[nodiscard]]
451 Expr Derived(const Expr& expression,
452  Expr_info variable);
453 
454 [[nodiscard]]
455 inline Expr Derived(
456  const Expr& expression,
457  const Expr& variable)
458 {
459  return Derived(expression, variable.get());
460 }
461 
462 inline void Derive(
463  Expr& expression,
464  Expr_info variable)
465 {
466  expression = Derived(expression, variable);
467 }
468 
469 inline void Derive(
470  Expr& expression,
471  const Expr& variable)
472 {
473  expression = Derived(expression, variable);
474 }
475 
476 [[nodiscard]]
477 Expr GetPolynomialTerm(const Expr& expression,
478  Expr_info variable,
479  int order);
480 
481 [[nodiscard]]
482 inline Expr GetPolynomialTerm(
483  const Expr& expression,
484  const Expr& variable,
485  int order)
486 {
487  return GetPolynomialTerm(expression, variable.get(), order);
488 }
489 
490 [[nodiscard]]
491 Expr Evaluated(const Expr& expression);
492 
493 [[nodiscard]]
494 Expr Evaluated(const Expr& expression,
495  csl::eval::mode user_mode);
496 
497 inline void Evaluate(Expr &expr)
498 {
499  expr = Evaluated(expr);
500 }
501 
502 inline void Evaluate(
503  Expr &expr,
504  eval::mode user_mode)
505 {
506  expr = Evaluated(expr, user_mode);
507 }
508 
509 [[nodiscard]]
510 ComplexProperty GetComplexProperty(Expr const &expr);
511 
512 void SetComplexProperty(
513  Expr &expr,
514  ComplexProperty prop
515  );
516 
517 ComplexProperty GetComplexProperty(csl::Parent const &parent);
518 
519 void SetComplexProperty(
520  csl::Parent &parent,
521  ComplexProperty prop
522  );
523 
524 template<class T>
525 inline void SetComplexProperty(
526  T parent,
527  ComplexProperty prop
528  )
529 {
530  csl::Parent p(parent);
531  SetComplexProperty(p, prop);
532 }
533 
534 [[nodiscard]]
535 Expr GetRealPart(const Expr& expression);
536 
537 [[nodiscard]]
538 Expr GetImaginaryPart(const Expr& expression);
539 
540 [[nodiscard]]
541 Expr GetComplexModulus(const Expr& expression);
542 
543 [[nodiscard]]
544 Expr GetComplexArgument(const Expr& expression);
545 
546 [[nodiscard]]
547 Expr GetComplexConjugate(const Expr& expression);
548 
549 
550 [[nodiscard]]
551 Expr GetTransposed(const Expr& expression,
552  const Space* space,
553  bool applyProp = true);
554 
555 [[nodiscard]]
556 Expr GetTransposed(const Expr& expression,
557  const std::vector<const Space*>& spaces,
558  bool applyProp = true);
559 
560 [[nodiscard]]
561 Expr GetHermitianConjugate(const Expr& expression,
562  const Space* space);
563 
564 [[nodiscard]]
565 Expr GetHermitianConjugate(const Expr& expression,
566  const std::vector<const Space*>& spaces);
567 
568 [[nodiscard]]
569 Expr Swapped(const Expr& expression,
570  const Index& index1,
571  const Index& index2,
572  bool refresh = true);
573 
574 [[nodiscard]]
575 Expr Swapped(const Expr& expression,
576  const Expr& index1,
577  const Expr& index2,
578  bool refresh = true);
579 
580 [[nodiscard]]
581 Expr Swapped(const Expr& expression,
582  const Parent& index1,
583  const Parent& index2,
584  bool refresh = true);
585 
586 template<class T>
587 inline void Swap(
588  Expr &expression,
589  T const &old_obj,
590  T const &new_obj
591  )
592 {
593  expression = Swapped(expression, old_obj, new_obj);
594 }
595 
596 // void ReplaceInPlace(
597 // Expr& expression,
598 // const Index& oldIndex,
599 // const Index& newIndex);
600 //
601 [[nodiscard]]
602 Expr ContractIndex(const Expr& expression,
603  const Index& index);
604 
605 [[nodiscard]]
606 csl::Index GenerateIndex(const csl::Space* space,
607  const std::string& name = "");
608 
609 [[nodiscard]]
610 csl::Tensor GetDelta(const csl::Space* space);
611 [[nodiscard]]
612 csl::Tensor GetMetric(const csl::Space* space);
613 [[nodiscard]]
614 csl::Tensor GetEpsilon(const csl::Space* space);
615 
616 [[nodiscard]]
617 csl::Tensor GetDelta(const csl::Space& space);
618 [[nodiscard]]
619 csl::Tensor GetMetric(const csl::Space& space);
620 [[nodiscard]]
621 csl::Tensor GetEpsilon(const csl::Space& space);
622 
623 [[nodiscard]]
624 Parent GetParent(Expr const &tensor);
625 [[nodiscard]]
626 Tensor GetTensorParent(Expr const &tensor);
627 [[nodiscard]]
628 TensorField GetTensorFieldParent(Expr const &tensor);
629 [[nodiscard]]
630 TDerivative GetTDerivativeParent(Expr const &tensor);
631 
632 void AddSelfContraction(
633  csl::Tensor &parent,
634  Expr const &A,
635  Expr const &B,
636  Expr const &res
637  );
638 
639 void AddContractionProperty(
640  csl::Tensor &parent,
641  std::vector<Expr> const &tensors,
642  Expr const &res
643  );
644 
645 void AddComplexProperty(
646  csl::Tensor &parent,
647  Expr const &A,
648  Expr const &B
649  );
650 
651 void AddTransposedProperty(
652  csl::Tensor &parent,
653  csl::Space const *space,
654  Expr const &A,
655  Expr const &B
656  );
657 
658 void AddHermitianProperty(
659  csl::Tensor &parent,
660  csl::Space const *space,
661  Expr const &A,
662  Expr const &B
663  );
664 
665 [[nodiscard]]
666 LibDependency GetLibraryDependencies(Expr const& expression);
667 
668 [[nodiscard]]
669 inline bool IsIndexed(Expr const &expr) {
670  return expr->isIndexed();
671 }
672 [[nodiscard]]
673 inline bool IsNumerical(Expr const &expr) {
674  return expr->getPrimaryType() == csl::PrimaryType::Numerical;
675 }
676 [[nodiscard]]
677 inline bool IsLiteral(Expr const &expr) {
678  return expr->getPrimaryType() == csl::PrimaryType::Literal;
679 }
680 [[nodiscard]]
681 inline bool IsScalarFunction(Expr const &expr) {
682  return expr->getPrimaryType() == csl::PrimaryType::ScalarFunction;
683 }
684 [[nodiscard]]
685 inline bool IsMultiFunction(Expr const &expr) {
686  return expr->getPrimaryType() == csl::PrimaryType::MultiFunction;
687 }
688 [[nodiscard]]
689 inline bool IsVectorial(Expr const &expr) {
690  return expr->getPrimaryType() == csl::PrimaryType::Vectorial;
691 }
692 [[nodiscard]]
693 inline bool IsIndicial(Expr const &expr) {
694  return expr->getPrimaryType() == csl::PrimaryType::Indicial;
695 }
696 [[nodiscard]]
697 inline bool IsField(Expr const &expr) {
698  return expr->getPrimaryType() == csl::PrimaryType::Field;
699 }
700 [[nodiscard]]
701 inline bool IsArbitrary(Expr const &expr) {
702  return expr->getPrimaryType() == csl::PrimaryType::Arbitrary;
703 }
704 
705 [[nodiscard]]
706 inline bool IsInteger(Expr const &expr) {
707  return expr->getType() == csl::Type::Integer;
708 }
709 [[nodiscard]]
710 inline bool IsFloat(Expr const &expr) {
711  return expr->getType() == csl::Type::Float;
712 }
713 [[nodiscard]]
714 inline bool IsIntFraction(Expr const &expr) {
715  return expr->getType() == csl::Type::IntFraction;
716 }
717 [[nodiscard]]
718 inline bool IsIntFactorial(Expr const &expr) {
719  return expr->getType() == csl::Type::IntFactorial;
720 }
721 [[nodiscard]]
722 inline bool IsComplex(Expr const &expr) {
723  return expr->getType() == csl::Type::Complex;
724 }
725 [[nodiscard]]
726 inline bool IsNumericalEval(Expr const &expr) {
727  return expr->getType() == csl::Type::NumericalEval;
728 }
729 [[nodiscard]]
730 inline bool IsImaginary(Expr const &expr) {
731  return expr->getType() == csl::Type::Imaginary;
732 }
733 [[nodiscard]]
734 inline bool IsConstant(Expr const &expr) {
735  return expr->getType() == csl::Type::Constant;
736 }
737 [[nodiscard]]
738 inline bool IsVariable(Expr const &expr) {
739  return expr->getType() == csl::Type::Variable;
740 }
741 [[nodiscard]]
742 inline bool IsExp(Expr const &expr) {
743  return expr->getType() == csl::Type::Exp;
744 }
745 [[nodiscard]]
746 inline bool IsLog(Expr const &expr) {
747  return expr->getType() == csl::Type::Log;
748 }
749 [[nodiscard]]
750 inline bool IsDiracDelta(Expr const &expr) {
751  return expr->getType() == csl::Type::DiracDelta;
752 }
753 [[nodiscard]]
754 inline bool IsAbs(Expr const &expr) {
755  return expr->getType() == csl::Type::Abs;
756 }
757 [[nodiscard]]
758 inline bool IsCos(Expr const &expr) {
759  return expr->getType() == csl::Type::Cos;
760 }
761 [[nodiscard]]
762 inline bool IsSin(Expr const &expr) {
763  return expr->getType() == csl::Type::Sin;
764 }
765 [[nodiscard]]
766 inline bool IsTan(Expr const &expr) {
767  return expr->getType() == csl::Type::Tan;
768 }
769 [[nodiscard]]
770 inline bool IsCosh(Expr const &expr) {
771  return expr->getType() == csl::Type::Cosh;
772 }
773 [[nodiscard]]
774 inline bool IsSinh(Expr const &expr) {
775  return expr->getType() == csl::Type::Sinh;
776 }
777 [[nodiscard]]
778 inline bool IsTanh(Expr const &expr) {
779  return expr->getType() == csl::Type::Tanh;
780 }
781 [[nodiscard]]
782 inline bool IsACos(Expr const &expr) {
783  return expr->getType() == csl::Type::ACos;
784 }
785 [[nodiscard]]
786 inline bool IsASin(Expr const &expr) {
787  return expr->getType() == csl::Type::ASin;
788 }
789 [[nodiscard]]
790 inline bool IsATan(Expr const &expr) {
791  return expr->getType() == csl::Type::ATan;
792 }
793 [[nodiscard]]
794 inline bool IsACosh(Expr const &expr) {
795  return expr->getType() == csl::Type::ACosh;
796 }
797 [[nodiscard]]
798 inline bool IsASinh(Expr const &expr) {
799  return expr->getType() == csl::Type::ASinh;
800 }
801 [[nodiscard]]
802 inline bool IsATanh(Expr const &expr) {
803  return expr->getType() == csl::Type::ATanh;
804 }
805 [[nodiscard]]
806 inline bool IsScalar(Expr const &expr) {
807  return expr->getType() == csl::Type::Scalar;
808 }
809 [[nodiscard]]
810 inline bool IsRealPart(Expr const &expr) {
811  return expr->getType() == csl::Type::RealPart;
812 }
813 [[nodiscard]]
814 inline bool IsImaginaryPart(Expr const &expr) {
815  return expr->getType() == csl::Type::ImaginaryPart;
816 }
817 [[nodiscard]]
818 inline bool IsITensor(Expr const &expr) {
819  return expr->getType() == csl::Type::TensorElement;
820 }
821 [[nodiscard]]
822 inline bool IsScalarField(Expr const &expr) {
823  return expr->getType() == csl::Type::ScalarField;
824 }
825 [[nodiscard]]
826 inline bool IsTensorField(Expr const &expr) {
827  return expr->getType() == csl::Type::TensorFieldElement;
828 }
829 [[nodiscard]]
830 inline bool IsTensorialDerivative(Expr const &expr) {
831  return expr->getType() == csl::Type::TDerivativeElement;
832 }
833 [[nodiscard]]
834 inline bool IsStandardDuo(Expr const &expr) {
835  return expr->getType() == csl::Type::StandardDuo;
836 }
837 [[nodiscard]]
838 inline bool IsStandardMult(Expr const &expr) {
839  return expr->getType() == csl::Type::StandardMult;
840 }
841 [[nodiscard]]
842 inline bool IsPow(Expr const &expr) {
843  return expr->getType() == csl::Type::Pow;
844 }
845 [[nodiscard]]
846 inline bool IsProd(Expr const &expr) {
847  return expr->getType() == csl::Type::Prod;
848 }
849 [[nodiscard]]
850 inline bool IsSum(Expr const &expr) {
851  return expr->getType() == csl::Type::Sum;
852 }
853 [[nodiscard]]
854 inline bool IsPolynomial(Expr const &expr) {
855  return expr->getType() == csl::Type::Polynomial;
856 }
857 [[nodiscard]]
858 inline bool IsDerivative(Expr const &expr) {
859  return expr->getType() == csl::Type::Derivative;
860 }
861 [[nodiscard]]
862 inline bool IsCommutator(Expr const &expr) {
863  return expr->getType() == csl::Type::Commutator;
864 }
865 [[nodiscard]]
866 inline bool IsAngle(Expr const &expr) {
867  return expr->getType() == csl::Type::Angle;
868 }
869 [[nodiscard]]
870 inline bool IsFactorial(Expr const &expr) {
871  return expr->getType() == csl::Type::Factorial;
872 }
873 [[nodiscard]]
874 inline bool IsIntegral(Expr const &expr) {
875  return expr->getType() == csl::Type::Integral;
876 }
877 [[nodiscard]]
878 inline bool IsScalarIntegral(Expr const &expr) {
879  return expr->getType() == csl::Type::ScalarIntegral;
880 }
881 [[nodiscard]]
882 inline bool IsVectorIntegral(Expr const &expr) {
883  return expr->getType() == csl::Type::VectorIntegral;
884 }
885 [[nodiscard]]
886 inline bool IsVector(Expr const &expr) {
887  return expr->getType() == csl::Type::Vector;
888 }
889 [[nodiscard]]
890 inline bool IsMatrix(Expr const &expr) {
891  return expr->getType() == csl::Type::Matrix;
892 }
893 [[nodiscard]]
894 inline bool IsHighDTensor(Expr const &expr) {
895  return expr->getType() == csl::Type::HighDTensor;
896 }
897 
898 [[nodiscard]]
899 inline bool IsIndexed(Expr_info expr) {
900  return expr->isIndexed();
901 }
902 [[nodiscard]]
903 inline bool IsNumerical(Expr_info expr) {
904  return expr->getPrimaryType() == csl::PrimaryType::Numerical;
905 }
906 [[nodiscard]]
907 inline bool IsLiteral(Expr_info expr) {
908  return expr->getPrimaryType() == csl::PrimaryType::Literal;
909 }
910 [[nodiscard]]
911 inline bool IsScalarFunction(Expr_info expr) {
912  return expr->getPrimaryType() == csl::PrimaryType::ScalarFunction;
913 }
914 [[nodiscard]]
915 inline bool IsMultiFunction(Expr_info expr) {
916  return expr->getPrimaryType() == csl::PrimaryType::MultiFunction;
917 }
918 [[nodiscard]]
919 inline bool IsVectorial(Expr_info expr) {
920  return expr->getPrimaryType() == csl::PrimaryType::Vectorial;
921 }
922 [[nodiscard]]
923 inline bool IsIndicial(Expr_info expr) {
924  return expr->getPrimaryType() == csl::PrimaryType::Indicial;
925 }
926 [[nodiscard]]
927 inline bool IsField(Expr_info expr) {
928  return expr->getPrimaryType() == csl::PrimaryType::Field;
929 }
930 [[nodiscard]]
931 inline bool IsArbitrary(Expr_info expr) {
932  return expr->getPrimaryType() == csl::PrimaryType::Arbitrary;
933 }
934 
935 [[nodiscard]]
936 inline bool IsInteger(Expr_info expr) {
937  return expr->getType() == csl::Type::Integer;
938 }
939 [[nodiscard]]
940 inline bool IsFloat(Expr_info expr) {
941  return expr->getType() == csl::Type::Float;
942 }
943 [[nodiscard]]
944 inline bool IsIntFraction(Expr_info expr) {
945  return expr->getType() == csl::Type::IntFraction;
946 }
947 [[nodiscard]]
948 inline bool IsIntFactorial(Expr_info expr) {
949  return expr->getType() == csl::Type::IntFactorial;
950 }
951 [[nodiscard]]
952 inline bool IsComplex(Expr_info expr) {
953  return expr->getType() == csl::Type::Complex;
954 }
955 [[nodiscard]]
956 inline bool IsNumericalEval(Expr_info expr) {
957  return expr->getType() == csl::Type::NumericalEval;
958 }
959 [[nodiscard]]
960 inline bool IsImaginary(Expr_info expr) {
961  return expr->getType() == csl::Type::Imaginary;
962 }
963 [[nodiscard]]
964 inline bool IsConstant(Expr_info expr) {
965  return expr->getType() == csl::Type::Constant;
966 }
967 [[nodiscard]]
968 inline bool IsVariable(Expr_info expr) {
969  return expr->getType() == csl::Type::Variable;
970 }
971 [[nodiscard]]
972 inline bool IsExp(Expr_info expr) {
973  return expr->getType() == csl::Type::Exp;
974 }
975 [[nodiscard]]
976 inline bool IsLog(Expr_info expr) {
977  return expr->getType() == csl::Type::Log;
978 }
979 [[nodiscard]]
980 inline bool IsDiracDelta(Expr_info expr) {
981  return expr->getType() == csl::Type::DiracDelta;
982 }
983 [[nodiscard]]
984 inline bool IsAbs(Expr_info expr) {
985  return expr->getType() == csl::Type::Abs;
986 }
987 [[nodiscard]]
988 inline bool IsCos(Expr_info expr) {
989  return expr->getType() == csl::Type::Cos;
990 }
991 [[nodiscard]]
992 inline bool IsSin(Expr_info expr) {
993  return expr->getType() == csl::Type::Sin;
994 }
995 [[nodiscard]]
996 inline bool IsTan(Expr_info expr) {
997  return expr->getType() == csl::Type::Tan;
998 }
999 [[nodiscard]]
1000 inline bool IsCosh(Expr_info expr) {
1001  return expr->getType() == csl::Type::Cosh;
1002 }
1003 [[nodiscard]]
1004 inline bool IsSinh(Expr_info expr) {
1005  return expr->getType() == csl::Type::Sinh;
1006 }
1007 [[nodiscard]]
1008 inline bool IsTanh(Expr_info expr) {
1009  return expr->getType() == csl::Type::Tanh;
1010 }
1011 [[nodiscard]]
1012 inline bool IsACos(Expr_info expr) {
1013  return expr->getType() == csl::Type::ACos;
1014 }
1015 [[nodiscard]]
1016 inline bool IsASin(Expr_info expr) {
1017  return expr->getType() == csl::Type::ASin;
1018 }
1019 [[nodiscard]]
1020 inline bool IsATan(Expr_info expr) {
1021  return expr->getType() == csl::Type::ATan;
1022 }
1023 [[nodiscard]]
1024 inline bool IsACosh(Expr_info expr) {
1025  return expr->getType() == csl::Type::ACosh;
1026 }
1027 [[nodiscard]]
1028 inline bool IsASinh(Expr_info expr) {
1029  return expr->getType() == csl::Type::ASinh;
1030 }
1031 [[nodiscard]]
1032 inline bool IsATanh(Expr_info expr) {
1033  return expr->getType() == csl::Type::ATanh;
1034 }
1035 [[nodiscard]]
1036 inline bool IsScalar(Expr_info expr) {
1037  return expr->getType() == csl::Type::Scalar;
1038 }
1039 [[nodiscard]]
1040 inline bool IsRealPart(Expr_info expr) {
1041  return expr->getType() == csl::Type::RealPart;
1042 }
1043 [[nodiscard]]
1044 inline bool IsImaginaryPart(Expr_info expr) {
1045  return expr->getType() == csl::Type::ImaginaryPart;
1046 }
1047 [[nodiscard]]
1048 inline bool IsITensor(Expr_info expr) {
1049  return expr->getType() == csl::Type::TensorElement;
1050 }
1051 [[nodiscard]]
1052 inline bool IsScalarField(Expr_info expr) {
1053  return expr->getType() == csl::Type::ScalarField;
1054 }
1055 [[nodiscard]]
1056 inline bool IsTensorField(Expr_info expr) {
1057  return expr->getType() == csl::Type::TensorFieldElement;
1058 }
1059 [[nodiscard]]
1060 inline bool IsTensorialDerivative(Expr_info expr) {
1061  return expr->getType() == csl::Type::TDerivativeElement;
1062 }
1063 [[nodiscard]]
1064 inline bool IsStandardDuo(Expr_info expr) {
1065  return expr->getType() == csl::Type::StandardDuo;
1066 }
1067 [[nodiscard]]
1068 inline bool IsStandardMult(Expr_info expr) {
1069  return expr->getType() == csl::Type::StandardMult;
1070 }
1071 [[nodiscard]]
1072 inline bool IsPow(Expr_info expr) {
1073  return expr->getType() == csl::Type::Pow;
1074 }
1075 [[nodiscard]]
1076 inline bool IsProd(Expr_info expr) {
1077  return expr->getType() == csl::Type::Prod;
1078 }
1079 [[nodiscard]]
1080 inline bool IsSum(Expr_info expr) {
1081  return expr->getType() == csl::Type::Sum;
1082 }
1083 [[nodiscard]]
1084 inline bool IsPolynomial(Expr_info expr) {
1085  return expr->getType() == csl::Type::Polynomial;
1086 }
1087 [[nodiscard]]
1088 inline bool IsDerivative(Expr_info expr) {
1089  return expr->getType() == csl::Type::Derivative;
1090 }
1091 [[nodiscard]]
1092 inline bool IsCommutator(Expr_info expr) {
1093  return expr->getType() == csl::Type::Commutator;
1094 }
1095 [[nodiscard]]
1096 inline bool IsAngle(Expr_info expr) {
1097  return expr->getType() == csl::Type::Angle;
1098 }
1099 [[nodiscard]]
1100 inline bool IsFactorial(Expr_info expr) {
1101  return expr->getType() == csl::Type::Factorial;
1102 }
1103 [[nodiscard]]
1104 inline bool IsIntegral(Expr_info expr) {
1105  return expr->getType() == csl::Type::Integral;
1106 }
1107 [[nodiscard]]
1108 inline bool IsScalarIntegral(Expr_info expr) {
1109  return expr->getType() == csl::Type::ScalarIntegral;
1110 }
1111 [[nodiscard]]
1112 inline bool IsVectorIntegral(Expr_info expr) {
1113  return expr->getType() == csl::Type::VectorIntegral;
1114 }
1115 [[nodiscard]]
1116 inline bool IsVector(Expr_info expr) {
1117  return expr->getType() == csl::Type::Vector;
1118 }
1119 [[nodiscard]]
1120 inline bool IsMatrix(Expr_info expr) {
1121  return expr->getType() == csl::Type::Matrix;
1122 }
1123 [[nodiscard]]
1124 inline bool IsHighDTensor(Expr_info expr) {
1125  return expr->getType() == csl::Type::HighDTensor;
1126 }
1127 
1139 void ApplySelfProperty(Expr& init,
1140  csl::Tensor& tensor,
1141  Expr const& A,
1142  Expr const& B,
1143  Expr const& res);
1144 
1155 void ApplyChainProperty(Expr& init,
1156  csl::Tensor& tensor,
1157  std::vector<Expr> const& prod,
1158  Expr const& res);
1159 
1170 bool CheckValidity(Expr const& init,
1171  std::vector<Expr_info> encountered
1172  = std::vector<Expr_info>());
1173 
1187 size_t MemorySizeOf(Expr const& expression);
1188 
1189 } // End of namespace csl
1190 
1191 #endif
size_t MemorySizeOf(Expr const &expression)
Calculates an estimate of the total memory that an expression takes.
Definition: interface.cpp:694
Namespace for csl library.
Definition: abreviation.h:34
Definition: parent.h:439
Index object that is used for indicial objects.
Definition: index.h:75
Base classes for parents and elements.
Type
Enum of the different types of Abstract (i.e. list of all possible specializations).
Definition: enum.h:47
bool CheckValidity(Expr const &init, std::vector< Expr_info > encountered=std::vector< Expr_info >())
Checks the validity of an expression.
Definition: interface.cpp:676
ComplexProperty
Contains all possible complex properties of objects. Real, purely imaginary, or complex.
Definition: enum.h:127
Root class of the inheritance tree of abstracts.
Definition: abstract.h:76
void ApplySelfProperty(Expr &init, csl::Tensor &tensor, Expr const &A, Expr const &B, Expr const &res)
Declares a self contraction property just the time of a refresh in order to apply it on one expressio...
Definition: interface.cpp:655
Vector space that has a name, a dimension, a delta tensor and possibly a non-trivial metric...
Definition: space.h:64
virtual bool getCommutable() const
Allows to know if the object commutes with all the others.
Definition: abstract.cpp:47
void ApplyChainProperty(Expr &init, csl::Tensor &tensor, std::vector< Expr > const &prod, Expr const &res)
Declares a chain contraction property just the time of a refresh in order to apply it on one expressi...
Definition: interface.cpp:666
Base classes for all exprs in the program.
Definition: indicial.h:675
Expression type/.
Definition: abstract.h:1573