150#include "hwy/highway.h"
164template <
class D,
class V>
165HWY_INLINE V
Atan(
const D d, V y, V x);
166template <
class D,
class V>
167HWY_NOINLINE V
CallAtan2(
const D d, VecArg<V> y, VecArg<V> x) {
168 return Atan2(d, y, x);
171template <
class D,
class V>
172HWY_INLINE V
Atan2(
const D d, V y, V x) {
174 typedef Mask < D > M ;
213 const M xZero = Eq ( x , Set ( d , 0.0 ) ) ;
214 const M yZero = Eq ( y , Set ( d , 0.0 ) ) ;
215 const M xNeg = Lt ( x , Set ( d , 0.0 ) ) ;
216 const M xMinusZero = And ( xZero , xNeg ) ;
217 const M yNeg = Lt ( y , Set ( d , 0.0 ) ) ;
218 const M xInf = IsInf ( x ) ;
219 const M yInf = IsInf ( y ) ;
222 V cpsy = CopySign ( Set ( d , M_PI ) , y ) ;
223 V a = IfThenElseZero ( xNeg , cpsy ) ;
224 V cpsx = CopySign ( Set ( d , 1.0 ) , x ) ;
227 V _x = IfThenElse ( yInf , cpsx , x ) ;
228 a = Add ( a ,
Atan ( d , Div ( y , _x ) ) ) ;
230 a = IfThenZeroElse ( And ( xZero , yZero ) , a ) ;
232 a = IfThenElse ( xMinusZero , Add ( a , cpsy ) , a ) ;
234 a = IfThenElse ( And ( xZero , yNeg ) , Set ( d , - M_PI_2 ) , a ) ;
235 V cpsp4 = CopySign ( Set ( d , M_PI_4 ) , Xor ( x , Not ( y ) ) ) ;
237 a = IfThenElse ( And ( xInf , yInf ) , Add ( a , cpsp4 ) , a ) ;
238 M azero = Eq ( a , Set ( d , 0.0 ) ) ;
240 a = IfThenElse ( azero , CopySign ( a , y ) , a ) ;
242 a = IfThenElse ( Or ( IsNaN ( y ) , IsNaN ( x ) ) , NaN ( d ) , a ) ;
HWY_NOINLINE V CallAtan2(const D d, VecArg< V > y, VecArg< V > x)
HWY_INLINE V Atan2(const D d, V y, V x)
HWY_INLINE V Atan(const D d, V y, V x)