Documentation of CSL
mathFunctions.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 MATHFUNCTIONS_H_INCLUDED
22 #define MATHFUNCTIONS_H_INCLUDED
23 #include "scalarFunc.h"
24 
25 
26 namespace csl {
27 
31 class Abs: public AbstractFunc{
32 
33  public:
34 
37  Abs();
38 
42  explicit Abs(const Expr& t_argument);
43 
44 #ifdef DEBUG
45  ~Abs(){ __record_data_alloc(static_cast<int>(getType())); }
46 #endif
47 
51  csl::Type getType() const override {
52  return csl::Type::Abs;
53  }
54 
55  void print(int mode=0,
56  std::ostream& out=std::cout,
57  bool lib = false) const override;
58 
59  void printCode(
60  int mode = 0,
61  std::ostream &out = std::cout
62  ) const override;
63 
64  std::string printLaTeX(int mode=0) const override;
65 
66  LibDependency getLibDependency() const override;
67 
72  std::optional<Expr> evaluate(
73  csl::eval::mode user_mode = csl::eval::base) const override;
74 
75  unique_Expr copy_unique() const override;
76 
77  Expr deepCopy() const override;
78 
79  Expr refresh() const override;
80 
81  Expr deepRefresh() const override;
82 
86  long double evaluateScalar() const override;
87 
91  std::optional<Expr> derive(Expr_info expr) const override;
92 
93  int getParity(Expr_info t_variable) const override;
94 };
95 
105 Expr abs_s(const Expr& expr);
106 
107 
111 class Exp: public AbstractFunc{
112 
113  public:
114 
117  Exp();
118 
122  explicit Exp(const Expr& t_argument);
123 
124 #ifdef DEBUG
125  ~Exp(){ __record_data_alloc(static_cast<int>(getType())); }
126 #endif
127 
131  csl::Type getType() const override {
132  return csl::Type::Exp;
133  }
134 
135  std::optional<Expr> getRealPart() const override;
136 
137  Expr getImaginaryPart() const override;
138 
139  std::optional<Expr> getComplexModulus() const override;
140 
141  std::optional<Expr> getComplexArgument() const override;
142 
143  void print(int mode=0,
144  std::ostream& out=std::cout,
145  bool lib = false) const override;
146 
147  void printCode(
148  int mode = 0,
149  std::ostream &out = std::cout
150  ) const override;
151 
152  std::string printLaTeX(int mode=0) const override;
153 
154  LibDependency getLibDependency() const override;
155 
159  long double evaluateScalar() const override;
160 
161  std::optional<Expr> evaluate(
162  csl::eval::mode user_mode = csl::eval::base
163  ) const override;
164 
165  unique_Expr copy_unique() const override;
166 
167  Expr deepCopy() const override;
168 
169  Expr refresh() const override;
170 
171  Expr deepRefresh() const override;
172 
176  std::optional<Expr> derive(Expr_info expr) const override;
177 
178  std::optional<Expr> expand(bool full=false,
179  bool inplace=false) const override;
180 
181  std::optional<Expr> expand_if(
182  std::function<bool(Expr const&)> const& f,
183  bool full=false,
184  bool inplace=false) const override;
185 
186  int getParity(Expr_info t_variable) const override;
187 };
188 
198 Expr exp_s(const Expr& expr);
199 
203 class Log: public AbstractFunc{
204 
205  public:
206 
209  Log();
210 
214  explicit Log(const Expr& t_argument);
215 
216 #ifdef DEBUG
217  ~Log(){ __record_data_alloc(static_cast<int>(getType())); }
218 #endif
219 
223  csl::Type getType() const override {
224  return csl::Type::Log;
225  }
226 
227  std::optional<Expr> getRealPart() const override;
228 
229  Expr getImaginaryPart() const override;
230 
231  std::optional<Expr> getComplexModulus() const override;
232 
233  std::optional<Expr> getComplexArgument() const override;
234 
235  void print(int mode=0,
236  std::ostream& out=std::cout,
237  bool lib = false) const override;
238 
239  void printCode(
240  int mode = 0,
241  std::ostream &out = std::cout
242  ) const override;
243 
244  std::string printLaTeX(int mode=0) const override;
245 
246  LibDependency getLibDependency() const override;
247 
251  long double evaluateScalar() const override;
252 
253  std::optional<Expr> evaluate(
254  csl::eval::mode user_mode = csl::eval::base
255  ) const override;
256 
257  unique_Expr copy_unique() const override;
258 
259  Expr deepCopy() const override;
260 
261  Expr refresh() const override;
262 
263  Expr deepRefresh() const override;
264 
268  std::optional<Expr> derive(Expr_info expr) const override;
269 
270  int getParity(Expr_info t_variable) const override;
271 };
272 
282 Expr log_s(const Expr& expr);
283 
287 class Cos: public AbstractFunc{
288 
289  public:
290 
293  Cos();
294 
298  explicit Cos(const Expr& t_argument);
299 
300 #ifdef DEBUG
301  ~Cos(){ __record_data_alloc(static_cast<int>(getType())); }
302 #endif
303 
307  csl::Type getType() const override {
308  return csl::Type::Cos;
309  }
310 
311  std::optional<Expr> getRealPart() const override;
312 
313  Expr getImaginaryPart() const override;
314 
315  std::optional<Expr> getComplexModulus() const override;
316 
317  std::optional<Expr> getComplexArgument() const override;
318 
319  void print(int mode=0,
320  std::ostream& out=std::cout,
321  bool lib = false) const override;
322 
323  void printCode(
324  int mode = 0,
325  std::ostream &out = std::cout
326  ) const override;
327 
328  std::string printLaTeX(int mode=0) const override;
329 
330  LibDependency getLibDependency() const override;
331 
335  long double evaluateScalar() const override;
336 
337  std::optional<Expr> evaluate(
338  csl::eval::mode user_mode = csl::eval::base
339  ) const override;
340 
341  unique_Expr copy_unique() const override;
342 
343  Expr deepCopy() const override;
344 
345  Expr refresh() const override;
346 
347  Expr deepRefresh() const override;
348 
352  std::optional<Expr> derive(Expr_info expr) const override;
353 
354  int getParity(Expr_info t_variable) const override;
355 
356  csl::vector_expr getAlternateForms() const override;
357 };
358 
368 Expr cos_s(const Expr& expr);
369 
373 class Sin: public AbstractFunc{
374 
375  public:
376 
379  Sin();
380 
384  explicit Sin(const Expr& t_argument);
385 
386 #ifdef DEBUG
387  ~Sin(){ __record_data_alloc(static_cast<int>(getType())); }
388 #endif
389 
393  csl::Type getType() const override {
394  return csl::Type::Sin;
395  }
396 
397  std::optional<Expr> getRealPart() const override;
398 
399  Expr getImaginaryPart() const override;
400 
401  std::optional<Expr> getComplexModulus() const override;
402 
403  std::optional<Expr> getComplexArgument() const override;
404 
405  void print(int mode=0,
406  std::ostream& out=std::cout,
407  bool lib = false) const override;
408 
409  void printCode(
410  int mode = 0,
411  std::ostream &out = std::cout
412  ) const override;
413 
414  std::string printLaTeX(int mode=0) const override;
415 
416  LibDependency getLibDependency() const override;
417 
421  long double evaluateScalar() const override;
422 
423  std::optional<Expr> evaluate(
424  csl::eval::mode user_mode = csl::eval::base
425  ) const override;
426 
427  unique_Expr copy_unique() const override;
428 
429  Expr deepCopy() const override;
430 
431  Expr refresh() const override;
432 
433  Expr deepRefresh() const override;
434 
438  std::optional<Expr> derive(Expr_info expr) const override;
439 
440  int getParity(Expr_info t_variable) const override;
441 
442  csl::vector_expr getAlternateForms() const override;
443 };
444 
454 Expr sin_s(const Expr& expr);
455 
459 class Tan: public AbstractFunc{
460 
461  public:
462 
465  Tan();
466 
470  explicit Tan(const Expr& t_argument);
471 
472 #ifdef DEBUG
473  ~Tan(){ __record_data_alloc(static_cast<int>(getType())); }
474 #endif
475 
479  csl::Type getType() const override {
480  return csl::Type::Tan;
481  }
482 
483  std::optional<Expr> getRealPart() const override;
484 
485  Expr getImaginaryPart() const override;
486 
487  std::optional<Expr> getComplexModulus() const override;
488 
489  std::optional<Expr> getComplexArgument() const override;
490 
491  void print(int mode=0,
492  std::ostream& out=std::cout,
493  bool lib = false) const override;
494 
495  void printCode(
496  int mode = 0,
497  std::ostream &out = std::cout
498  ) const override;
499 
500  std::string printLaTeX(int mode=0) const override;
501 
502  LibDependency getLibDependency() const override;
503 
507  long double evaluateScalar() const override;
508 
509  std::optional<Expr> evaluate(
510  csl::eval::mode user_mode = csl::eval::base
511  ) const override;
512 
513  unique_Expr copy_unique() const override;
514 
515  Expr deepCopy() const override;
516 
517  Expr refresh() const override;
518 
519  Expr deepRefresh() const override;
520 
524  std::optional<Expr> derive(Expr_info expr) const override;
525 
526  int getParity(Expr_info t_variable) const override;
527 
528  csl::vector_expr getAlternateForms() const override;
529 };
530 
540 Expr tan_s(const Expr& expr);
541 
545 class ACos: public AbstractFunc{
546 
547  public:
548 
551  ACos();
552 
556  explicit ACos(const Expr& t_argument);
557 
558 #ifdef DEBUG
559  ~ACos(){ __record_data_alloc(static_cast<int>(getType())); }
560 #endif
561 
565  csl::Type getType() const override {
566  return csl::Type::ACos;
567  }
568 
569  std::optional<Expr> getRealPart() const override;
570 
571  Expr getImaginaryPart() const override;
572 
573  std::optional<Expr> getComplexModulus() const override;
574 
575  std::optional<Expr> getComplexArgument() const override;
576 
577  void print(int mode=0,
578  std::ostream& out=std::cout,
579  bool lib = false) const override;
580 
581  void printCode(
582  int mode = 0,
583  std::ostream &out = std::cout
584  ) const override;
585 
586  std::string printLaTeX(int mode=0) const override;
587 
588  LibDependency getLibDependency() const override;
589 
593  long double evaluateScalar() const override;
594 
595  std::optional<Expr> evaluate(
596  csl::eval::mode user_mode = csl::eval::base
597  ) const override;
598 
599  unique_Expr copy_unique() const override;
600 
601  Expr deepCopy() const override;
602 
603  Expr refresh() const override;
604 
605  Expr deepRefresh() const override;
606 
610  std::optional<Expr> derive(Expr_info expr) const override;
611 
612  int getParity(Expr_info t_variable) const override;
613 };
614 
624 Expr acos_s(const Expr& expr);
625 
629 class ASin: public AbstractFunc{
630 
631  public:
632 
635  ASin();
636 
640  explicit ASin(const Expr& t_argument);
641 
642 #ifdef DEBUG
643  ~ASin(){ __record_data_alloc(static_cast<int>(getType())); }
644 #endif
645 
649  csl::Type getType() const override {
650  return csl::Type::ASin;
651  }
652 
653  std::optional<Expr> getRealPart() const override;
654 
655  Expr getImaginaryPart() const override;
656 
657  std::optional<Expr> getComplexModulus() const override;
658 
659  std::optional<Expr> getComplexArgument() const override;
660 
661  void print(int mode=0,
662  std::ostream& out=std::cout,
663  bool lib = false) const override;
664 
665  void printCode(
666  int mode = 0,
667  std::ostream &out = std::cout
668  ) const override;
669 
670  std::string printLaTeX(int mode=0) const override;
671 
672  LibDependency getLibDependency() const override;
673 
677  long double evaluateScalar() const override;
678 
679  std::optional<Expr> evaluate(
680  csl::eval::mode user_mode = csl::eval::base
681  ) const override;
682 
683  unique_Expr copy_unique() const override;
684 
685  Expr deepCopy() const override;
686 
687  Expr refresh() const override;
688 
689  Expr deepRefresh() const override;
690 
694  std::optional<Expr> derive(Expr_info expr) const override;
695 
696  int getParity(Expr_info t_variable) const override;
697 };
698 
708 Expr asin_s(const Expr& expr);
709 
710 
714 class ATan: public AbstractFunc{
715 
716  public:
717 
720  ATan();
721 
725  explicit ATan(const Expr& t_argument);
726 
727 #ifdef DEBUG
728  ~ATan(){ __record_data_alloc(static_cast<int>(getType())); }
729 #endif
730 
734  csl::Type getType() const override {
735  return csl::Type::ATan;
736  }
737 
738  void print(int mode=0,
739  std::ostream& out=std::cout,
740  bool lib = false) const override;
741 
742  void printCode(
743  int mode = 0,
744  std::ostream &out = std::cout
745  ) const override;
746 
747  std::string printLaTeX(int mode=0) const override;
748 
749  LibDependency getLibDependency() const override;
750 
754  long double evaluateScalar() const override;
755 
756  std::optional<Expr> evaluate(
757  csl::eval::mode user_mode = csl::eval::base
758  ) const override;
759 
760  unique_Expr copy_unique() const override;
761 
762  Expr deepCopy() const override;
763 
764  Expr refresh() const override;
765 
766  Expr deepRefresh() const override;
767 
771  std::optional<Expr> derive(Expr_info expr) const override;
772 
773  int getParity(Expr_info t_variable) const override;
774 };
775 
785 Expr atan_s(const Expr& expr);
786 
790 class Angle: public AbstractDuoFunc{
791 
792  public:
793 
796  Angle();
797 
804  Angle(const Expr& leftOperand, const Expr& rightOperand);
805 
806 #ifdef DEBUG
807  ~Angle(){ __record_data_alloc(static_cast<int>(getType())); }
808 #endif
809 
813  csl::Type getType() const override {
814  return csl::Type::Angle;
815  }
816 
817  void print(int mode=0,
818  std::ostream& out=std::cout,
819  bool lib = false) const override;
820 
821  void printCode(
822  int mode = 0,
823  std::ostream &out = std::cout
824  ) const override;
825 
826  std::string printLaTeX(int mode=0) const override;
827 
828  LibDependency getLibDependency() const override;
829 
836  long double evaluateScalar() const override;
837 
838  std::optional<Expr> evaluate(
839  csl::eval::mode user_mode = csl::eval::base) const override;
840 
841  unique_Expr copy_unique() const override;
842 
843  Expr deepCopy() const override;
844 
845  Expr refresh() const override;
846 
847  Expr deepRefresh() const override;
848 
853  std::optional<Expr> derive(Expr_info expr) const override;
854 
855  bool operator==(Expr_info expr) const override;
856 
857  bool operator<(const Abstract* expr) const override;
858 
859  int getParity(Expr_info t_variable) const override;
860 };
861 
862 Expr angle_s(Expr const &a, Expr const &b);
863 
867 class Cosh: public AbstractFunc{
868 
869  public:
870 
873  Cosh();
874 
878  explicit Cosh(const Expr& t_argument);
879 
880 #ifdef DEBUG
881  ~Cosh(){ __record_data_alloc(static_cast<int>(getType())); }
882 #endif
883 
887  csl::Type getType() const override {
888  return csl::Type::Cosh;
889  }
890 
891  std::optional<Expr> getRealPart() const override;
892 
893  Expr getImaginaryPart() const override;
894 
895  std::optional<Expr> getComplexModulus() const override;
896 
897  std::optional<Expr> getComplexArgument() const override;
898 
899  void print(int mode=0,
900  std::ostream& out=std::cout,
901  bool lib = false) const override;
902 
903  void printCode(
904  int mode = 0,
905  std::ostream &out = std::cout
906  ) const override;
907 
908  std::string printLaTeX(int mode=0) const override;
909 
910  LibDependency getLibDependency() const override;
911 
915  long double evaluateScalar() const override;
916 
917  std::optional<Expr> evaluate(
918  csl::eval::mode user_mode = csl::eval::base
919  ) const override;
920 
921  unique_Expr copy_unique() const override;
922 
923  Expr deepCopy() const override;
924 
925  Expr refresh() const override;
926 
927  Expr deepRefresh() const override;
928 
932  std::optional<Expr> derive(Expr_info expr) const override;
933 
934  int getParity(Expr_info t_variable) const override;
935 
936  csl::vector_expr getAlternateForms() const override;
937 };
938 
948 Expr cosh_s(const Expr& expr);
949 
953 class Sinh: public AbstractFunc{
954 
955  public:
956 
959  Sinh();
960 
964  explicit Sinh(const Expr& t_argument);
965 
966 #ifdef DEBUG
967  ~Sinh(){ __record_data_alloc(static_cast<int>(getType())); }
968 #endif
969 
973  csl::Type getType() const override{
974  return csl::Type::Sinh;
975  }
976 
977  std::optional<Expr> getRealPart() const override;
978 
979  Expr getImaginaryPart() const override;
980 
981  std::optional<Expr> getComplexModulus() const override;
982 
983  std::optional<Expr> getComplexArgument() const override;
984 
985  void print(int mode=0,
986  std::ostream& out=std::cout,
987  bool lib = false) const override;
988 
989  void printCode(
990  int mode = 0,
991  std::ostream &out = std::cout
992  ) const override;
993 
994  std::string printLaTeX(int mode=0) const override;
995 
996  LibDependency getLibDependency() const override;
997 
1001  long double evaluateScalar() const override;
1002 
1003  std::optional<Expr> evaluate(
1004  csl::eval::mode user_mode = csl::eval::base
1005  ) const override;
1006 
1007  unique_Expr copy_unique() const override;
1008 
1009  Expr deepCopy() const override;
1010 
1011  Expr refresh() const override;
1012 
1013  Expr deepRefresh() const override;
1014 
1018  std::optional<Expr> derive(Expr_info expr) const override;
1019 
1020  int getParity(Expr_info t_variable) const override;
1021 
1022  csl::vector_expr getAlternateForms() const override;
1023 };
1024 
1034 Expr sinh_s(const Expr& expr);
1035 
1039 class Tanh: public AbstractFunc{
1040 
1041  public:
1042 
1045  Tanh();
1046 
1050  explicit Tanh(const Expr& t_argument);
1051 
1052 #ifdef DEBUG
1053  ~Tanh(){ __record_data_alloc(static_cast<int>(getType())); }
1054 #endif
1055 
1059  csl::Type getType() const override {
1060  return csl::Type::Tanh;
1061  }
1062 
1063  std::optional<Expr> getRealPart() const override;
1064 
1065  Expr getImaginaryPart() const override;
1066 
1067  std::optional<Expr> getComplexModulus() const override;
1068 
1069  std::optional<Expr> getComplexArgument() const override;
1070 
1071  void print(int mode=0,
1072  std::ostream& out=std::cout,
1073  bool lib = false) const override;
1074 
1075  void printCode(
1076  int mode = 0,
1077  std::ostream &out = std::cout
1078  ) const override;
1079 
1080  std::string printLaTeX(int mode=0) const override;
1081 
1082  LibDependency getLibDependency() const override;
1083 
1087  long double evaluateScalar() const override;
1088 
1089  std::optional<Expr> evaluate(
1090  csl::eval::mode user_mode = csl::eval::base
1091  ) const override;
1092 
1093  unique_Expr copy_unique() const override;
1094 
1095  Expr deepCopy() const override;
1096 
1097  Expr refresh() const override;
1098 
1099  Expr deepRefresh() const override;
1100 
1104  std::optional<Expr> derive(Expr_info expr) const override;
1105 
1106  int getParity(Expr_info t_variable) const override;
1107 
1108  csl::vector_expr getAlternateForms() const override;
1109 };
1110 
1120 Expr tanh_s(const Expr& expr);
1121 
1125 class ACosh: public AbstractFunc{
1126 
1127  public:
1128 
1131  ACosh();
1132 
1136  explicit ACosh(const Expr& t_argument);
1137 
1138 #ifdef DEBUG
1139  ~ACosh(){ __record_data_alloc(static_cast<int>(getType())); }
1140 #endif
1141 
1145  csl::Type getType() const override {
1146  return csl::Type::ACosh;
1147  }
1148 
1149  void print(int mode=0,
1150  std::ostream& out=std::cout,
1151  bool lib = false) const override;
1152 
1153  void printCode(
1154  int mode = 0,
1155  std::ostream &out = std::cout
1156  ) const override;
1157 
1158  std::string printLaTeX(int mode=0) const override;
1159 
1160  LibDependency getLibDependency() const override;
1161 
1165  long double evaluateScalar() const override;
1166 
1167  std::optional<Expr> evaluate(
1168  csl::eval::mode user_mode = csl::eval::base
1169  ) const override;
1170 
1171  unique_Expr copy_unique() const override;
1172 
1173  Expr deepCopy() const override;
1174 
1175  Expr refresh() const override;
1176 
1177  Expr deepRefresh() const override;
1178 
1182  std::optional<Expr> derive(Expr_info expr) const override;
1183 
1184  int getParity(Expr_info t_variable) const override;
1185 };
1186 
1196 Expr acosh_s(const Expr& expr);
1197 
1201 class ASinh: public AbstractFunc{
1202 
1203  public:
1204 
1207  ASinh();
1208 
1212  explicit ASinh(const Expr& t_argument);
1213 
1214 #ifdef DEBUG
1215  ~ASinh(){ __record_data_alloc(static_cast<int>(getType())); }
1216 #endif
1217 
1221  csl::Type getType() const override {
1222  return csl::Type::ASinh;
1223  }
1224 
1225  void print(int mode=0,
1226  std::ostream& out=std::cout,
1227  bool lib = false) const override;
1228 
1229  void printCode(
1230  int mode = 0,
1231  std::ostream &out = std::cout
1232  ) const override;
1233 
1234  std::string printLaTeX(int mode=0) const override;
1235 
1236  LibDependency getLibDependency() const override;
1237 
1241  long double evaluateScalar() const override;
1242 
1243  std::optional<Expr> evaluate(
1244  csl::eval::mode user_mode = csl::eval::base
1245  ) const override;
1246 
1247  unique_Expr copy_unique() const override;
1248 
1249  Expr deepCopy() const override;
1250 
1251  Expr refresh() const override;
1252 
1253  Expr deepRefresh() const override;
1254 
1258  std::optional<Expr> derive(Expr_info expr) const override;
1259 
1260  int getParity(Expr_info t_variable) const override;
1261 };
1262 
1272 Expr asinh_s(const Expr& expr);
1273 
1277 class ATanh: public AbstractFunc{
1278 
1279  public:
1280 
1283  ATanh();
1284 
1288  explicit ATanh(const Expr& t_argument);
1289 
1290 #ifdef DEBUG
1291  ~ATanh(){ __record_data_alloc(static_cast<int>(getType())); }
1292 #endif
1293 
1297  csl::Type getType() const override {
1298  return csl::Type::ATanh;
1299  }
1300 
1301  void print(int mode=0,
1302  std::ostream& out=std::cout,
1303  bool lib = false) const override;
1304 
1305  void printCode(
1306  int mode = 0,
1307  std::ostream &out = std::cout
1308  ) const override;
1309 
1310  std::string printLaTeX(int mode=0) const override;
1311 
1312  LibDependency getLibDependency() const override;
1313 
1317  long double evaluateScalar() const override;
1318 
1319  std::optional<Expr> evaluate(
1320  csl::eval::mode user_mode = csl::eval::base
1321  ) const override;
1322 
1323  unique_Expr copy_unique() const override;
1324 
1325  Expr deepCopy() const override;
1326 
1327  Expr refresh() const override;
1328 
1329  Expr deepRefresh() const override;
1330 
1334  std::optional<Expr> derive(Expr_info expr) const override;
1335 
1336  int getParity(Expr_info t_variable) const override;
1337 };
1338 
1348 Expr atanh_s(const Expr& expr);
1349 
1350 
1354 class Factorial: public AbstractFunc{
1355 
1356  public:
1357 
1360  Factorial();
1361 
1365  explicit Factorial(const Expr& t_argument);
1366 
1367 #ifdef DEBUG
1368  ~Factorial(){ __record_data_alloc(static_cast<int>(getType())); }
1369 #endif
1370 
1374  csl::Type getType() const override {
1375  return csl::Type::Factorial;
1376  }
1377 
1378  void print(int mode=0,
1379  std::ostream& out=std::cout,
1380  bool lib = false) const override;
1381 
1382  void printCode(
1383  int mode = 0,
1384  std::ostream &out = std::cout
1385  ) const override;
1386 
1387  std::string printLaTeX(int mode=0) const override;
1388 
1389  LibDependency getLibDependency() const override;
1390 
1394  std::optional<Expr> evaluate(
1395  csl::eval::mode user_mode = csl::eval::base
1396  ) const override;
1397 
1403  long double evaluateScalar() const override;
1404 
1405  unique_Expr copy_unique() const override;
1406 
1407  Expr deepCopy() const override;
1408 
1409  Expr refresh() const override;
1410 
1411  Expr deepRefresh() const override;
1412 
1417  std::optional<Expr> derive(Expr_info expr) const override;
1418 
1419  int getParity(Expr_info t_variable) const override;
1420 };
1421 
1422 Expr factorial_s(const Expr& expr);
1423 
1424 class DiracDelta: public AbstractFunc {
1425 
1426  public:
1427 
1430  DiracDelta();
1431 
1435  explicit DiracDelta(const Expr& t_argument);
1436 
1437 #ifdef DEBUG
1438  ~DiracDelta(){ __record_data_alloc(static_cast<int>(getType())); }
1439 #endif
1440 
1444  csl::Type getType() const override {
1445  return csl::Type::DiracDelta;
1446  }
1447 
1448  unique_Expr copy_unique() const override;
1449 
1450  Expr deepCopy() const override;
1451 
1452  Expr refresh() const override;
1453 
1454  Expr deepRefresh() const override;
1455 
1456  std::optional<Expr> getRealPart() const override;
1457 
1458  Expr getImaginaryPart() const override;
1459 
1460  std::optional<Expr> getComplexModulus() const override;
1461 
1462  std::optional<Expr> getComplexArgument() const override;
1463 
1464  void print(int mode=0,
1465  std::ostream& out=std::cout,
1466  bool lib = false) const override;
1467 
1468  void printCode(
1469  int mode = 0,
1470  std::ostream &out = std::cout
1471  ) const override;
1472 
1473  std::string printLaTeX(int mode=0) const override;
1474 
1478  std::optional<Expr> derive(Expr_info expr) const override;
1479 
1480  int getParity(Expr_info t_variable) const override;
1481 
1482  Expr applyDiracDelta(const Expr& expr, const Expr& variable) const override;
1483 
1484  bool operator==(Expr_info other) const override;
1485 };
1486 
1487 Expr diracdelta_s(const Expr& argument);
1488 
1490 // Inline functions
1491 inline Abs::Abs(): AbstractFunc(){}
1492 inline Abs::Abs(const Expr& t_argument): AbstractFunc(){
1493  argument = t_argument;
1494 }
1495 
1496 inline Exp::Exp(): AbstractFunc(){}
1497 inline Exp::Exp(const Expr& t_argument): AbstractFunc(){
1498  argument = t_argument;
1499 }
1500 
1502  argument = CSL_1;
1503 }
1504 inline Log::Log(const Expr& t_argument): AbstractFunc(){
1505  argument = t_argument;
1506 }
1507 
1509 inline Angle::Angle(const Expr& leftOperand, const Expr& rightOperand)
1510  :AbstractDuoFunc()
1511 {
1512  argument[0] = leftOperand;
1513  argument[1] = rightOperand;
1514 }
1515 
1516 inline Cos::Cos(): AbstractFunc(){}
1517 inline Cos::Cos(const Expr& t_argument): AbstractFunc(){
1518  argument = t_argument;
1519 }
1520 
1521 inline Sin::Sin(): AbstractFunc(){}
1522 inline Sin::Sin(const Expr& t_argument): AbstractFunc(){
1523  argument = t_argument;
1524 }
1525 
1526 inline Tan::Tan(): AbstractFunc(){}
1527 inline Tan::Tan(const Expr& t_argument): AbstractFunc(){
1528  argument = t_argument;
1529 }
1530 
1532 inline Cosh::Cosh(const Expr& t_argument): AbstractFunc(){
1533  argument = t_argument;
1534 }
1535 
1537 inline Sinh::Sinh(const Expr& t_argument): AbstractFunc(){
1538  argument = t_argument;
1539 }
1540 
1542 inline Tanh::Tanh(const Expr& t_argument): AbstractFunc(){
1543  argument = t_argument;
1544 }
1545 
1547 inline ACos::ACos(const Expr& t_argument): AbstractFunc(){
1548  argument = t_argument;
1549 }
1550 
1552 inline ASin::ASin(const Expr& t_argument): AbstractFunc(){
1553  argument = t_argument;
1554 }
1555 
1557 inline ATan::ATan(const Expr& t_argument): AbstractFunc(){
1558  argument = t_argument;
1559 }
1560 
1562 inline ACosh::ACosh(const Expr& t_argument): AbstractFunc(){
1563  argument = t_argument;
1564 }
1565 
1567 inline ASinh::ASinh(const Expr& t_argument): AbstractFunc(){
1568  argument = t_argument;
1569 }
1570 
1572 inline ATanh::ATanh(const Expr& t_argument): AbstractFunc(){
1573  argument = t_argument;
1574 }
1575 
1577 inline Factorial::Factorial(const Expr& t_argument): AbstractFunc(){
1578  argument = t_argument;
1579 }
1581 } // End of namespace csl
1582 
1583 #endif
csl::Type getType() const override
Gives the type of the cosh function.
Definition: mathFunctions.h:887
Expr cos_s(const Expr &expr)
Creates an object of type Cos acting on expr.
Definition: mathFunctions.cpp:532
long double evaluateScalar() const override
Evaluates the function on the argument.
Definition: mathFunctions.cpp:147
Expr cosh_s(const Expr &expr)
Creates an object of type Cosh acting on expr.
Definition: mathFunctions.cpp:1230
Expr acosh_s(const Expr &expr)
Creates an object of type ACosh acting on expr.
Definition: mathFunctions.cpp:1534
Angle()
Default constructor. Initializes both arguments to 0.
Definition: mathFunctions.h:1508
Namespace for csl library.
Definition: abreviation.h:34
Final specialization of AbstractFunc, the logarithm function.
Definition: mathFunctions.h:203
Final specialization of AbstractFunc, the tan function.
Definition: mathFunctions.h:459
csl::Type getType() const override
Gives the type of an Angle object.
Definition: mathFunctions.h:813
Handle functions of multiple arguments. In the case of the call of a simplification function...
Definition: scalarFunc.h:199
csl::Type getType() const override
Gives the type of the atanh function.
Definition: mathFunctions.h:1444
Log()
Default constructor. Initializes argument to 1.
Definition: mathFunctions.h:1501
void print(int mode=0, std::ostream &out=std::cout, bool lib=false) const override
Displays the abstract in standard output.
Definition: mathFunctions.cpp:101
Final specialization of AbstractFunc, the acosh function.
Definition: mathFunctions.h:1125
bool operator==(Expr_info expr) const override
Compares the Abstract with another.
Definition: scalarFunc.cpp:367
ATanh()
Default constructor. Initializes argument to 0.
Definition: mathFunctions.h:1571
csl::Type getType() const override
Gives the type of the acos function.
Definition: mathFunctions.h:565
Handles a angle of 2 arguments.
Definition: mathFunctions.h:790
Type
Enum of the different types of Abstract (i.e. list of all possible specializations).
Definition: enum.h:47
std::string printLaTeX(int mode=0) const override
Creates a LaTeX output for the Abstract.
Definition: mathFunctions.cpp:119
Exp()
Default constructor. Initializes argument to 0.
Definition: mathFunctions.h:1496
Base class for scalar functions of one argument.
Definition: scalarFunc.h:38
csl::Type getType() const override
Gives the type of the exponential function.
Definition: mathFunctions.h:131
Expr atan_s(const Expr &expr)
Creates an object of type ATan acting on expr.
Definition: mathFunctions.cpp:1127
Expr tanh_s(const Expr &expr)
Creates an object of type Tanh acting on expr.
Definition: mathFunctions.cpp:1460
Tan()
Default constructor. Initializes argument to 0.
Definition: mathFunctions.h:1526
Final specialization of AbstractFunc, the tanh function.
Definition: mathFunctions.h:1039
Factorial()
Default constructor. Initializes argument to 0.
Definition: mathFunctions.h:1576
ACos()
Default constructor. Initializes argument to 0.
Definition: mathFunctions.h:1546
std::optional< Expr > getComplexModulus() const override
Evaluates the modulus in the complex plane of the Abstract and returns it.
Definition: scalarFunc.cpp:110
csl::Type getType() const override
Gives the type of the atanh function.
Definition: mathFunctions.h:1297
std::optional< Expr > expand(bool full=false, bool inPlace=false) const override
Develops the Abstract.
Definition: scalarFunc.cpp:236
Expr argument
Argument of the considered function.
Definition: scalarFunc.h:42
Final specialization of AbstractFunc, the sinh function.
Definition: mathFunctions.h:953
Expr abs_s(const Expr &expr)
Creates an object of type Abs acting on expr.
Definition: mathFunctions.cpp:160
Expr asinh_s(const Expr &expr)
Creates an object of type ASinh acting on expr.
Definition: mathFunctions.cpp:1612
Final specialization of AbstractFunc, the asin function.
Definition: mathFunctions.h:629
ASin()
Default constructor. Initializes argument to 0.
Definition: mathFunctions.h:1551
Definition: librarydependency.h:33
Expr asin_s(const Expr &expr)
Creates an object of type ASin acting on expr.
Definition: mathFunctions.cpp:1053
Expr sin_s(const Expr &expr)
Creates an object of type Sin acting on expr.
Definition: mathFunctions.cpp:663
std::optional< Expr > evaluate(csl::eval::mode user_mode=csl::eval::base) const override
Evaluates the absolute value, return |argument|.
Definition: mathFunctions.cpp:137
csl::Type getType() const override
Gives the type of the tanh function.
Definition: mathFunctions.h:1059
Final specialization of AbstractFunc, the atanh function.
Definition: mathFunctions.h:1277
Expr exp_s(const Expr &expr)
Creates an object of type Exp acting on expr.
Definition: mathFunctions.cpp:310
virtual csl::vector_expr getAlternateForms() const
Calculates and returns all possible alternate forms of the expression in terms of simplifications...
Definition: abstract.cpp:1017
Final specialization of AbstractFunc, the sin function.
Definition: mathFunctions.h:373
Expr getImaginaryPart() const override
Evaluates the imaginary part of the Abstract and returns it.
Definition: scalarFunc.cpp:105
csl::Type getType() const override
Gives the type of the logarithm function.
Definition: mathFunctions.h:223
Final specialization of AbstractFunc, the asinh function.
Definition: mathFunctions.h:1201
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:250
Root class of the inheritance tree of abstracts.
Definition: abstract.h:76
csl::Type getType() const override
Gives the type of the sin function.
Definition: mathFunctions.h:393
Expr sinh_s(const Expr &expr)
Creates an object of type Sinh acting on expr.
Definition: mathFunctions.cpp:1333
Final specialization of AbstractFunc, the factorial function.
Definition: mathFunctions.h:1354
std::optional< Expr > derive(Expr_info expr) const override
Derives the abs function.
Definition: mathFunctions.cpp:154
Final specialization of AbstractFunc, the cos function.
Definition: mathFunctions.h:287
Final specialization of AbstractFunc, the abs function.
Definition: mathFunctions.h:31
csl::Type getType() const override
Gives the type of the abs funtion function.
Definition: mathFunctions.h:51
csl::Type getType() const override
Gives the type of the factorial function.
Definition: mathFunctions.h:1374
Base classes for scalar functions.
csl::Type getType() const override
Gives the type of the asin function.
Definition: mathFunctions.h:649
Final specialization of AbstractFunc, the cosh function.
Definition: mathFunctions.h:867
csl::Type getType() const override
Gives the type of the asinh function.
Definition: mathFunctions.h:1221
Final specialization of AbstractFunc, the exponential function.
Definition: mathFunctions.h:111
Expr tan_s(const Expr &expr)
Creates an object of type Tan acting on expr.
Definition: mathFunctions.cpp:813
Final specialization of AbstractFunc, the acos function.
Definition: mathFunctions.h:545
ACosh()
Default constructor. Initializes argument to 0.
Definition: mathFunctions.h:1561
csl::Type getType() const override
Gives the type of the tan function.
Definition: mathFunctions.h:479
Sinh()
Default constructor. Initializes argument to 0.
Definition: mathFunctions.h:1536
csl::Type getType() const override
Gives the type of the acosh function.
Definition: mathFunctions.h:1145
Expr atanh_s(const Expr &expr)
Creates an object of type ATanh acting on expr.
Definition: mathFunctions.cpp:1689
std::optional< Expr > getComplexArgument() const override
Evaluates the argument in the complex plane of the Abstract and returns it.
Definition: scalarFunc.cpp:116
Cos()
Default constructor. Initializes argument to 0.
Definition: mathFunctions.h:1516
Final specialization of AbstractFunc, the atan function.
Definition: mathFunctions.h:714
int getParity(Expr_info t_variable) const override
Returns the parity property of the expression with respect to t_variable.
Definition: mathFunctions.cpp:174
Tanh()
Default constructor. Initializes argument to 0.
Definition: mathFunctions.h:1541
Definition: mathFunctions.h:1424
ASinh()
Default constructor. Initializes argument to 0.
Definition: mathFunctions.h:1566
ATan()
Default constructor. Initializes argument to 0.
Definition: mathFunctions.h:1556
Expr acos_s(const Expr &expr)
Creates an object of type ACos acting on expr.
Definition: mathFunctions.cpp:946
csl::Type getType() const override
Gives the type of the cos function.
Definition: mathFunctions.h:307
csl::Type getType() const override
Gives the type of the sinh function.
Definition: mathFunctions.h:973
bool operator<(const Expr &a, const Expr &b)
see Abstract::operator<()
Definition: abstract.cpp:1423
std::optional< Expr > getRealPart() const override
Evaluates the real part of the Abstract and returns it.
Definition: scalarFunc.cpp:100
Abs()
Default constructor. Initializes argument to 0.
Definition: mathFunctions.h:1491
csl::Type getType() const override
Gives the type of the atan function.
Definition: mathFunctions.h:734
Expr log_s(const Expr &expr)
Creates an object of type Log acting on expr.
Definition: mathFunctions.cpp:423
Sin()
Default constructor. Initializes argument to 0.
Definition: mathFunctions.h:1521
Expression type/.
Definition: abstract.h:1573
Cosh()
Default constructor. Initializes argument to 0.
Definition: mathFunctions.h:1531