Documentation of CSL
operations.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 OPERATIONS_H_INCLUDED
22 #define OPERATIONS_H_INCLUDED
23 #include "scalarFunc.h"
24 #include "operator.h"
25 
26 namespace csl {
27 
28 // inline bool testOperatorComparison = false;
29 
33 class Sum: public AbstractMultiFunc{
34 
35  public:
36 
39  Sum();
40 
44  Sum(const csl::vector_expr& operands, bool explicitSum=false);
45 
50  Sum(const Expr& leftOperand,
51  const Expr& rightOperand,
52  bool explicitSum = false);
53 
54 
55 #ifdef DEBUG
56  ~Sum(){ __record_data_alloc(static_cast<int>(getType())); }
57 #endif
58 
62  csl::Type getType() const override {
63  return csl::Type::Sum;
64  }
65 
66  virtual bool isIndexed() const override { return false; }
67 
70  Expr getNumericalFactor() const override;
71 
72  int getOrderOf(Expr_info expr) const override;
73 
76  std::optional<Expr> getTerm() const override;
77 
81  csl::vector_expr getFactors() const override;
82 
83  std::optional<Expr> getRealPart() const override;
84 
85  Expr getImaginaryPart() const override;
86 
87  std::optional<Expr> getComplexModulus() const override;
88 
89  std::optional<Expr> getComplexArgument() const override;
90 
91  void insert(const Expr& expr, bool explicitSum=false) override;
92 
93  void print(int mode=0,
94  std::ostream& out=std::cout,
95  bool lib = false) const override;
96 
97  void printCode(
98  int mode=0,
99  std::ostream& out=std::cout
100  ) const override;
101 
102  std::string printLaTeX(int mode=0) const override;
103 
109  long double evaluateScalar() const override;
110 
111  std::optional<Expr> evaluate(
112  csl::eval::mode user_mode = csl::eval::base
113  ) const override;
114 
115  unique_Expr copy_unique() const override;
116 
117  Expr deepCopy() const override;
118 
119  Expr refresh() const override;
120 
121  Expr deepRefresh() const override;
122 
129  virtual bool mergeTerms();
130 
131  void orderTerms();
132 
137  std::optional<Expr> derive(Expr_info expr) const override;
138 
142  std::optional<Expr> factor(bool full=false) const override;
143 
148  std::optional<Expr> factor(Expr_info expr, bool full=false) const override;
149 
150  std::optional<Expr> collect(
151  std::vector<Expr> const &factors,
152  bool full
153  ) const override;
154 
155  bool askTerm(Expr_info term, bool exact=false) const override;
156 
157  Expr suppressTerm(Expr_info term) const override;
158 
159  int getParity(Expr_info t_variable) const override;
160 
161  bool operator==(Expr_info expr) const override;
162 
163  csl::vector_expr getAlternateForms() const override;
164 
165  bool operator<(const Abstract* expr) const override;
166 
167  protected:
168 
169  virtual void gatherFactors(
170  csl::vector_expr& factors,
171  csl::vector_expr& arg,
172  bool full
173  ) const;
174 
175  void clearRedundantFactors(csl::vector_expr& factors) const;
176 };
177 
182 
183  private:
184 
185  Expr variable;
186 
187  public:
188 
191  Polynomial();
192 
198  Polynomial(const Expr& expr, const Expr& t_variable);
199 
205  Polynomial(const csl::vector_expr& terms, const Expr& t_variable);
206 
207 
208 #ifdef DEBUG
209  ~Polynomial(){ __record_data_alloc(static_cast<int>(getType())); }
210 #endif
211 
212  bool mergeTerms();
213 
217  csl::Type getType() const override {
218  return csl::Type::Polynomial;
219  }
220 
221  int getOrder() const override;
222 
223  int getOrderOf(Expr_info expr) const override;
224 
225  Expr getVariable() const override;
226 
227  virtual bool isIndexed() const override;
228 
229  IndexStructure getIndexStructure() const override;
230 
231  void print(int mode=0,
232  std::ostream& out=std::cout,
233  bool lib = false) const override;
234 
235  void printCode(
236  int mode=0,
237  std::ostream& out=std::cout
238  ) const override;
239 
240  std::string printLaTeX(int mode=0) const override;
241 
247  long double evaluateScalar() const override;
248 
249  std::optional<Expr> evaluate(
250  csl::eval::mode user_mode = csl::eval::base
251  ) const override;
252 
253  unique_Expr copy_unique() const override;
254 
255  Expr deepCopy() const override;
256 
257  Expr refresh() const override;
258 
259  Expr deepRefresh() const override;
260 
265  std::optional<Expr> derive(Expr_info expr) const override;
266 
267  int getParity(Expr_info t_variable) const override;
268 
269  Expr getRegularExpression() const override;
270 
271  Expr addition_own(const Expr& expr) const override;
272 
273  Expr multiplication_own(const Expr& expr, bool side=1) const override;
274 
275  Expr division_own(const Expr& expr) const override;
276 
277  std::optional<Expr> factor(bool full=false) const override;
278 
279  bool operator==(Expr_info expr) const override;
280 
281  bool operator<(const Abstract* expr) const override;
282 };
283 
284 void getExponentStructure(const Expr& argument, Expr& term, Expr& exponent);
285 
289 class Prod: public AbstractMultiFunc{
290 
291  public:
292 
295  Prod();
296 
302  Prod(const csl::vector_expr& t_argument, bool explicitProd=0);
303 
310  Prod(const Expr& leftOperand, const Expr& rightOperand, bool explicitProd=0);
311 
312 
313 #ifdef DEBUG
314  ~Prod(){ __record_data_alloc(static_cast<int>(getType())); }
315 #endif
316 
320  csl::Type getType() const override {
321  return csl::Type::Prod;
322  }
323 
324  virtual bool isIndexed() const override { return false; }
325 
326  int getOrderOf(Expr_info expr) const override;
327 
328  //IndexStructure getIndexStructure() const override;
329 
330  //virtual void selfCheckIndexStructure();
331 
332  std::optional<Expr> getRealPart() const override;
333 
334  Expr getImaginaryPart() const override;
335 
336  std::optional<Expr> getComplexModulus() const override;
337 
338  std::optional<Expr> getComplexArgument() const override;
339 
340  std::optional<Expr> getHermitianConjugate(
341  const Space* space) const override;
342 
343  std::optional<Expr> getHermitianConjugate(
344  const std::vector<const Space*>& spaces) const override;
345 
346  std::optional<Expr> findSubExpression(
347  Expr_info subExpression,
348  const Expr& newExpression) const override;
349 
352  Expr getNumericalFactor() const override;
353 
356  std::optional<Expr> getTerm() const override;
357 
361  int getNFactor() const override;
362 
366  csl::vector_expr getFactors() const override;
367 
368  void getExponents(
369  std::vector<Expr> const &factors,
370  std::vector<Expr> &exponents
371  ) const override;
372 
378  bool askTerm(Expr_info expr, bool exact=false) const override;
379 
386  Expr suppressTerm(Expr_info expr) const override;
387 
388  std::optional<Expr> suppressExponent(
389  Expr const &factor,
390  Expr const &exponent
391  ) const override;
392 
393  void insert(const Expr& expr, bool side=1) override;
394  virtual void leftInsert(const Expr& expr);
395  virtual void rightInsert(const Expr& expr);
396 
397  void print(int mode=0,
398  std::ostream& out=std::cout,
399  bool lib = false) const override;
400 
401  void printCode(
402  int mode = 0,
403  std::ostream &out = std::cout
404  ) const override;
405 
406  std::string printLaTeX(int mode=0) const override;
407 
413  long double evaluateScalar() const override;
414 
415  std::optional<Expr> evaluate(
416  csl::eval::mode user_mode = csl::eval::base
417  ) const override;
418 
419  unique_Expr copy_unique() const override;
420 
421  Expr deepCopy() const override;
422 
423  Expr refresh() const override;
424 
425  Expr deepRefresh() const override;
426 
427  bool mergeNumericals();
428 
429  void mergeProducts();
430 
437  virtual bool mergeTerms();
438 
439  void orderTerms();
440 
445  std::optional<Expr> derive(Expr_info expr) const override;
446 
451  std::optional<Expr> expand(bool full=false,
452  bool inPlace=false) const override;
453 
462  virtual std::optional<Expr> expand_if(
463  std::function<bool(Expr const&)> const& f,
464  bool full=false,
465  bool inPlace=false) const override;
466 
467  int isPolynomial(Expr_info expr) const override;
468 
469  std::optional<Expr> getPolynomialTerm(
470  Expr_info t_variable, int order) const override;
471 
472  int getParity(Expr_info t_variable) const override;
473 
474  virtual bool operator==(Expr_info expr) const override;
475 
476  virtual bool partialComparison(Expr_info expr) const;
477 
478  csl::vector_expr getAlternateForms() const override;
479 
480  bool operator<(const Abstract* expr) const override;
481 };
482 
486 class Pow: public AbstractDuoFunc{
487 
488  public:
489 
492  Pow();
493 
498  Pow(const Expr& leftOperand,
499  const Expr& rightOperand,
500  bool explicitPow = false);
501 
502 
503 #ifdef DEBUG
504  ~Pow(){ __record_data_alloc(static_cast<int>(getType())); }
505 #endif
506 
510  csl::Type getType() const override {
511  return csl::Type::Pow;
512  }
513 
514  Expr getNumericalFactor() const override;
515 
516  std::optional<Expr> getTerm() const override;
517 
518  int getOrderOf(Expr_info expr) const override;
519 
524  int getNFactor() const override;
525 
529  csl::vector_expr getFactors() const override;
530 
531  void getExponents(
532  std::vector<Expr> const &factors,
533  std::vector<Expr> &exponents
534  ) const override;
535 
541  bool askTerm(Expr_info expr, bool exact=false) const override;
542 
549  Expr suppressTerm(Expr_info expr) const override;
550 
551  std::optional<Expr> suppressExponent(
552  Expr const &factor,
553  Expr const &exponent
554  ) const override;
555 
556  void print(int mode=0,
557  std::ostream& out=std::cout,
558  bool lib = false) const override;
559 
560  void printCode(
561  int mode = 0,
562  std::ostream &out = std::cout
563  ) const override;
564 
565  std::string printLaTeX(int mode=0) const override;
566 
567  LibDependency getLibDependency() const override;
568 
574  long double evaluateScalar() const override;
575 
576  std::optional<Expr> evaluate(
577  csl::eval::mode user_mode = csl::eval::base
578  ) const override;
579 
580  unique_Expr copy_unique() const override;
581 
582  Expr deepCopy() const override;
583 
584  Expr refresh() const override;
585 
586  Expr deepRefresh() const override;
587 
594  bool mergeTerms();
595 
600  std::optional<Expr> derive(Expr_info expr) const override;
601 
606  std::optional<Expr> expand(bool full=false,
607  bool inplace=false) const override;
608 
617  virtual std::optional<Expr> expand_if(
618  std::function<bool(Expr const&)> const& f,
619  bool full=false,
620  bool inplace=false) const override;
621 
622  int isPolynomial(Expr_info expr) const override;
623 
624  std::optional<Expr> getPolynomialTerm(
625  Expr_info t_variable, int order) const override;
626 
627  int getParity(Expr_info t_variable) const override;
628 
629  bool operator==(Expr_info expr) const override;
630 
631  csl::vector_expr getAlternateForms() const override;
632 
633  bool operator<(const Abstract* expr) const override;
634 };
635 
636 
640 class Derivative: public Operator<AbstractDuoFunc>{
641 
642  protected:
643 
644  int order;
645 
646  public:
647 
650  Derivative();
651 
657  Derivative(const Expr& variable, int order);
658 
664  Derivative(const Expr& leftOperand, const Expr& rightOperand);
665 
671  Derivative(const Expr& leftOperand, const Expr& rightOperand, int t_order);
672 
673  Derivative(const Expr& leftOperand, const Expr& rightOperand,
674  int t_order, bool t_empty);
675 
676 
677 #ifdef DEBUG
678  ~Derivative(){ __record_data_alloc(static_cast<int>(getType())); }
679 #endif
680 
684  csl::Type getType() const override {
685  return csl::Type::Derivative;
686  }
687 
688  Expr getVariable() const override;
689 
690  Expr getOperand() const override;
691 
692  int getOrder() const override;
693 
694  void setOperand(const Expr& t_operand) override;
695 
696  void print(int mode=0,
697  std::ostream& out=std::cout,
698  bool lib = false) const override;
699 
700  void printCode(
701  int mode = 0,
702  std::ostream &out = std::cout
703  ) const override;
704 
705  std::string printLaTeX(int mode=0) const override;
706 
712  long double evaluateScalar() const override;
713 
714  std::optional<Expr> evaluate(
715  csl::eval::mode user_mode = csl::eval::base
716  ) const override;
717 
718  unique_Expr copy_unique() const override;
719 
720  Expr deepCopy() const override;
721 
722  Expr refresh() const override;
723 
724  Expr deepRefresh() const override;
725 
730  std::optional<Expr> derive(Expr_info expr) const override;
731 
732  int getParity(Expr_info t_variable) const override;
733 
734  bool operatorAppliesOn(Expr_info expr) const override;
735 
736  bool operator==(Expr_info expr) const override;
737 
738  bool operator<(const Abstract* expr) const override;
739 };
740 
741 class Integral: public Operator<AbstractDuoFunc>{
742 
743  protected:
744 
745  Expr inf;
746  Expr sup;
747 
748  public:
749 
750  Integral();
751 
752  explicit Integral(const Expr& variable);
753 
754  Integral(const Expr& leftOperand, const Expr& rightOperand);
755 
756  Integral(const Expr& leftOperand, const Expr& rightOperand, bool t_empty);
757 
758  Integral(const Expr& leftOperand, const Expr& rightOperand,
759  const Expr& t_inf, const Expr& t_sup);
760 
761  Integral(const Expr& leftOperand, const Expr& rightOperand, bool t_empty,
762  const Expr& t_inf, const Expr& t_sup);
763 
764 
765 #ifdef DEBUG
766  ~Integral(){ __record_data_alloc(static_cast<int>(getType())); }
767 #endif
768 
772  csl::Type getType() const override {
773  return csl::Type::Integral;
774  }
775 
776  Expr getVariable() const override;
777 
778  Expr getOperand() const override;
779 
780  Expr getSupBoundary() const override;
781 
782  Expr getInfBoundary() const override;
783 
784  void setOperand(const Expr& t_operand) override;
785 
786  void print(int mode=0,
787  std::ostream& out=std::cout,
788  bool lib = false) const override;
789 
790  void printCode(
791  int mode = 0,
792  std::ostream &out = std::cout
793  ) const override;
794 
795  std::string printLaTeX(int mode=0) const override;
796 
797  //long double evaluateScalar() const override;
798 
799  Expr suppressTerm(Expr_info term) const override;
800 
801  Expr evaluateIntegral() const;
802 
803  std::optional<Expr> evaluate(
804  csl::eval::mode user_mode = csl::eval::base
805  ) const override;
806 
807  unique_Expr copy_unique() const override;
808 
809  Expr deepCopy() const override;
810 
811  Expr refresh() const override;
812 
813  Expr deepRefresh() const override;
814 
815  std::optional<Expr> derive(Expr_info expr) const override;
816 
817  int getParity(Expr_info t_variable) const override;
818 
819  bool operatorAppliesOn(Expr_info expr) const override;
820 
821  bool dependsOn(Expr_info var) const override;
822 
823  bool dependsExplicitlyOn(Expr_info var) const override;
824 
825  bool operator==(Expr_info expr) const override;
826 
827  bool operator<(const Abstract* expr) const override;
828 
829  protected:
830 
831  /*bool evaluateDelta(Expr& res, const Expr& dep) const;
832 
833  bool evaluateExpProduct(Expr& res, const Expr& dep) const;*/
834 };
835 
836 void applyOperator(Expr& product);
837 
838 /*************************************************/
839 // Inline functions (non virtual and short) //
840 /*************************************************/
843 inline Polynomial::Polynomial(): AbstractMultiFunc(), variable(CSL_0){}
845 
847 {
848  argument[0] = CSL_1;
849  argument[1] = CSL_0;
850 }
851 inline Derivative::Derivative(const Expr& t_variable,
852  int t_order)
853  :Operator<AbstractDuoFunc>(), order(t_order)
854 {
855  argument[0] = CSL_1;
856  argument[1] = t_variable;
857 }
858 inline Derivative::Derivative(const Expr& leftOperand,
859  const Expr& rightOperand)
860  : Operator<AbstractDuoFunc>(), order(1)
861 {
862  argument[0] = leftOperand;
863  argument[1] = rightOperand;
864  if (*argument[1] != CSL_1)
865  empty = false;
866 }
867 inline Derivative::Derivative(const Expr& leftOperand,
868  const Expr& rightOperand,
869  int t_order)
870  :Operator<AbstractDuoFunc>(), order(t_order)
871 {
872  argument[0] = leftOperand;
873  argument[1] = rightOperand;
874  if (*argument[1] != CSL_1)
875  empty = false;
876 }
877 inline Derivative::Derivative(const Expr& leftOperand, const Expr& rightOperand,
878  int t_order, bool t_empty)
879  :Operator<AbstractDuoFunc>(), order(t_order)
880 {
881  argument[0] = leftOperand;
882  argument[1] = rightOperand;
883  empty = t_empty;
884 }
885 
886 inline Integral::Integral(): Operator<AbstractDuoFunc>()
887 {
888  argument[0] = CSL_1;
889  argument[1] = CSL_0;
890  inf = -CSL_INF;
891  sup = CSL_INF;
892 }
893 inline Integral::Integral(const Expr& t_variable)
894  :Integral()
895 {
896  argument[1] = t_variable;
897 }
898 Expr tensor_s(const std::vector<int>& shape, const Expr& filler);
899 inline Integral::Integral(const Expr& leftOperand, const Expr& rightOperand)
900  :Integral()
901 {
902 // if (rightOperand->getDim() > 0)
903  // callError(cslError::UndefinedBehaviour,
904  // "Integral::Integral(const Expr&, const Expr&)");
905  argument[0] = leftOperand;
906  argument[1] = rightOperand;
907  inf = -CSL_INF;
908  sup = CSL_INF;
909  if (*argument[1] != CSL_1)
910  empty = false;
911 }
912 
913 inline Integral::Integral(const Expr& leftOperand, const Expr& rightOperand,
914  bool t_empty):Integral(leftOperand, rightOperand)
915 {
916  empty = t_empty;
917 }
918 inline Integral::Integral(const Expr& leftOperand, const Expr& rightOperand,
919  const Expr& t_inf, const Expr& t_sup)
920  :Integral()
921 {
922  inf = t_inf;
923  sup = t_sup;
924  argument[0] = leftOperand;
925  argument[1] = rightOperand;
926  if (*argument[1] != CSL_1)
927  empty = false;
928 }
929 
930 inline Integral::Integral(const Expr& leftOperand, const Expr& rightOperand,
931  bool t_empty, const Expr& t_inf, const Expr& t_sup)
932  :Integral(leftOperand, rightOperand, t_inf, t_sup)
933 {
934  empty = t_empty;
935 }
936 
937 inline csl::allocator<Sum> alloc_sum;
938 inline csl::allocator<Prod> alloc_prod;
939 inline csl::allocator<Pow> alloc_pow;
940 
941 } // End of namespace csl
942 
943 #endif
virtual Expr addition_own(const Expr &expr) const
Contains implementation of special addition for Numerical- and Vectorial-types.
Definition: abstract.cpp:878
std::optional< Expr > findSubExpression(Expr_info subExpression, const Expr &newExpression) const override
Searches a sub-expression and replaces it.
Definition: scalarFunc.cpp:739
Polynomial()
Default constructor. Initializes argument to an empty std::vector, order to 0.
Definition: operations.h:843
Expr getNumericalFactor() const override
Definition: operations.cpp:530
int getParity(Expr_info t_variable) const override
Returns the parity property of the expression with respect to t_variable.
Definition: operations.cpp:893
virtual void getExponents(std::vector< Expr > const &factors, std::vector< Expr > &exponents) const
Fills in a vector the exponents corresponding to some factors for the expression. ...
Definition: abstract.cpp:609
Namespace for csl library.
Definition: abreviation.h:34
void insert(const Expr &expr, bool explicitSum=false) override
Inserts an expression in a sum or a product.
Definition: operations.cpp:129
virtual std::optional< Expr > suppressExponent(Expr const &factor, Expr const &exponent) const
Returns the expression where the factor factor^exponent has been suppressed.
Definition: abstract.cpp:784
Handle functions of multiple arguments. In the case of the call of a simplification function...
Definition: scalarFunc.h:199
Handles a sum, function of multiple arguments.
Definition: operations.h:33
bool askTerm(Expr_info term, bool exact=false) const override
Check if expr can factor *this.
Definition: operations.cpp:866
std::string printLaTeX(int mode=0) const override
Creates a LaTeX output for the Abstract.
Definition: operations.cpp:224
Expr suppressTerm(Expr_info term) const override
Remove a factor from an expr, that must have been determined before.
Definition: operations.cpp:880
virtual IndexStructure getIndexStructure() const
Definition: abstract.cpp:222
Handles a product, function of multiple arguments.
Definition: operations.h:289
Type
Enum of the different types of Abstract (i.e. list of all possible specializations).
Definition: enum.h:47
Expr getImaginaryPart() const override
Evaluates the imaginary part of the Abstract and returns it.
Definition: operations.cpp:99
Definition: operations.h:741
std::optional< Expr > factor(bool full=false) const override
Factors the expr if common factors are found.
Definition: operations.cpp:689
virtual int getOrder() const
Accessor to the order (integer) that defines certain types of expressions.
Definition: abstract.cpp:621
virtual bool isIndexed() const override
Definition: operations.h:324
std::optional< Expr > evaluate(csl::eval::mode user_mode=csl::eval::base) const override
Evaluates the Abstract.
Definition: operations.cpp:254
csl::Type getType() const override
Gives the type of a Derivative object.
Definition: operations.h:684
csl::vector_expr argument
std::vector containing the arguments.
Definition: scalarFunc.h:349
virtual Expr getRegularExpression() const
Returns a regular expression from the polynomial, that is a sum where the different powers of the var...
Definition: abstract.cpp:965
Pow()
Default constructor. Initializes both arguments to 0.
Definition: operations.h:844
virtual bool mergeTerms()
Merge identical terms.
Definition: operations.cpp:324
const csl::Expr CSL_INF
Represents infinity in the program.
Definition: literal.h:607
std::optional< Expr > getComplexArgument() const override
Evaluates the argument in the complex plane of the Abstract and returns it.
Definition: operations.cpp:121
void print(int mode=0, std::ostream &out=std::cout, bool lib=false) const override
Displays the abstract in standard output.
Definition: operations.cpp:182
bool dependsExplicitlyOn(Expr_info expr) const override
Check recursively if expr is present in the expression.
Definition: scalarFunc.cpp:1061
csl::Type getType() const override
Gives the type of a Polynomial object.
Definition: operations.h:217
Sum()
Default constructor. Initializes argument to an empty std::vector.
Definition: operations.h:841
long double evaluateScalar() const override
Return the sum of all the arguments.
Definition: operations.cpp:242
csl::Type getType() const override
Gives the type of a Integral object.
Definition: operations.h:772
virtual bool isIndexed() const override
Definition: operations.h:66
Generic template to handle operator expression, i.e. expression that applies on expressions on the ri...
csl::Type getType() const override
Gives the type of a Sum object.
Definition: operations.h:62
Definition: librarydependency.h:33
std::optional< Expr > derive(Expr_info expr) const override
Derives the sum.
Definition: operations.cpp:514
Prod()
Default constructor. Initializes argument to an empty std::vector.
Definition: operations.h:842
std::optional< Expr > getRealPart() const override
Evaluates the real part of the Abstract and returns it.
Definition: operations.cpp:85
std::optional< Expr > getTerm() const override
Definition: operations.cpp:560
bool dependsOn(Expr_info expr) const override
Check recursively if the expression depends on expr.
Definition: scalarFunc.cpp:1037
Root class of the inheritance tree of abstracts.
Definition: abstract.h:76
virtual std::optional< Expr > expand(bool full=false, bool inPlace=false) const override
Develops the Abstract.
Definition: scalarFunc.cpp:995
Handles a polynomial, function of multiple arguments.
Definition: operations.h:181
std::optional< Expr > collect(std::vector< Expr > const &factors, bool full) const override
Collects terms in sum according to some factors given by the user.
Definition: operations.cpp:774
Handles the exponentiation of one Abstract wrt another.
Definition: operations.h:486
Base classes for scalar functions.
Vector space that has a name, a dimension, a delta tensor and possibly a non-trivial metric...
Definition: space.h:64
virtual Expr multiplication_own(const Expr &expr, bool side=1) const
Contains implementation of special multiplication for Numerical- and Vectorial-types.
Definition: abstract.cpp:885
virtual int getNFactor() const
Definition: abstract.cpp:594
csl::vector_expr getFactors() const override
Returns all the possible factors.
Definition: operations.cpp:575
Handles the exponentiation of one Abstract wrt another.
Definition: operations.h:640
Handle functions of multiple arguments. In the case of the call of a simplification function...
Definition: scalarFunc.h:345
virtual Expr applyOperator(const Expr &operand, bool leaveEmpty=false) const
Apply the operator on an operand, iif the expression is an operator.
Definition: abstract.cpp:1022
virtual std::optional< Expr > getPolynomialTerm(Expr_info t_variable, int order) const
Calculates and returns the polynomial term corresponding to *this with the variable t_variable at ord...
Definition: abstract.cpp:950
virtual Expr getVariable() const
Accessor to the variable that defines certain types of expressions.
Definition: abstract.cpp:945
Derivative()
Default constructor. Initializes both arguments to 0, order to 1.
Definition: operations.h:846
virtual void setOperand(const Expr &operand)
Sets the operand of an operator.
Definition: abstract.cpp:854
csl::Type getType() const override
Gives the type of a Prod object.
Definition: operations.h:320
virtual Expr division_own(const Expr &expr) const
Contains implementation of special division for Numerical- and Polynomial-types. For polynomial...
Definition: abstract.cpp:892
csl::vector_expr getAlternateForms() const override
Calculates and returns all possible alternate forms of the expression in terms of simplifications...
Definition: alternateForms.cpp:277
bool operator<(const Expr &a, const Expr &b)
see Abstract::operator<()
Definition: abstract.cpp:1423
Linear operator O(a*X+b*Y) = a*O(X) + b*O(Y)
Definition: operator.h:38
Manages a std::vector of Index, to be used by an TensorElement.
Definition: index.h:472
bool operator==(Expr_info expr) const override
Compares the Abstract with another.
Definition: operations.cpp:908
csl::Type getType() const override
Gives the type of a Pow object.
Definition: operations.h:510
std::optional< Expr > getComplexModulus() const override
Evaluates the modulus in the complex plane of the Abstract and returns it.
Definition: operations.cpp:111
virtual std::optional< Expr > expand_if(std::function< bool(Expr const &)> const &f, bool full=false, bool inPlace=false) const override
Develops the Abstract.
Definition: scalarFunc.cpp:1019
Expression type/.
Definition: abstract.h:1573
virtual Expr getOperand() const
Returns the operand of an Operator.
Definition: abstract.cpp:654
int isPolynomial(Expr_info expr) const override
Determines if the expression is a mononomial term in expr, i.e. a term of the form C*expr^n with C in...
Definition: scalarFunc.cpp:1090