23 #ifndef INTERFACE_H_INCLUDED 24 #define INTERFACE_H_INCLUDED 39 return expr->getType();
43 inline csl::Type GetPrimaryType(T
const &expr)
45 return expr->getPrimaryType();
49 inline size_t Size(Expr
const &expr)
55 inline Expr GetArgument(
60 return expr->getArgument(
int(pos));
64 inline bool GetCommutable(
csl::Expr const &expr)
66 return !csl::option::checkCommutations || expr->getCommutable();
72 return !csl::option::checkCommutations || expr->
getCommutable();
78 return !csl::option::checkCommutations || expr.
getCommutable();
83 std::string_view name,
89 std::string_view name,
94 inline bool DependsOn(
98 return init->dependsOn(x.get());
102 inline bool DependsExplicitlyOn(
106 return init->dependsExplicitlyOn(x.get());
110 inline bool DependsOn(
114 return init->dependsOn(x.get());
118 inline bool DependsExplicitlyOn(
122 return init->dependsExplicitlyOn(x.get());
125 void Expand(Expr& expression,
127 bool inplace =
false);
130 Expr Expanded(
const Expr& expression,
132 bool inplace =
false);
134 void ExpandIf(Expr& expression,
135 std::function<
bool(Expr
const&)>
const& f,
137 bool inplace =
false);
140 Expr ExpandedIf(
const Expr& expression,
141 std::function<
bool(Expr
const&)>
const& f,
143 bool inplace =
false);
145 inline void DeepExpand(
150 Expand(expression,
true, inplace);
154 inline Expr DeepExpanded(
155 Expr
const &expression,
159 return Expanded(expression,
true, inplace);
162 inline void DeepExpandIf(
164 std::function<
bool(Expr
const&)>
const& f,
168 ExpandIf(expression, f,
true, inplace);
172 inline Expr DeepExpandedIf(
173 Expr
const &expression,
174 std::function<
bool(Expr
const&)>
const& f,
178 return ExpandedIf(expression, f,
true, inplace);
181 void DeepExpandIf_lock(
183 std::function<
bool(Expr
const&)>
const &f,
185 bool inplace =
false,
186 bool refactor =
false 190 Expr DeepExpandedIf_lock(
191 Expr
const &expression,
192 std::function<
bool(Expr
const&)>
const &f,
194 bool inplace =
false,
195 bool refactor =
false 198 void Factor(Expr& expression,
201 void Factor(Expr& expression,
210 Factor(expression, factor.get(), full);
214 Expr Factored(
const Expr& expression,
218 Expr Factored(
const Expr& expression,
223 inline Expr Factored(
224 const Expr& expression,
228 return Factored(expression, factor.get(), full);
231 inline void DeepFactor(
235 Factor(expression,
true);
238 inline void DeepFactor(
243 Factor(expression, factor,
true);
246 inline void DeepFactor(
251 Factor(expression, factor,
true);
255 inline Expr DeepFactored(
256 const Expr& expression
259 return Factored(expression,
true);
263 inline Expr DeepFactored(
264 const Expr& expression,
268 return Factored(expression, factor,
true);
272 inline Expr DeepFactored(
273 const Expr& expression,
277 return Factored(expression, factor,
true);
282 std::vector<Expr>
const &factors
286 std::vector<Expr>
const &factors
291 std::vector<Expr>
const &factors
296 std::vector<Expr>
const &factors
300 Expr Distributed(Expr
const& expression,
304 void Distribute(Expr& expression,
309 inline Expr Distributed(
310 Expr
const& expression,
314 return Distributed(expression, factor.get(), full);
317 inline void Distribute(
322 Distribute(expression, factor.get(), full);
326 inline Expr DeepDistributed(
327 Expr
const& expression,
331 return Distributed(expression, factor,
true);
334 inline void DeepDistribute(
339 Distribute(expression, factor,
true);
343 inline Expr DeepDistributed(
344 Expr
const& expression,
347 return Distributed(expression, factor,
true);
350 inline void DeepDistribute(
355 Distribute(expression, factor,
true);
359 Expr Distributed(Expr
const& expression,
363 void Distribute(Expr& expression,
368 inline Expr Distributed(
369 Expr
const& expression,
370 Parent
const& factor,
373 return Distributed(expression, factor.get(), full);
376 inline void Distribute(
378 Parent
const& factor,
381 Distribute(expression, factor.get(), full);
385 inline Expr DeepDistributed(
386 Expr
const& expression,
390 return Distributed(expression, factor,
true);
393 inline void DeepDistribute(
398 Distribute(expression, factor,
true);
402 inline Expr DeepDistributed(
403 Expr
const& expression,
404 Parent
const& factor)
406 return Distributed(expression, factor,
true);
409 inline void DeepDistribute(
414 Distribute(expression, factor,
true);
419 Expr
const& expression,
420 std::function<
bool(Expr
const&)> f,
426 std::function<
bool(Expr
const&)> f,
431 inline Expr DeepDistributedIf(
432 Expr
const& expression,
433 std::function<
bool(Expr
const&)> f
436 return DistributedIf(expression, f,
true);
439 inline void DeepDistributeIf(
441 std::function<
bool(Expr
const&)> f
444 return DistributeIf(expression, f,
true);
448 Expr GetTerm(
const Expr& expression);
451 Expr Derived(
const Expr& expression,
456 const Expr& expression,
457 const Expr& variable)
459 return Derived(expression, variable.get());
466 expression = Derived(expression, variable);
471 const Expr& variable)
473 expression = Derived(expression, variable);
477 Expr GetPolynomialTerm(
const Expr& expression,
482 inline Expr GetPolynomialTerm(
483 const Expr& expression,
484 const Expr& variable,
487 return GetPolynomialTerm(expression, variable.get(), order);
491 Expr Evaluated(
const Expr& expression);
494 Expr Evaluated(
const Expr& expression,
495 csl::eval::mode user_mode);
497 inline void Evaluate(Expr &expr)
499 expr = Evaluated(expr);
502 inline void Evaluate(
504 eval::mode user_mode)
506 expr = Evaluated(expr, user_mode);
512 void SetComplexProperty(
519 void SetComplexProperty(
525 inline void SetComplexProperty(
531 SetComplexProperty(p, prop);
535 Expr GetRealPart(
const Expr& expression);
538 Expr GetImaginaryPart(
const Expr& expression);
541 Expr GetComplexModulus(
const Expr& expression);
544 Expr GetComplexArgument(
const Expr& expression);
547 Expr GetComplexConjugate(
const Expr& expression);
551 Expr GetTransposed(
const Expr& expression,
553 bool applyProp =
true);
556 Expr GetTransposed(
const Expr& expression,
557 const std::vector<const Space*>& spaces,
558 bool applyProp =
true);
561 Expr GetHermitianConjugate(
const Expr& expression,
565 Expr GetHermitianConjugate(
const Expr& expression,
566 const std::vector<const Space*>& spaces);
569 Expr Swapped(
const Expr& expression,
572 bool refresh =
true);
575 Expr Swapped(
const Expr& expression,
578 bool refresh =
true);
581 Expr Swapped(
const Expr& expression,
582 const Parent& index1,
583 const Parent& index2,
584 bool refresh =
true);
593 expression = Swapped(expression, old_obj, new_obj);
602 Expr ContractIndex(
const Expr& expression,
607 const std::string& name =
"");
624 Parent GetParent(Expr
const &tensor);
626 Tensor GetTensorParent(Expr
const &tensor);
628 TensorField GetTensorFieldParent(Expr
const &tensor);
630 TDerivative GetTDerivativeParent(Expr
const &tensor);
632 void AddSelfContraction(
639 void AddContractionProperty(
641 std::vector<Expr>
const &tensors,
645 void AddComplexProperty(
651 void AddTransposedProperty(
658 void AddHermitianProperty(
666 LibDependency GetLibraryDependencies(Expr
const& expression);
669 inline bool IsIndexed(Expr
const &expr) {
670 return expr->isIndexed();
673 inline bool IsNumerical(Expr
const &expr) {
677 inline bool IsLiteral(Expr
const &expr) {
681 inline bool IsScalarFunction(Expr
const &expr) {
685 inline bool IsMultiFunction(Expr
const &expr) {
689 inline bool IsVectorial(Expr
const &expr) {
693 inline bool IsIndicial(Expr
const &expr) {
697 inline bool IsField(Expr
const &expr) {
701 inline bool IsArbitrary(Expr
const &expr) {
702 return expr->getPrimaryType() == csl::PrimaryType::Arbitrary;
706 inline bool IsInteger(Expr
const &expr) {
710 inline bool IsFloat(Expr
const &expr) {
714 inline bool IsIntFraction(Expr
const &expr) {
718 inline bool IsIntFactorial(Expr
const &expr) {
722 inline bool IsComplex(Expr
const &expr) {
726 inline bool IsNumericalEval(Expr
const &expr) {
730 inline bool IsImaginary(Expr
const &expr) {
734 inline bool IsConstant(Expr
const &expr) {
738 inline bool IsVariable(Expr
const &expr) {
742 inline bool IsExp(Expr
const &expr) {
746 inline bool IsLog(Expr
const &expr) {
750 inline bool IsDiracDelta(Expr
const &expr) {
754 inline bool IsAbs(Expr
const &expr) {
758 inline bool IsCos(Expr
const &expr) {
762 inline bool IsSin(Expr
const &expr) {
766 inline bool IsTan(Expr
const &expr) {
770 inline bool IsCosh(Expr
const &expr) {
774 inline bool IsSinh(Expr
const &expr) {
778 inline bool IsTanh(Expr
const &expr) {
782 inline bool IsACos(Expr
const &expr) {
786 inline bool IsASin(Expr
const &expr) {
790 inline bool IsATan(Expr
const &expr) {
794 inline bool IsACosh(Expr
const &expr) {
798 inline bool IsASinh(Expr
const &expr) {
802 inline bool IsATanh(Expr
const &expr) {
806 inline bool IsScalar(Expr
const &expr) {
810 inline bool IsRealPart(Expr
const &expr) {
814 inline bool IsImaginaryPart(Expr
const &expr) {
818 inline bool IsITensor(Expr
const &expr) {
822 inline bool IsScalarField(Expr
const &expr) {
826 inline bool IsTensorField(Expr
const &expr) {
830 inline bool IsTensorialDerivative(Expr
const &expr) {
831 return expr->getType() == csl::Type::TDerivativeElement;
834 inline bool IsStandardDuo(Expr
const &expr) {
838 inline bool IsStandardMult(Expr
const &expr) {
842 inline bool IsPow(Expr
const &expr) {
846 inline bool IsProd(Expr
const &expr) {
850 inline bool IsSum(Expr
const &expr) {
854 inline bool IsPolynomial(Expr
const &expr) {
858 inline bool IsDerivative(Expr
const &expr) {
862 inline bool IsCommutator(Expr
const &expr) {
866 inline bool IsAngle(Expr
const &expr) {
870 inline bool IsFactorial(Expr
const &expr) {
874 inline bool IsIntegral(Expr
const &expr) {
878 inline bool IsScalarIntegral(Expr
const &expr) {
882 inline bool IsVectorIntegral(Expr
const &expr) {
886 inline bool IsVector(Expr
const &expr) {
890 inline bool IsMatrix(Expr
const &expr) {
894 inline bool IsHighDTensor(Expr
const &expr) {
899 inline bool IsIndexed(Expr_info expr) {
900 return expr->isIndexed();
903 inline bool IsNumerical(Expr_info expr) {
907 inline bool IsLiteral(Expr_info expr) {
911 inline bool IsScalarFunction(Expr_info expr) {
915 inline bool IsMultiFunction(Expr_info expr) {
919 inline bool IsVectorial(Expr_info expr) {
923 inline bool IsIndicial(Expr_info expr) {
927 inline bool IsField(Expr_info expr) {
931 inline bool IsArbitrary(Expr_info expr) {
932 return expr->getPrimaryType() == csl::PrimaryType::Arbitrary;
936 inline bool IsInteger(Expr_info expr) {
940 inline bool IsFloat(Expr_info expr) {
944 inline bool IsIntFraction(Expr_info expr) {
948 inline bool IsIntFactorial(Expr_info expr) {
952 inline bool IsComplex(Expr_info expr) {
956 inline bool IsNumericalEval(Expr_info expr) {
960 inline bool IsImaginary(Expr_info expr) {
964 inline bool IsConstant(Expr_info expr) {
968 inline bool IsVariable(Expr_info expr) {
972 inline bool IsExp(Expr_info expr) {
976 inline bool IsLog(Expr_info expr) {
980 inline bool IsDiracDelta(Expr_info expr) {
984 inline bool IsAbs(Expr_info expr) {
988 inline bool IsCos(Expr_info expr) {
992 inline bool IsSin(Expr_info expr) {
996 inline bool IsTan(Expr_info expr) {
1000 inline bool IsCosh(Expr_info expr) {
1004 inline bool IsSinh(Expr_info expr) {
1008 inline bool IsTanh(Expr_info expr) {
1012 inline bool IsACos(Expr_info expr) {
1016 inline bool IsASin(Expr_info expr) {
1020 inline bool IsATan(Expr_info expr) {
1024 inline bool IsACosh(Expr_info expr) {
1028 inline bool IsASinh(Expr_info expr) {
1032 inline bool IsATanh(Expr_info expr) {
1036 inline bool IsScalar(Expr_info expr) {
1040 inline bool IsRealPart(Expr_info expr) {
1044 inline bool IsImaginaryPart(Expr_info expr) {
1048 inline bool IsITensor(Expr_info expr) {
1052 inline bool IsScalarField(Expr_info expr) {
1056 inline bool IsTensorField(Expr_info expr) {
1060 inline bool IsTensorialDerivative(Expr_info expr) {
1061 return expr->getType() == csl::Type::TDerivativeElement;
1064 inline bool IsStandardDuo(Expr_info expr) {
1068 inline bool IsStandardMult(Expr_info expr) {
1072 inline bool IsPow(Expr_info expr) {
1076 inline bool IsProd(Expr_info expr) {
1080 inline bool IsSum(Expr_info expr) {
1084 inline bool IsPolynomial(Expr_info expr) {
1088 inline bool IsDerivative(Expr_info expr) {
1092 inline bool IsCommutator(Expr_info expr) {
1096 inline bool IsAngle(Expr_info expr) {
1100 inline bool IsFactorial(Expr_info expr) {
1104 inline bool IsIntegral(Expr_info expr) {
1108 inline bool IsScalarIntegral(Expr_info expr) {
1112 inline bool IsVectorIntegral(Expr_info expr) {
1116 inline bool IsVector(Expr_info expr) {
1120 inline bool IsMatrix(Expr_info expr) {
1124 inline bool IsHighDTensor(Expr_info expr) {
1157 std::vector<Expr>
const& prod,
1171 std::vector<Expr_info> encountered
1172 = std::vector<Expr_info>());
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
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