codac 1.5.6
Loading...
Searching...
No Matches
codac2_analytic_constants.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include "codac2_Index.h"
13#include "codac2_ValueType.h"
14
15namespace codac2
16{
17 template<typename T>
18 class ConstValueExpr : public AnalyticExpr<T>
19 {
20 public:
21
22 ConstValueExpr(const typename T::Domain& x)
23 : _x(x)
24 { }
25
26 std::shared_ptr<ExprBase> copy() const
27 {
28 return std::make_shared<ConstValueExpr<T>>(*this);
29 }
30
31 T fwd_eval(ValuesMap& v, Index total_input_size, bool natural_eval) const
32 {
33 if(natural_eval)
34 return AnalyticExpr<T>::init_value(v, T(
35 // the mid is not considered for const values in centered form expression:
36 _x,
37 // the definition domain is necesarily met at this point:
38 true
39 ));
40
41 else
42 return AnalyticExpr<T>::init_value(v, T(
43 // the mid is not considered for const values in centered form expression:
44 _x,
45 _x,
46 // the derivative of a const value is zero:
47 IntervalMatrix::zero(_x.size(),total_input_size),
48 // the definition domain is necesarily met at this point:
49 true
50 ));
51 }
52
53 void bwd_eval(ValuesMap& v) const
54 {
55 AnalyticExpr<T>::value(v).a &= _x;
56 }
57
58 void replace_expr([[maybe_unused]] const ExprID& old_expr_id, [[maybe_unused]] const std::shared_ptr<ExprBase>& new_expr)
59 { }
60
61 virtual bool belongs_to_args_list([[maybe_unused]] const FunctionArgsList& args) const
62 {
63 return true;
64 }
65
66 protected:
67
68 const typename T::Domain _x;
69 };
70
71 template<typename T>
72 inline AnalyticExprWrapper<typename ValueType<T>::Type> const_value(const T& x)
73 {
74 return { std::make_shared<ConstValueExpr<typename ValueType<T>::Type>>(x) };
75 }
76}