21 template<
typename X1,
typename X2>
22 static std::string str(
const X1& x1,
const X2& x2)
24 return "atan2(" + x1->str() +
"," + x2->str() +
")";
27 template<
typename X1,
typename X2>
28 static std::pair<Index,Index> output_shape([[maybe_unused]]
const X1& s1, [[maybe_unused]]
const X2& s2)
33 static Interval fwd(
const Interval& x1,
const Interval& x2);
34 static ScalarType fwd_natural(
const ScalarType& x1,
const ScalarType& x2);
35 static ScalarType fwd_centered(
const ScalarType& x1,
const ScalarType& x2);
36 static void bwd(
const Interval& y, Interval& x1, Interval& x2);
43 atan2(
const ScalarExpr& x1,
const ScalarExpr& x2)
45 return { std::make_shared<AnalyticOperationExpr<Atan2Op,ScalarType,ScalarType,ScalarType>>(x1,x2) };
55 inline ScalarType Atan2Op::fwd_natural(
const ScalarType& x1,
const ScalarType& x2)
59 x1.def_domain && x2.def_domain
60 && !(x1.a.contains(0.) && x2.a.contains(0.))
64 inline ScalarType Atan2Op::fwd_centered(
const ScalarType& x1,
const ScalarType& x2)
66 if(centered_form_not_available_for_args(x1,x2))
67 return fwd_natural(x1,x2);
69 assert(x1.da.rows() == 1);
70 assert(x1.da.rows() == x2.da.rows() && x1.da.cols() == x2.da.cols());
73 for(Index i = 0 ; i < d.size() ; i++)
74 d(0,i) = (-x1.a*x2.da(0,i)/(
sqr(x2.a)+
sqr(x1.a)))+(x2.a*x1.da(0,i)/(
sqr(x2.a)+
sqr(x1.a)));
80 x1.def_domain && x2.def_domain
81 && !(x1.a.contains(0.) && x2.a.contains(0.))
103 if(!y_x2pos.is_empty())
105 Interval xpos = x2 & Interval(0,oo);
108 if(y_x2neg_x1pos.is_empty() || y_x2neg_x1neg.is_empty())
110 Interval z = yall/xpos;
111 AtanOp::bwd(y_x2pos,z);
112 DivOp::bwd(z,yall,xpos);
122 yres |= (x1 & Interval(0,oo));
127 yres |= (x1 & Interval(-oo,0));
131 if(!y_x2neg_x1pos.is_empty())
133 Interval xneg = x2 & Interval(-oo,0);
134 Interval ypos = x1 & Interval(0,oo);
135 Interval z = ypos/xneg;
137 DivOp::bwd(z,ypos,xneg);
142 if(!y_x2neg_x1neg.is_empty())
144 Interval xneg = x2 & Interval(-oo,0);
145 Interval yneg = x1 & Interval(-oo,0);
146 Interval z = yneg/xneg;
148 DivOp::bwd(z,yneg,xneg);
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:50
static Interval pi()
Provides an interval for .
Definition codac2_Interval_impl.h:604
static Interval zero()
Provides an interval for .
Definition codac2_Interval_impl.h:589
double lb() const
Returns the lower bound of this.
Definition codac2_Interval_impl.h:126
static Interval empty()
Provides an empty interval.
Definition codac2_Interval_impl.h:584
static Interval half_pi()
Provides an interval for .
Definition codac2_Interval_impl.h:599
Definition codac2_OctaSym.h:21
Interval atan2(const Interval &y, const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:140
Interval sqr(const Interval &x)
Returns .
Definition codac2_Interval_operations_impl.h:21
Eigen::Matrix< Interval,-1,-1 > IntervalMatrix
Alias for a dynamic-size matrix of intervals.
Definition codac2_IntervalMatrix.h:25