codac 1.5.6
Loading...
Searching...
No Matches
codac2_acos.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include "codac2_Interval.h"
13#include "codac2_AnalyticType.h"
15
16namespace codac2
17{
18 struct AcosOp
19 {
20 static Interval fwd(const Interval& x1);
21 static ScalarType fwd_natural(const ScalarType& x1);
22 static ScalarType fwd_centered(const ScalarType& x1);
23 static void bwd(const Interval& y, Interval& x1);
24 };
25
26 // Analytic operator
27 // The following function can be used to build analytic expressions.
28
29 inline ScalarExpr
30 acos(const ScalarExpr& x1)
31 {
32 return { std::make_shared<AnalyticOperationExpr<AcosOp,ScalarType,ScalarType>>(x1) };
33 }
34
35 // Inline functions
36
37 inline Interval AcosOp::fwd(const Interval& x1)
38 {
39 return acos(x1);
40 }
41
42 inline ScalarType AcosOp::fwd_natural(const ScalarType& x1)
43 {
44 return {
45 fwd(x1.a),
46 x1.a.is_subset({-1,1}) // def domain of acos
47 && x1.a != 1. // def domain of the derivative of acos
48 && x1.def_domain
49 };
50 }
51
52 inline ScalarType AcosOp::fwd_centered(const ScalarType& x1)
53 {
54 if(centered_form_not_available_for_args(x1))
55 return fwd_natural(x1);
56
57 IntervalMatrix d(1,x1.da.size());
58 for(Index i = 0 ; i < d.size() ; i++)
59 d(0,i) = -x1.da(0,i)/sqrt(1.-sqr(x1.a));
60
61 return {
62 fwd(x1.m),
63 fwd(x1.a),
64 d,
65 x1.a.is_subset({-1,1}) // def domain of acos
66 && x1.a != 1. // def domain of the derivative of acos
67 && x1.def_domain
68 };
69 }
70
71 inline void AcosOp::bwd(const Interval& y, Interval& x1)
72 {
73 x1 &= cos(y);
74 }
75}
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:62
Interval sqrt(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:26
Interval acos(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:119
Interval cos(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:98
Interval sqr(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:21