Documentation of CSL
numericalEval.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 NUMERICAL_EVAL_H_INCLUDED
24 #define NUMERICAL_EVAL_H_INCLUDED
25 
26 #include "numerical.h"
27 
28 namespace csl {
29 
31 
32  protected:
33 
34  long double value = 0;
35 
36  long double delta_plus = 0;
37 
38  long double delta_minus = 0;
39 
40  public:
41 
42  NumericalEval();
43 
44  explicit
45  NumericalEval(long double value);
46 
47  NumericalEval(long double value,
48  long double delta);
49 
50  NumericalEval(long double value,
51  long double delta_plus,
52  long double delta_minus);
53 
54  NumericalEval(NumericalEval const&) = default;
55 
56  NumericalEval& operator=(NumericalEval const& ) = default;
57 
58 #ifdef DEBUG
59  ~NumericalEval(){ __record_data_alloc(static_cast<int>(getType())); }
60 #else
61 
62  ~NumericalEval(){};
63 #endif
64 
65 
66  csl::Type getType() const override;
67 
68  void print(int mode=0,
69  std::ostream& out=std::cout,
70  bool lib = false) const override;
71 
72  void printCode(
73  int mode=0,
74  std::ostream& out=std::cout
75  ) const override;
76 
77  std::string printLaTeX(int mode=0) const override;
78 
79  long double evaluateScalar() const override;
80 
81  long double getValue() const override;
82 
83  long double getDeltaPlus() const override;
84 
85  long double getDeltaMinus() const override;
86 
87  std::optional<Expr> evaluate(
88  csl::eval::mode user_mode = csl::eval::base
89  ) const override;
90 
91  unique_Expr copy_unique() const override;
92 
93  Expr multiplication_own(const Expr& expr, bool side=1) const override;
94 
95  Expr addition_own(const Expr& expr) const override;
96 
97  Expr division_own(const Expr& expr) const override;
98 
99  Expr exponentiation_own(const Expr& expr) const override;
100 
101  std::optional<Expr> derive(Expr_info expr) const override;
102 
103  bool operator==(Expr_info expr) const override;
104 
105  bool operator<(const Abstract* expr) const override;
106 };
107 
108 Expr numericaleval_s(long double value,
109  long double delta_plus);
110 
111 Expr numericaleval_s(long double value,
112  long double delta_plus,
113  long double delta_minus);
114 
115 } // End of namespace csl
116 
117 #endif
bool operator==(Expr_info expr) const override
Compares the Abstract with another.
Definition: numericalEval.cpp:252
Expr multiplication_own(const Expr &expr, bool side=1) const override
Contains implementation of special multiplication for Numerical- and Vectorial-types.
Definition: numericalEval.cpp:172
Namespace for csl library.
Definition: abreviation.h:34
Definition: numericalEval.h:30
void print(int mode=0, std::ostream &out=std::cout, bool lib=false) const override
Displays the abstract in standard output.
Definition: numericalEval.cpp:59
std::optional< Expr > derive(Expr_info expr) const override
Calculates the derivative of the Abstract wrt another.
Definition: numericalEval.cpp:247
Type
Enum of the different types of Abstract (i.e. list of all possible specializations).
Definition: enum.h:47
Expr exponentiation_own(const Expr &expr) const override
Contains implementation of special exponentiation for Numerical- and Vectorial-types.
Definition: numericalEval.cpp:218
std::string printLaTeX(int mode=0) const override
Creates a LaTeX output for the Abstract.
Definition: numericalEval.cpp:97
Expr addition_own(const Expr &expr) const override
Contains implementation of special addition for Numerical- and Vectorial-types.
Definition: numericalEval.cpp:153
Expr division_own(const Expr &expr) const override
Contains implementation of special division for Numerical- and Polynomial-types. For polynomial...
Definition: numericalEval.cpp:192
Root class of the inheritance tree of abstracts.
Definition: abstract.h:76
long double evaluateScalar() const override
Evaluates the value of the Abstract.
Definition: numericalEval.cpp:122
Abstract class from which derive numerical types, i.e. Float, Integer, IntFraction.
Definition: numerical.h:34
long double getValue() const override
Returns the value of the expression, if it has one explicitely. In particular, it will work only on N...
Definition: numericalEval.cpp:127
std::optional< Expr > evaluate(csl::eval::mode user_mode=csl::eval::base) const override
Evaluates the Abstract.
Definition: numericalEval.cpp:142
Expression type/.
Definition: abstract.h:1573
csl::Type getType() const override
Gives the type of Abstract.
Definition: numericalEval.cpp:54