MathFunctions.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
5 // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_MATHFUNCTIONS_H
12 #define EIGEN_MATHFUNCTIONS_H
13 
14 // TODO this should better be moved to NumTraits
15 // Source: WolframAlpha
16 #define EIGEN_PI 3.141592653589793238462643383279502884197169399375105820974944592307816406L
17 #define EIGEN_LOG2E 1.442695040888963407359924681001892137426645954152985934135449406931109219L
18 #define EIGEN_LN2 0.693147180559945309417232121458176568075500134360255254120680009493393621L
19 
20 // IWYU pragma: private
21 #include "./InternalHeaderCheck.h"
22 
23 namespace Eigen {
24 
25 namespace internal {
26 
48 template <typename T, typename dummy = void>
50  typedef T type;
51 };
52 
53 template <typename T>
54 struct always_void {
55  typedef void type;
56 };
57 
58 template <typename T>
60  T, typename always_void<typename T::Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl>::type> {
61  typedef typename T::Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl type;
62 };
63 
64 #define EIGEN_MATHFUNC_IMPL(func, scalar) \
65  Eigen::internal::func##_impl<typename Eigen::internal::global_math_functions_filtering_base<scalar>::type>
66 #define EIGEN_MATHFUNC_RETVAL(func, scalar) \
67  typename Eigen::internal::func##_retval< \
68  typename Eigen::internal::global_math_functions_filtering_base<scalar>::type>::type
69 
70 /****************************************************************************
71  * Implementation of real *
72  ****************************************************************************/
73 
77  EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) { return x; }
78 };
79 
80 template <typename Scalar>
81 struct real_default_impl<Scalar, true> {
83  EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
84  using std::real;
85  return real(x);
86  }
87 };
88 
89 template <typename Scalar>
90 struct real_impl : real_default_impl<Scalar> {};
91 
92 #if defined(EIGEN_GPU_COMPILE_PHASE)
93 template <typename T>
94 struct real_impl<std::complex<T>> {
95  typedef T RealScalar;
96  EIGEN_DEVICE_FUNC static inline T run(const std::complex<T>& x) { return x.real(); }
97 };
98 #endif
99 
100 template <typename Scalar>
101 struct real_retval {
102  typedef typename NumTraits<Scalar>::Real type;
103 };
104 
105 /****************************************************************************
106  * Implementation of imag *
107  ****************************************************************************/
108 
112  EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar&) { return RealScalar(0); }
113 };
114 
115 template <typename Scalar>
116 struct imag_default_impl<Scalar, true> {
118  EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
119  using std::imag;
120  return imag(x);
121  }
122 };
123 
124 template <typename Scalar>
125 struct imag_impl : imag_default_impl<Scalar> {};
126 
127 #if defined(EIGEN_GPU_COMPILE_PHASE)
128 template <typename T>
129 struct imag_impl<std::complex<T>> {
130  typedef T RealScalar;
131  EIGEN_DEVICE_FUNC static inline T run(const std::complex<T>& x) { return x.imag(); }
132 };
133 #endif
134 
135 template <typename Scalar>
136 struct imag_retval {
137  typedef typename NumTraits<Scalar>::Real type;
138 };
139 
140 /****************************************************************************
141  * Implementation of real_ref *
142  ****************************************************************************/
143 
144 template <typename Scalar>
147  EIGEN_DEVICE_FUNC static inline RealScalar& run(Scalar& x) { return reinterpret_cast<RealScalar*>(&x)[0]; }
148  EIGEN_DEVICE_FUNC static inline const RealScalar& run(const Scalar& x) {
149  return reinterpret_cast<const RealScalar*>(&x)[0];
150  }
151 };
152 
153 template <typename Scalar>
155  typedef typename NumTraits<Scalar>::Real& type;
156 };
157 
158 /****************************************************************************
159  * Implementation of imag_ref *
160  ****************************************************************************/
161 
162 template <typename Scalar, bool IsComplex>
165  EIGEN_DEVICE_FUNC static inline RealScalar& run(Scalar& x) { return reinterpret_cast<RealScalar*>(&x)[1]; }
166  EIGEN_DEVICE_FUNC static inline const RealScalar& run(const Scalar& x) {
167  return reinterpret_cast<const RealScalar*>(&x)[1];
168  }
169 };
170 
171 template <typename Scalar>
173  EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR static inline Scalar run(Scalar&) { return Scalar(0); }
174  EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR static inline const Scalar run(const Scalar&) { return Scalar(0); }
175 };
176 
177 template <typename Scalar>
178 struct imag_ref_impl : imag_ref_default_impl<Scalar, NumTraits<Scalar>::IsComplex> {};
179 
180 template <typename Scalar>
182  typedef typename NumTraits<Scalar>::Real& type;
183 };
184 
185 /****************************************************************************
186  * Implementation of conj *
187  ****************************************************************************/
188 
191  EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) { return x; }
192 };
193 
194 template <typename Scalar>
195 struct conj_default_impl<Scalar, true> {
196  EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) {
197  using std::conj;
198  return conj(x);
199  }
200 };
201 
203 struct conj_impl : conj_default_impl<Scalar, IsComplex> {};
204 
205 template <typename Scalar>
206 struct conj_retval {
207  typedef Scalar type;
208 };
209 
210 /****************************************************************************
211  * Implementation of abs2 *
212  ****************************************************************************/
213 
214 template <typename Scalar, bool IsComplex>
217  EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) { return x * x; }
218 };
219 
220 template <typename Scalar>
221 struct abs2_impl_default<Scalar, true> // IsComplex
222 {
224  EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) { return x.real() * x.real() + x.imag() * x.imag(); }
225 };
226 
227 template <typename Scalar>
228 struct abs2_impl {
230  EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
232  }
233 };
234 
235 template <typename Scalar>
236 struct abs2_retval {
237  typedef typename NumTraits<Scalar>::Real type;
238 };
239 
240 /****************************************************************************
241  * Implementation of sqrt/rsqrt *
242  ****************************************************************************/
243 
244 template <typename Scalar>
245 struct sqrt_impl {
248  return sqrt(x);
249  }
250 };
251 
252 // Complex sqrt defined in MathFunctionsImpl.h.
253 template <typename T>
254 EIGEN_DEVICE_FUNC std::complex<T> complex_sqrt(const std::complex<T>& a_x);
255 
256 // Custom implementation is faster than `std::sqrt`, works on
257 // GPU, and correctly handles special cases (unlike MSVC).
258 template <typename T>
259 struct sqrt_impl<std::complex<T>> {
260  EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE std::complex<T> run(const std::complex<T>& x) {
261  return complex_sqrt<T>(x);
262  }
263 };
264 
265 template <typename Scalar>
266 struct sqrt_retval {
267  typedef Scalar type;
268 };
269 
270 // Default implementation relies on numext::sqrt, at bottom of file.
271 template <typename T>
272 struct rsqrt_impl;
273 
274 // Complex rsqrt defined in MathFunctionsImpl.h.
275 template <typename T>
276 EIGEN_DEVICE_FUNC std::complex<T> complex_rsqrt(const std::complex<T>& a_x);
277 
278 template <typename T>
279 struct rsqrt_impl<std::complex<T>> {
280  EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE std::complex<T> run(const std::complex<T>& x) {
281  return complex_rsqrt<T>(x);
282  }
283 };
284 
285 template <typename Scalar>
286 struct rsqrt_retval {
287  typedef Scalar type;
288 };
289 
290 /****************************************************************************
291  * Implementation of norm1 *
292  ****************************************************************************/
293 
294 template <typename Scalar, bool IsComplex>
296 
297 template <typename Scalar>
298 struct norm1_default_impl<Scalar, true> {
300  EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
302  return abs(x.real()) + abs(x.imag());
303  }
304 };
305 
306 template <typename Scalar>
307 struct norm1_default_impl<Scalar, false> {
308  EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) {
310  return abs(x);
311  }
312 };
313 
314 template <typename Scalar>
315 struct norm1_impl : norm1_default_impl<Scalar, NumTraits<Scalar>::IsComplex> {};
316 
317 template <typename Scalar>
318 struct norm1_retval {
319  typedef typename NumTraits<Scalar>::Real type;
320 };
321 
322 /****************************************************************************
323  * Implementation of hypot *
324  ****************************************************************************/
325 
326 template <typename Scalar>
327 struct hypot_impl;
328 
329 template <typename Scalar>
330 struct hypot_retval {
331  typedef typename NumTraits<Scalar>::Real type;
332 };
333 
334 /****************************************************************************
335  * Implementation of cast *
336  ****************************************************************************/
337 
338 template <typename OldType, typename NewType, typename EnableIf = void>
339 struct cast_impl {
340  EIGEN_DEVICE_FUNC static inline NewType run(const OldType& x) { return static_cast<NewType>(x); }
341 };
342 
343 template <typename OldType>
344 struct cast_impl<OldType, bool> {
345  EIGEN_DEVICE_FUNC static inline bool run(const OldType& x) { return x != OldType(0); }
346 };
347 
348 // Casting from S -> Complex<T> leads to an implicit conversion from S to T,
349 // generating warnings on clang. Here we explicitly cast the real component.
350 template <typename OldType, typename NewType>
351 struct cast_impl<OldType, NewType,
352  typename std::enable_if_t<!NumTraits<OldType>::IsComplex && NumTraits<NewType>::IsComplex>> {
353  EIGEN_DEVICE_FUNC static inline NewType run(const OldType& x) {
354  typedef typename NumTraits<NewType>::Real NewReal;
355  return static_cast<NewType>(static_cast<NewReal>(x));
356  }
357 };
358 
359 // here, for once, we're plainly returning NewType: we don't want cast to do weird things.
360 
361 template <typename OldType, typename NewType>
362 EIGEN_DEVICE_FUNC inline NewType cast(const OldType& x) {
364 }
365 
366 /****************************************************************************
367  * Implementation of arg *
368  ****************************************************************************/
369 
370 // Visual Studio 2017 has a bug where arg(float) returns 0 for negative inputs.
371 // This seems to be fixed in VS 2019.
372 #if (!EIGEN_COMP_MSVC || EIGEN_COMP_MSVC >= 1920)
373 // std::arg is only defined for types of std::complex, or integer types or float/double/long double
378 
379 template <typename Scalar>
380 struct arg_default_impl<Scalar, true> {
382  EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
383  // There is no official ::arg on device in CUDA/HIP, so we always need to use std::arg.
384  using std::arg;
385  return static_cast<RealScalar>(arg(x));
386  }
387 };
388 
389 // Must be non-complex floating-point type (e.g. half/bfloat16).
390 template <typename Scalar>
391 struct arg_default_impl<Scalar, false> {
393  EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
394  return (x < Scalar(0)) ? RealScalar(EIGEN_PI) : RealScalar(0);
395  }
396 };
397 #else
399 struct arg_default_impl {
400  typedef typename NumTraits<Scalar>::Real RealScalar;
401  EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
402  return (x < RealScalar(0)) ? RealScalar(EIGEN_PI) : RealScalar(0);
403  }
404 };
405 
406 template <typename Scalar>
407 struct arg_default_impl<Scalar, true> {
408  typedef typename NumTraits<Scalar>::Real RealScalar;
409  EIGEN_DEVICE_FUNC static inline RealScalar run(const Scalar& x) {
410  EIGEN_USING_STD(arg);
411  return arg(x);
412  }
413 };
414 #endif
415 template <typename Scalar>
416 struct arg_impl : arg_default_impl<Scalar> {};
417 
418 template <typename Scalar>
419 struct arg_retval {
420  typedef typename NumTraits<Scalar>::Real type;
421 };
422 
423 /****************************************************************************
424  * Implementation of expm1 *
425  ****************************************************************************/
426 
427 // This implementation is based on GSL Math's expm1.
428 namespace std_fallback {
429 // fallback expm1 implementation in case there is no expm1(Scalar) function in namespace of Scalar,
430 // or that there is no suitable std::expm1 function available. Implementation
431 // attributed to Kahan. See: http://www.plunk.org/~hatch/rightway.php.
432 template <typename Scalar>
435  typedef typename NumTraits<Scalar>::Real RealScalar;
436 
438  Scalar u = exp(x);
439  if (numext::equal_strict(u, Scalar(1))) {
440  return x;
441  }
442  Scalar um1 = u - RealScalar(1);
443  if (numext::equal_strict(um1, Scalar(-1))) {
444  return RealScalar(-1);
445  }
446 
448  Scalar logu = log(u);
449  return numext::equal_strict(u, logu) ? u : (u - RealScalar(1)) * x / logu;
450 }
451 } // namespace std_fallback
452 
453 template <typename Scalar>
454 struct expm1_impl {
455  EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) {
458  return expm1(x);
459  }
460 };
461 
462 template <typename Scalar>
463 struct expm1_retval {
464  typedef Scalar type;
465 };
466 
467 /****************************************************************************
468  * Implementation of log *
469  ****************************************************************************/
470 
471 // Complex log defined in MathFunctionsImpl.h.
472 template <typename T>
473 EIGEN_DEVICE_FUNC std::complex<T> complex_log(const std::complex<T>& z);
474 
475 template <typename Scalar>
476 struct log_impl {
477  EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) {
479  return static_cast<Scalar>(log(x));
480  }
481 };
482 
483 template <typename Scalar>
484 struct log_impl<std::complex<Scalar>> {
485  EIGEN_DEVICE_FUNC static inline std::complex<Scalar> run(const std::complex<Scalar>& z) { return complex_log(z); }
486 };
487 
488 /****************************************************************************
489  * Implementation of log1p *
490  ****************************************************************************/
491 
492 namespace std_fallback {
493 // fallback log1p implementation in case there is no log1p(Scalar) function in namespace of Scalar,
494 // or that there is no suitable std::log1p function available
495 template <typename Scalar>
498  typedef typename NumTraits<Scalar>::Real RealScalar;
500  Scalar x1p = RealScalar(1) + x;
501  Scalar log_1p = log_impl<Scalar>::run(x1p);
502  const bool is_small = numext::equal_strict(x1p, Scalar(1));
503  const bool is_inf = numext::equal_strict(x1p, log_1p);
504  return (is_small || is_inf) ? x : x * (log_1p / (x1p - RealScalar(1)));
505 }
506 } // namespace std_fallback
507 
508 template <typename Scalar>
509 struct log1p_impl {
511 
512  EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& x) {
514  return log1p(x);
515  }
516 };
517 
518 // Specialization for complex types that are not supported by std::log1p.
519 template <typename RealScalar>
520 struct log1p_impl<std::complex<RealScalar>> {
522 
523  EIGEN_DEVICE_FUNC static inline std::complex<RealScalar> run(const std::complex<RealScalar>& x) {
524  return std_fallback::log1p(x);
525  }
526 };
527 
528 template <typename Scalar>
529 struct log1p_retval {
530  typedef Scalar type;
531 };
532 
533 /****************************************************************************
534  * Implementation of pow *
535  ****************************************************************************/
536 
537 template <typename ScalarX, typename ScalarY,
539 struct pow_impl {
540  // typedef Scalar retval;
543  static EIGEN_DEVICE_FUNC inline result_type run(const ScalarX& x, const ScalarY& y) {
545  return pow(x, y);
546  }
547 };
548 
549 template <typename ScalarX, typename ScalarY>
550 struct pow_impl<ScalarX, ScalarY, true> {
551  typedef ScalarX result_type;
552  static EIGEN_DEVICE_FUNC inline ScalarX run(ScalarX x, ScalarY y) {
553  ScalarX res(1);
555  if (y & 1) res *= x;
556  y >>= 1;
557  while (y) {
558  x *= x;
559  if (y & 1) res *= x;
560  y >>= 1;
561  }
562  return res;
563  }
564 };
565 
567 
568 template <unsigned int n, int lower, int upper>
570  enum {
571  middle = (lower + upper) / 2,
572  value = (upper <= lower + 1) ? int(meta_floor_log2_terminate)
573  : (n < (1 << middle)) ? int(meta_floor_log2_move_down)
574  : (n == 0) ? int(meta_floor_log2_bogus)
576  };
577 };
578 
579 template <unsigned int n, int lower = 0, int upper = sizeof(unsigned int) * CHAR_BIT - 1,
581 struct meta_floor_log2 {};
582 
583 template <unsigned int n, int lower, int upper>
586 };
587 
588 template <unsigned int n, int lower, int upper>
591 };
592 
593 template <unsigned int n, int lower, int upper>
595  enum { value = (n >= ((unsigned int)(1) << (lower + 1))) ? lower + 1 : lower };
596 };
597 
598 template <unsigned int n, int lower, int upper>
600  // no value, error at compile time
601 };
602 
603 template <typename BitsType, typename EnableIf = void>
606  "BitsType must be an unsigned integer");
607  static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
608  int n = CHAR_BIT * sizeof(BitsType);
609  int shift = n / 2;
610  while (bits > 0 && shift > 0) {
611  BitsType y = bits >> shift;
612  if (y > 0) {
613  n -= shift;
614  bits = y;
615  }
616  shift /= 2;
617  }
618  if (shift == 0) {
619  --n;
620  }
621  return n;
622  }
623 
624  static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
625  int n = CHAR_BIT * sizeof(BitsType);
626  int shift = n / 2;
627  while (bits > 0 && shift > 0) {
628  BitsType y = bits << shift;
629  if (y > 0) {
630  n -= shift;
631  bits = y;
632  }
633  shift /= 2;
634  }
635  if (shift == 0) {
636  --n;
637  }
638  return n;
639  }
640 };
641 
642 // Count leading zeros.
643 template <typename BitsType>
644 EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
646 }
647 
648 // Count trailing zeros.
649 template <typename BitsType>
650 EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
652 }
653 
654 #if EIGEN_COMP_GNUC || EIGEN_COMP_CLANG
655 
656 template <typename BitsType>
657 struct count_bits_impl<
658  BitsType, std::enable_if_t<std::is_integral<BitsType>::value && sizeof(BitsType) <= sizeof(unsigned int)>> {
659  static constexpr int kNumBits = static_cast<int>(sizeof(BitsType) * CHAR_BIT);
660  static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
661  static constexpr int kLeadingBitsOffset = (sizeof(unsigned int) - sizeof(BitsType)) * CHAR_BIT;
662  return bits == 0 ? kNumBits : __builtin_clz(static_cast<unsigned int>(bits)) - kLeadingBitsOffset;
663  }
664 
665  static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
666  return bits == 0 ? kNumBits : __builtin_ctz(static_cast<unsigned int>(bits));
667  }
668 };
669 
670 template <typename BitsType>
671 struct count_bits_impl<BitsType,
672  std::enable_if_t<std::is_integral<BitsType>::value && sizeof(unsigned int) < sizeof(BitsType) &&
673  sizeof(BitsType) <= sizeof(unsigned long)>> {
674  static constexpr int kNumBits = static_cast<int>(sizeof(BitsType) * CHAR_BIT);
675  static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
676  static constexpr int kLeadingBitsOffset = (sizeof(unsigned long) - sizeof(BitsType)) * CHAR_BIT;
677  return bits == 0 ? kNumBits : __builtin_clzl(static_cast<unsigned long>(bits)) - kLeadingBitsOffset;
678  }
679 
680  static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
681  return bits == 0 ? kNumBits : __builtin_ctzl(static_cast<unsigned long>(bits));
682  }
683 };
684 
685 template <typename BitsType>
686 struct count_bits_impl<BitsType,
687  std::enable_if_t<std::is_integral<BitsType>::value && sizeof(unsigned long) < sizeof(BitsType) &&
688  sizeof(BitsType) <= sizeof(unsigned long long)>> {
689  static constexpr int kNumBits = static_cast<int>(sizeof(BitsType) * CHAR_BIT);
690  static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
691  static constexpr int kLeadingBitsOffset = (sizeof(unsigned long long) - sizeof(BitsType)) * CHAR_BIT;
692  return bits == 0 ? kNumBits : __builtin_clzll(static_cast<unsigned long long>(bits)) - kLeadingBitsOffset;
693  }
694 
695  static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
696  return bits == 0 ? kNumBits : __builtin_ctzll(static_cast<unsigned long long>(bits));
697  }
698 };
699 
700 #elif EIGEN_COMP_MSVC
701 
702 template <typename BitsType>
703 struct count_bits_impl<
704  BitsType, std::enable_if_t<std::is_integral<BitsType>::value && sizeof(BitsType) <= sizeof(unsigned long)>> {
705  static constexpr int kNumBits = static_cast<int>(sizeof(BitsType) * CHAR_BIT);
706  static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
707  unsigned long out;
708  _BitScanReverse(&out, static_cast<unsigned long>(bits));
709  return bits == 0 ? kNumBits : (kNumBits - 1) - static_cast<int>(out);
710  }
711 
712  static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
713  unsigned long out;
714  _BitScanForward(&out, static_cast<unsigned long>(bits));
715  return bits == 0 ? kNumBits : static_cast<int>(out);
716  }
717 };
718 
719 #ifdef _WIN64
720 
721 template <typename BitsType>
722 struct count_bits_impl<BitsType,
723  std::enable_if_t<std::is_integral<BitsType>::value && sizeof(unsigned long) < sizeof(BitsType) &&
724  sizeof(BitsType) <= sizeof(__int64)>> {
725  static constexpr int kNumBits = static_cast<int>(sizeof(BitsType) * CHAR_BIT);
726  static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
727  unsigned long out;
728  _BitScanReverse64(&out, static_cast<unsigned __int64>(bits));
729  return bits == 0 ? kNumBits : (kNumBits - 1) - static_cast<int>(out);
730  }
731 
732  static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
733  unsigned long out;
734  _BitScanForward64(&out, static_cast<unsigned __int64>(bits));
735  return bits == 0 ? kNumBits : static_cast<int>(out);
736  }
737 };
738 
739 #endif // _WIN64
740 
741 #endif // EIGEN_COMP_GNUC || EIGEN_COMP_CLANG
742 
743 template <typename BitsType>
744 struct log_2_impl {
745  static constexpr int kTotalBits = sizeof(BitsType) * CHAR_BIT;
746  static EIGEN_DEVICE_FUNC inline int run_ceil(const BitsType& x) {
747  const int n = kTotalBits - clz(x);
748  bool power_of_two = (x & (x - 1)) == 0;
749  return x == 0 ? 0 : power_of_two ? (n - 1) : n;
750  }
751  static EIGEN_DEVICE_FUNC inline int run_floor(const BitsType& x) {
752  const int n = kTotalBits - clz(x);
753  return x == 0 ? 0 : n - 1;
754  }
755 };
756 
757 template <typename BitsType>
758 int log2_ceil(const BitsType& x) {
759  return log_2_impl<BitsType>::run_ceil(x);
760 }
761 
762 template <typename BitsType>
763 int log2_floor(const BitsType& x) {
764  return log_2_impl<BitsType>::run_floor(x);
765 }
766 
767 // Implementation of is* functions
768 
769 template <typename T>
770 EIGEN_DEVICE_FUNC std::enable_if_t<!(std::numeric_limits<T>::has_infinity || std::numeric_limits<T>::has_quiet_NaN ||
771  std::numeric_limits<T>::has_signaling_NaN),
772  bool>
773 isfinite_impl(const T&) {
774  return true;
775 }
776 
777 template <typename T>
778 EIGEN_DEVICE_FUNC std::enable_if_t<(std::numeric_limits<T>::has_infinity || std::numeric_limits<T>::has_quiet_NaN ||
779  std::numeric_limits<T>::has_signaling_NaN) &&
780  (!NumTraits<T>::IsComplex),
781  bool>
782 isfinite_impl(const T& x) {
783  EIGEN_USING_STD(isfinite);
784  return isfinite EIGEN_NOT_A_MACRO(x);
785 }
786 
787 template <typename T>
788 EIGEN_DEVICE_FUNC std::enable_if_t<!std::numeric_limits<T>::has_infinity, bool> isinf_impl(const T&) {
789  return false;
790 }
791 
792 template <typename T>
793 EIGEN_DEVICE_FUNC std::enable_if_t<(std::numeric_limits<T>::has_infinity && !NumTraits<T>::IsComplex), bool> isinf_impl(
794  const T& x) {
795  EIGEN_USING_STD(isinf);
796  return isinf EIGEN_NOT_A_MACRO(x);
797 }
798 
799 template <typename T>
800 EIGEN_DEVICE_FUNC
801  std::enable_if_t<!(std::numeric_limits<T>::has_quiet_NaN || std::numeric_limits<T>::has_signaling_NaN), bool>
802  isnan_impl(const T&) {
803  return false;
804 }
805 
806 template <typename T>
807 EIGEN_DEVICE_FUNC std::enable_if_t<
808  (std::numeric_limits<T>::has_quiet_NaN || std::numeric_limits<T>::has_signaling_NaN) && (!NumTraits<T>::IsComplex),
809  bool>
810 isnan_impl(const T& x) {
811  EIGEN_USING_STD(isnan);
812  return isnan EIGEN_NOT_A_MACRO(x);
813 }
814 
815 // The following overload are defined at the end of this file
816 template <typename T>
817 EIGEN_DEVICE_FUNC bool isfinite_impl(const std::complex<T>& x);
818 template <typename T>
819 EIGEN_DEVICE_FUNC bool isnan_impl(const std::complex<T>& x);
820 template <typename T>
821 EIGEN_DEVICE_FUNC bool isinf_impl(const std::complex<T>& x);
822 template <typename T>
823 EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS T ptanh_float(const T& a_x);
824 
825 /****************************************************************************
826  * Implementation of sign *
827  ****************************************************************************/
828 template <typename Scalar, bool IsComplex = (NumTraits<Scalar>::IsComplex != 0),
829  bool IsInteger = (NumTraits<Scalar>::IsInteger != 0)>
830 struct sign_impl {
831  EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& a) { return Scalar((a > Scalar(0)) - (a < Scalar(0))); }
832 };
833 
834 template <typename Scalar>
835 struct sign_impl<Scalar, false, false> {
836  EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& a) {
837  return (isnan_impl<Scalar>)(a) ? a : Scalar((a > Scalar(0)) - (a < Scalar(0)));
838  }
839 };
840 
841 template <typename Scalar, bool IsInteger>
842 struct sign_impl<Scalar, true, IsInteger> {
843  EIGEN_DEVICE_FUNC static inline Scalar run(const Scalar& a) {
844  using real_type = typename NumTraits<Scalar>::Real;
845  EIGEN_USING_STD(abs);
846  real_type aa = abs(a);
847  if (aa == real_type(0)) return Scalar(0);
848  aa = real_type(1) / aa;
849  return Scalar(a.real() * aa, a.imag() * aa);
850  }
851 };
852 
853 // The sign function for bool is the identity.
854 template <>
855 struct sign_impl<bool, false, true> {
856  EIGEN_DEVICE_FUNC static inline bool run(const bool& a) { return a; }
857 };
858 
859 template <typename Scalar>
860 struct sign_retval {
861  typedef Scalar type;
862 };
863 
864 // suppress "unary minus operator applied to unsigned type, result still unsigned" warnings on MSVC
865 // note: `0 - a` is distinct from `-a` when Scalar is a floating point type and `a` is zero
866 
867 template <typename Scalar, bool IsInteger = NumTraits<Scalar>::IsInteger>
868 struct negate_impl {
869  static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar run(const Scalar& a) { return -a; }
870 };
871 
872 template <typename Scalar>
873 struct negate_impl<Scalar, true> {
874  EIGEN_STATIC_ASSERT((!is_same<Scalar, bool>::value), NEGATE IS NOT DEFINED FOR BOOLEAN TYPES)
875  static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar run(const Scalar& a) { return Scalar(0) - a; }
876 };
877 
878 template <typename Scalar>
879 struct negate_retval {
880  typedef Scalar type;
881 };
882 
883 template <typename Scalar, bool IsInteger = NumTraits<typename unpacket_traits<Scalar>::type>::IsInteger>
884 struct nearest_integer_impl {
885  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_floor(const Scalar& x) {
886  EIGEN_USING_STD(floor) return floor(x);
887  }
888  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_ceil(const Scalar& x) {
889  EIGEN_USING_STD(ceil) return ceil(x);
890  }
891  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_rint(const Scalar& x) {
892  EIGEN_USING_STD(rint) return rint(x);
893  }
894  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_round(const Scalar& x) {
895  EIGEN_USING_STD(round) return round(x);
896  }
897  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_trunc(const Scalar& x) {
898  EIGEN_USING_STD(trunc) return trunc(x);
899  }
900 };
901 template <typename Scalar>
902 struct nearest_integer_impl<Scalar, true> {
903  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_floor(const Scalar& x) { return x; }
904  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_ceil(const Scalar& x) { return x; }
905  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_rint(const Scalar& x) { return x; }
906  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_round(const Scalar& x) { return x; }
907  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_trunc(const Scalar& x) { return x; }
908 };
909 
910 } // end namespace internal
911 
912 /****************************************************************************
913  * Generic math functions *
914  ****************************************************************************/
915 
916 namespace numext {
917 
918 #if (!defined(EIGEN_GPUCC) || defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC))
919 template <typename T>
920 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T& x, const T& y) {
921  EIGEN_USING_STD(min)
922  return min EIGEN_NOT_A_MACRO(x, y);
923 }
924 
925 template <typename T>
926 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T maxi(const T& x, const T& y) {
927  EIGEN_USING_STD(max)
928  return max EIGEN_NOT_A_MACRO(x, y);
929 }
930 #else
931 template <typename T>
932 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T& x, const T& y) {
933  return y < x ? y : x;
934 }
935 template <>
936 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float mini(const float& x, const float& y) {
937  return fminf(x, y);
938 }
939 template <>
940 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double mini(const double& x, const double& y) {
941  return fmin(x, y);
942 }
943 
944 #ifndef EIGEN_GPU_COMPILE_PHASE
945 template <>
946 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE long double mini(const long double& x, const long double& y) {
947 #if defined(EIGEN_HIPCC)
948  // no "fminl" on HIP yet
949  return (x < y) ? x : y;
950 #else
951  return fminl(x, y);
952 #endif
953 }
954 #endif
955 
956 template <typename T>
957 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T maxi(const T& x, const T& y) {
958  return x < y ? y : x;
959 }
960 template <>
961 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float maxi(const float& x, const float& y) {
962  return fmaxf(x, y);
963 }
964 template <>
965 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double maxi(const double& x, const double& y) {
966  return fmax(x, y);
967 }
968 #ifndef EIGEN_GPU_COMPILE_PHASE
969 template <>
970 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE long double maxi(const long double& x, const long double& y) {
971 #if defined(EIGEN_HIPCC)
972  // no "fmaxl" on HIP yet
973  return (x > y) ? x : y;
974 #else
975  return fmaxl(x, y);
976 #endif
977 }
978 #endif
979 #endif
980 
981 #if defined(SYCL_DEVICE_ONLY)
982 
983 #define SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_BINARY(NAME, FUNC) \
984  SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_char) \
985  SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_short) \
986  SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_int) \
987  SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_long)
988 #define SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_UNARY(NAME, FUNC) \
989  SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_char) \
990  SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_short) \
991  SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_int) \
992  SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_long)
993 #define SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_BINARY(NAME, FUNC) \
994  SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_uchar) \
995  SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_ushort) \
996  SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_uint) \
997  SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_ulong)
998 #define SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY(NAME, FUNC) \
999  SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_uchar) \
1000  SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_ushort) \
1001  SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_uint) \
1002  SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_ulong)
1003 #define SYCL_SPECIALIZE_INTEGER_TYPES_BINARY(NAME, FUNC) \
1004  SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_BINARY(NAME, FUNC) \
1005  SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_BINARY(NAME, FUNC)
1006 #define SYCL_SPECIALIZE_INTEGER_TYPES_UNARY(NAME, FUNC) \
1007  SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_UNARY(NAME, FUNC) \
1008  SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY(NAME, FUNC)
1009 #define SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(NAME, FUNC) \
1010  SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_float) \
1011  SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, cl::sycl::cl_double)
1012 #define SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(NAME, FUNC) \
1013  SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_float) \
1014  SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, cl::sycl::cl_double)
1015 #define SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(NAME, FUNC, RET_TYPE) \
1016  SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, RET_TYPE, cl::sycl::cl_float) \
1017  SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, RET_TYPE, cl::sycl::cl_double)
1018 
1019 #define SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE) \
1020  template <> \
1021  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE RET_TYPE NAME(const ARG_TYPE& x) { \
1022  return cl::sycl::FUNC(x); \
1023  }
1024 
1025 #define SYCL_SPECIALIZE_UNARY_FUNC(NAME, FUNC, TYPE) SYCL_SPECIALIZE_GEN_UNARY_FUNC(NAME, FUNC, TYPE, TYPE)
1026 
1027 #define SYCL_SPECIALIZE_GEN1_BINARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE1, ARG_TYPE2) \
1028  template <> \
1029  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE RET_TYPE NAME(const ARG_TYPE1& x, const ARG_TYPE2& y) { \
1030  return cl::sycl::FUNC(x, y); \
1031  }
1032 
1033 #define SYCL_SPECIALIZE_GEN2_BINARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE) \
1034  SYCL_SPECIALIZE_GEN1_BINARY_FUNC(NAME, FUNC, RET_TYPE, ARG_TYPE, ARG_TYPE)
1035 
1036 #define SYCL_SPECIALIZE_BINARY_FUNC(NAME, FUNC, TYPE) SYCL_SPECIALIZE_GEN2_BINARY_FUNC(NAME, FUNC, TYPE, TYPE)
1037 
1038 SYCL_SPECIALIZE_INTEGER_TYPES_BINARY(mini, min)
1039 SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(mini, fmin)
1040 SYCL_SPECIALIZE_INTEGER_TYPES_BINARY(maxi, max)
1041 SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(maxi, fmax)
1042 
1043 #endif
1044 
1045 template <typename Scalar>
1046 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(real, Scalar) real(const Scalar& x) {
1047  return EIGEN_MATHFUNC_IMPL(real, Scalar)::run(x);
1048 }
1049 
1050 template <typename Scalar>
1051 EIGEN_DEVICE_FUNC inline internal::add_const_on_value_type_t<EIGEN_MATHFUNC_RETVAL(real_ref, Scalar)> real_ref(
1052  const Scalar& x) {
1053  return internal::real_ref_impl<Scalar>::run(x);
1054 }
1055 
1056 template <typename Scalar>
1057 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) real_ref(Scalar& x) {
1058  return EIGEN_MATHFUNC_IMPL(real_ref, Scalar)::run(x);
1059 }
1060 
1061 template <typename Scalar>
1062 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(imag, Scalar) imag(const Scalar& x) {
1063  return EIGEN_MATHFUNC_IMPL(imag, Scalar)::run(x);
1064 }
1065 
1066 template <typename Scalar>
1067 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(arg, Scalar) arg(const Scalar& x) {
1068  return EIGEN_MATHFUNC_IMPL(arg, Scalar)::run(x);
1069 }
1070 
1071 template <typename Scalar>
1072 EIGEN_DEVICE_FUNC inline internal::add_const_on_value_type_t<EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar)> imag_ref(
1073  const Scalar& x) {
1074  return internal::imag_ref_impl<Scalar>::run(x);
1075 }
1076 
1077 template <typename Scalar>
1078 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) imag_ref(Scalar& x) {
1079  return EIGEN_MATHFUNC_IMPL(imag_ref, Scalar)::run(x);
1080 }
1081 
1082 template <typename Scalar>
1083 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(conj, Scalar) conj(const Scalar& x) {
1084  return EIGEN_MATHFUNC_IMPL(conj, Scalar)::run(x);
1085 }
1086 
1087 template <typename Scalar>
1088 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(sign, Scalar) sign(const Scalar& x) {
1089  return EIGEN_MATHFUNC_IMPL(sign, Scalar)::run(x);
1090 }
1091 
1092 template <typename Scalar>
1093 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(negate, Scalar) negate(const Scalar& x) {
1094  return EIGEN_MATHFUNC_IMPL(negate, Scalar)::run(x);
1095 }
1096 
1097 template <typename Scalar>
1098 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(abs2, Scalar) abs2(const Scalar& x) {
1099  return EIGEN_MATHFUNC_IMPL(abs2, Scalar)::run(x);
1100 }
1101 
1102 EIGEN_DEVICE_FUNC inline bool abs2(bool x) { return x; }
1103 
1104 template <typename T>
1105 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T absdiff(const T& x, const T& y) {
1106  return x > y ? x - y : y - x;
1107 }
1108 template <>
1109 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float absdiff(const float& x, const float& y) {
1110  return fabsf(x - y);
1111 }
1112 template <>
1113 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double absdiff(const double& x, const double& y) {
1114  return fabs(x - y);
1115 }
1116 
1117 // HIP and CUDA do not support long double.
1118 #ifndef EIGEN_GPU_COMPILE_PHASE
1119 template <>
1120 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE long double absdiff(const long double& x, const long double& y) {
1121  return fabsl(x - y);
1122 }
1123 #endif
1124 
1125 template <typename Scalar>
1126 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(norm1, Scalar) norm1(const Scalar& x) {
1127  return EIGEN_MATHFUNC_IMPL(norm1, Scalar)::run(x);
1128 }
1129 
1130 template <typename Scalar>
1131 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(hypot, Scalar) hypot(const Scalar& x, const Scalar& y) {
1132  return EIGEN_MATHFUNC_IMPL(hypot, Scalar)::run(x, y);
1133 }
1134 
1135 #if defined(SYCL_DEVICE_ONLY)
1136 SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(hypot, hypot)
1137 #endif
1138 
1139 template <typename Scalar>
1140 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(log1p, Scalar) log1p(const Scalar& x) {
1141  return EIGEN_MATHFUNC_IMPL(log1p, Scalar)::run(x);
1142 }
1143 
1144 #if defined(SYCL_DEVICE_ONLY)
1145 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(log1p, log1p)
1146 #endif
1147 
1148 #if defined(EIGEN_GPUCC)
1149 template <>
1150 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float log1p(const float& x) {
1151  return ::log1pf(x);
1152 }
1153 
1154 template <>
1155 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double log1p(const double& x) {
1156  return ::log1p(x);
1157 }
1158 #endif
1159 
1160 template <typename ScalarX, typename ScalarY>
1161 EIGEN_DEVICE_FUNC inline typename internal::pow_impl<ScalarX, ScalarY>::result_type pow(const ScalarX& x,
1162  const ScalarY& y) {
1163  return internal::pow_impl<ScalarX, ScalarY>::run(x, y);
1164 }
1165 
1166 #if defined(SYCL_DEVICE_ONLY)
1167 SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(pow, pow)
1168 #endif
1169 
1170 template <typename T>
1171 EIGEN_DEVICE_FUNC bool(isnan)(const T& x) {
1172  return internal::isnan_impl(x);
1173 }
1174 template <typename T>
1175 EIGEN_DEVICE_FUNC bool(isinf)(const T& x) {
1176  return internal::isinf_impl(x);
1177 }
1178 template <typename T>
1179 EIGEN_DEVICE_FUNC bool(isfinite)(const T& x) {
1180  return internal::isfinite_impl(x);
1181 }
1182 
1183 #if defined(SYCL_DEVICE_ONLY)
1184 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(isnan, isnan, bool)
1185 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(isinf, isinf, bool)
1186 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE(isfinite, isfinite, bool)
1187 #endif
1188 
1189 template <typename Scalar>
1190 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar rint(const Scalar& x) {
1191  return internal::nearest_integer_impl<Scalar>::run_rint(x);
1192 }
1193 
1194 template <typename Scalar>
1195 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar round(const Scalar& x) {
1196  return internal::nearest_integer_impl<Scalar>::run_round(x);
1197 }
1198 
1199 template <typename Scalar>
1200 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar(floor)(const Scalar& x) {
1201  return internal::nearest_integer_impl<Scalar>::run_floor(x);
1202 }
1203 
1204 template <typename Scalar>
1205 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar(ceil)(const Scalar& x) {
1206  return internal::nearest_integer_impl<Scalar>::run_ceil(x);
1207 }
1208 
1209 template <typename Scalar>
1210 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar(trunc)(const Scalar& x) {
1211  return internal::nearest_integer_impl<Scalar>::run_trunc(x);
1212 }
1213 
1214 #if defined(SYCL_DEVICE_ONLY)
1215 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(round, round)
1216 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(floor, floor)
1217 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(ceil, ceil)
1218 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(trunc, trunc)
1219 #endif
1220 
1221 #if defined(EIGEN_GPUCC)
1222 template <>
1223 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float floor(const float& x) {
1224  return ::floorf(x);
1225 }
1226 template <>
1227 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double floor(const double& x) {
1228  return ::floor(x);
1229 }
1230 template <>
1231 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float ceil(const float& x) {
1232  return ::ceilf(x);
1233 }
1234 template <>
1235 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double ceil(const double& x) {
1236  return ::ceil(x);
1237 }
1238 template <>
1239 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float trunc(const float& x) {
1240  return ::truncf(x);
1241 }
1242 template <>
1243 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double trunc(const double& x) {
1244  return ::trunc(x);
1245 }
1246 #endif
1247 
1248 // Integer division with rounding up.
1249 // T is assumed to be an integer type with a>=0, and b>0
1250 template <typename T>
1251 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE EIGEN_CONSTEXPR T div_ceil(T a, T b) {
1252  using UnsignedT = typename internal::make_unsigned<T>::type;
1253  EIGEN_STATIC_ASSERT((NumTraits<T>::IsInteger), THIS FUNCTION IS FOR INTEGER TYPES)
1254  eigen_assert(a >= 0);
1255  eigen_assert(b > 0);
1256  // Note: explicitly declaring a and b as non-negative values allows the compiler to use better optimizations
1257  const UnsignedT ua = UnsignedT(a);
1258  const UnsignedT ub = UnsignedT(b);
1259  // Note: This form is used because it cannot overflow.
1260  return ua == 0 ? 0 : (ua - 1) / ub + 1;
1261 }
1262 
1263 // Integer round down to nearest power of b
1264 // T is assumed to be an integer type with a>=0, and b>0
1265 template <typename T, typename U>
1266 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE EIGEN_CONSTEXPR T round_down(T a, U b) {
1267  using UnsignedT = typename internal::make_unsigned<T>::type;
1268  using UnsignedU = typename internal::make_unsigned<U>::type;
1269  EIGEN_STATIC_ASSERT((NumTraits<T>::IsInteger), THIS FUNCTION IS FOR INTEGER TYPES)
1270  EIGEN_STATIC_ASSERT((NumTraits<U>::IsInteger), THIS FUNCTION IS FOR INTEGER TYPES)
1271  eigen_assert(a >= 0);
1272  eigen_assert(b > 0);
1273  // Note: explicitly declaring a and b as non-negative values allows the compiler to use better optimizations
1274  const UnsignedT ua = UnsignedT(a);
1275  const UnsignedU ub = UnsignedU(b);
1276  return ub * (ua / ub);
1277 }
1278 
1281 EIGEN_CONSTEXPR inline int log2(int x) {
1282  eigen_assert(x >= 0);
1283  unsigned int v(x);
1284  constexpr int table[32] = {0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
1285  8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31};
1286  v |= v >> 1;
1287  v |= v >> 2;
1288  v |= v >> 4;
1289  v |= v >> 8;
1290  v |= v >> 16;
1291  return table[(v * 0x07C4ACDDU) >> 27];
1292 }
1293 
1303 template <typename Scalar>
1305  return EIGEN_MATHFUNC_IMPL(sqrt, Scalar)::run(x);
1306 }
1307 
1308 // Boolean specialization, avoids implicit float to bool conversion (-Wimplicit-conversion-floating-point-to-bool).
1309 template <>
1311  return x;
1312 }
1313 
1314 #if defined(SYCL_DEVICE_ONLY)
1315 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(sqrt, sqrt)
1316 #endif
1317 
1319 template <typename T>
1322  return static_cast<T>(cbrt(x));
1323 }
1324 
1326 template <typename T>
1329 }
1330 
1331 template <typename T>
1333  return internal::log_impl<T>::run(x);
1334 }
1335 
1336 #if defined(SYCL_DEVICE_ONLY)
1337 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(log, log)
1338 #endif
1339 
1340 #if defined(EIGEN_GPUCC)
1341 template <>
1342 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float log(const float& x) {
1343  return ::logf(x);
1344 }
1345 
1346 template <>
1347 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double log(const double& x) {
1348  return ::log(x);
1349 }
1350 #endif
1351 
1352 template <typename T>
1354  std::enable_if_t<NumTraits<T>::IsSigned || NumTraits<T>::IsComplex, typename NumTraits<T>::Real>
1355  abs(const T& x) {
1357  return abs(x);
1358 }
1359 
1360 template <typename T>
1362  std::enable_if_t<!(NumTraits<T>::IsSigned || NumTraits<T>::IsComplex), typename NumTraits<T>::Real>
1363  abs(const T& x) {
1364  return x;
1365 }
1366 
1367 #if defined(SYCL_DEVICE_ONLY)
1368 SYCL_SPECIALIZE_INTEGER_TYPES_UNARY(abs, abs)
1369 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(abs, fabs)
1370 #endif
1371 
1372 #if defined(EIGEN_GPUCC)
1373 template <>
1374 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float abs(const float& x) {
1375  return ::fabsf(x);
1376 }
1377 
1378 template <>
1379 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double abs(const double& x) {
1380  return ::fabs(x);
1381 }
1382 
1383 template <>
1384 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float abs(const std::complex<float>& x) {
1385  return ::hypotf(x.real(), x.imag());
1386 }
1387 
1388 template <>
1389 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double abs(const std::complex<double>& x) {
1390  return ::hypot(x.real(), x.imag());
1391 }
1392 #endif
1393 
1394 template <typename Scalar, bool IsInteger = NumTraits<Scalar>::IsInteger, bool IsSigned = NumTraits<Scalar>::IsSigned>
1396 template <typename Scalar>
1397 struct signbit_impl<Scalar, false, true> {
1398  static constexpr size_t Size = sizeof(Scalar);
1399  static constexpr size_t Shift = (CHAR_BIT * Size) - 1;
1402  intSize_t a = bit_cast<intSize_t, Scalar>(x);
1403  a = a >> Shift;
1404  Scalar result = bit_cast<Scalar, intSize_t>(a);
1405  return result;
1406  }
1407 };
1408 template <typename Scalar>
1409 struct signbit_impl<Scalar, true, true> {
1410  static constexpr size_t Size = sizeof(Scalar);
1411  static constexpr size_t Shift = (CHAR_BIT * Size) - 1;
1412  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static constexpr Scalar run(const Scalar& x) { return x >> Shift; }
1413 };
1414 template <typename Scalar>
1415 struct signbit_impl<Scalar, true, false> {
1416  EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static constexpr Scalar run(const Scalar&) { return Scalar(0); }
1417 };
1418 template <typename Scalar>
1420  return signbit_impl<Scalar>::run(x);
1421 }
1422 
1423 template <typename T>
1426  return exp(x);
1427 }
1428 
1429 // MSVC screws up some edge-cases for std::exp(complex).
1430 #ifdef EIGEN_COMP_MSVC
1431 template <typename RealScalar>
1432 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<RealScalar> exp(const std::complex<RealScalar>& x) {
1434  // If z is (x,±∞) (for any finite x), the result is (NaN,NaN) and FE_INVALID is raised.
1435  // If z is (x,NaN) (for any finite x), the result is (NaN,NaN) and FE_INVALID may be raised.
1436  if ((isfinite)(real_ref(x)) && !(isfinite)(imag_ref(x))) {
1437  return std::complex<RealScalar>(NumTraits<RealScalar>::quiet_NaN(), NumTraits<RealScalar>::quiet_NaN());
1438  }
1439  // If z is (+∞,±∞), the result is (±∞,NaN) and FE_INVALID is raised (the sign of the real part is unspecified)
1440  // If z is (+∞,NaN), the result is (±∞,NaN) (the sign of the real part is unspecified)
1441  if ((real_ref(x) == NumTraits<RealScalar>::infinity() && !(isfinite)(imag_ref(x)))) {
1442  return std::complex<RealScalar>(NumTraits<RealScalar>::infinity(), NumTraits<RealScalar>::quiet_NaN());
1443  }
1444  return exp(x);
1445 }
1446 #endif
1447 
1448 #if defined(SYCL_DEVICE_ONLY)
1449 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(exp, exp)
1450 #endif
1451 
1452 #if defined(EIGEN_GPUCC)
1453 template <>
1454 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float exp(const float& x) {
1455  return ::expf(x);
1456 }
1457 
1458 template <>
1459 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double exp(const double& x) {
1460  return ::exp(x);
1461 }
1462 
1463 template <>
1464 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<float> exp(const std::complex<float>& x) {
1465  float com = ::expf(x.real());
1466  float res_real = com * ::cosf(x.imag());
1467  float res_imag = com * ::sinf(x.imag());
1468  return std::complex<float>(res_real, res_imag);
1469 }
1470 
1471 template <>
1472 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<double> exp(const std::complex<double>& x) {
1473  double com = ::exp(x.real());
1474  double res_real = com * ::cos(x.imag());
1475  double res_imag = com * ::sin(x.imag());
1476  return std::complex<double>(res_real, res_imag);
1477 }
1478 #endif
1479 
1480 template <typename T>
1483  return exp2(x);
1484 }
1485 
1486 // MSVC screws up some edge-cases for std::exp2(complex).
1487 #ifdef EIGEN_COMP_MSVC
1488 template <typename RealScalar>
1489 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<RealScalar> exp2(const std::complex<RealScalar>& x) {
1491  // If z is (x,±∞) (for any finite x), the result is (NaN,NaN) and FE_INVALID is raised.
1492  // If z is (x,NaN) (for any finite x), the result is (NaN,NaN) and FE_INVALID may be raised.
1493  if ((isfinite)(real_ref(x)) && !(isfinite)(imag_ref(x))) {
1494  return std::complex<RealScalar>(NumTraits<RealScalar>::quiet_NaN(), NumTraits<RealScalar>::quiet_NaN());
1495  }
1496  // If z is (+∞,±∞), the result is (±∞,NaN) and FE_INVALID is raised (the sign of the real part is unspecified)
1497  // If z is (+∞,NaN), the result is (±∞,NaN) (the sign of the real part is unspecified)
1498  if ((real_ref(x) == NumTraits<RealScalar>::infinity() && !(isfinite)(imag_ref(x)))) {
1499  return std::complex<RealScalar>(NumTraits<RealScalar>::infinity(), NumTraits<RealScalar>::quiet_NaN());
1500  }
1501  return exp2(x);
1502 }
1503 #endif
1504 
1505 #if defined(SYCL_DEVICE_ONLY)
1506 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(exp2, exp2)
1507 #endif
1508 
1509 #if defined(EIGEN_GPUCC)
1510 template <>
1511 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float exp2(const float& x) {
1512  return ::exp2f(x);
1513 }
1514 
1515 template <>
1516 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double exp2(const double& x) {
1517  return ::exp2(x);
1518 }
1519 
1520 template <>
1521 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<float> exp2(const std::complex<float>& x) {
1522  float com = ::exp2f(x.real());
1523  float res_real = com * ::cosf(static_cast<float>(EIGEN_LN2) * x.imag());
1524  float res_imag = com * ::sinf(static_cast<float>(EIGEN_LN2) * x.imag());
1525  return std::complex<float>(res_real, res_imag);
1526 }
1527 
1528 template <>
1529 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<double> exp2(const std::complex<double>& x) {
1530  double com = ::exp2(x.real());
1531  double res_real = com * ::cos(static_cast<double>(EIGEN_LN2) * x.imag());
1532  double res_imag = com * ::sin(static_cast<double>(EIGEN_LN2) * x.imag());
1533  return std::complex<double>(res_real, res_imag);
1534 }
1535 #endif
1536 
1537 template <typename Scalar>
1539  return EIGEN_MATHFUNC_IMPL(expm1, Scalar)::run(x);
1540 }
1541 
1542 #if defined(SYCL_DEVICE_ONLY)
1543 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(expm1, expm1)
1544 #endif
1545 
1546 #if defined(EIGEN_GPUCC)
1547 template <>
1548 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float expm1(const float& x) {
1549  return ::expm1f(x);
1550 }
1551 
1552 template <>
1553 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double expm1(const double& x) {
1554  return ::expm1(x);
1555 }
1556 #endif
1557 
1558 template <typename T>
1561  return cos(x);
1562 }
1563 
1564 #if defined(SYCL_DEVICE_ONLY)
1565 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(cos, cos)
1566 #endif
1567 
1568 #if defined(EIGEN_GPUCC)
1569 template <>
1570 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float cos(const float& x) {
1571  return ::cosf(x);
1572 }
1573 
1574 template <>
1575 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double cos(const double& x) {
1576  return ::cos(x);
1577 }
1578 #endif
1579 
1580 template <typename T>
1583  return sin(x);
1584 }
1585 
1586 #if defined(SYCL_DEVICE_ONLY)
1587 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(sin, sin)
1588 #endif
1589 
1590 #if defined(EIGEN_GPUCC)
1591 template <>
1592 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float sin(const float& x) {
1593  return ::sinf(x);
1594 }
1595 
1596 template <>
1597 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double sin(const double& x) {
1598  return ::sin(x);
1599 }
1600 #endif
1601 
1602 template <typename T>
1605  return tan(x);
1606 }
1607 
1608 #if defined(SYCL_DEVICE_ONLY)
1609 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(tan, tan)
1610 #endif
1611 
1612 #if defined(EIGEN_GPUCC)
1613 template <>
1614 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float tan(const float& x) {
1615  return ::tanf(x);
1616 }
1617 
1618 template <>
1619 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double tan(const double& x) {
1620  return ::tan(x);
1621 }
1622 #endif
1623 
1624 template <typename T>
1627  return acos(x);
1628 }
1629 
1630 template <typename T>
1633  return static_cast<T>(acosh(x));
1634 }
1635 
1636 #if defined(SYCL_DEVICE_ONLY)
1637 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(acos, acos)
1638 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(acosh, acosh)
1639 #endif
1640 
1641 #if defined(EIGEN_GPUCC)
1642 template <>
1643 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float acos(const float& x) {
1644  return ::acosf(x);
1645 }
1646 
1647 template <>
1648 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double acos(const double& x) {
1649  return ::acos(x);
1650 }
1651 #endif
1652 
1653 template <typename T>
1656  return asin(x);
1657 }
1658 
1659 template <typename T>
1662  return static_cast<T>(asinh(x));
1663 }
1664 
1665 #if defined(SYCL_DEVICE_ONLY)
1666 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(asin, asin)
1667 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(asinh, asinh)
1668 #endif
1669 
1670 #if defined(EIGEN_GPUCC)
1671 template <>
1672 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float asin(const float& x) {
1673  return ::asinf(x);
1674 }
1675 
1676 template <>
1677 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double asin(const double& x) {
1678  return ::asin(x);
1679 }
1680 #endif
1681 
1682 template <typename T>
1685  return static_cast<T>(atan(x));
1686 }
1687 
1691  return static_cast<T>(atan2(y, x));
1692 }
1693 
1694 template <typename T>
1697  return static_cast<T>(atanh(x));
1698 }
1699 
1700 #if defined(SYCL_DEVICE_ONLY)
1701 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(atan, atan)
1702 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(atanh, atanh)
1703 #endif
1704 
1705 #if defined(EIGEN_GPUCC)
1706 template <>
1707 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float atan(const float& x) {
1708  return ::atanf(x);
1709 }
1710 
1711 template <>
1712 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double atan(const double& x) {
1713  return ::atan(x);
1714 }
1715 #endif
1716 
1717 template <typename T>
1720  return static_cast<T>(cosh(x));
1721 }
1722 
1723 #if defined(SYCL_DEVICE_ONLY)
1724 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(cosh, cosh)
1725 #endif
1726 
1727 #if defined(EIGEN_GPUCC)
1728 template <>
1729 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float cosh(const float& x) {
1730  return ::coshf(x);
1731 }
1732 
1733 template <>
1734 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double cosh(const double& x) {
1735  return ::cosh(x);
1736 }
1737 #endif
1738 
1739 template <typename T>
1742  return static_cast<T>(sinh(x));
1743 }
1744 
1745 #if defined(SYCL_DEVICE_ONLY)
1746 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(sinh, sinh)
1747 #endif
1748 
1749 #if defined(EIGEN_GPUCC)
1750 template <>
1751 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float sinh(const float& x) {
1752  return ::sinhf(x);
1753 }
1754 
1755 template <>
1756 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double sinh(const double& x) {
1757  return ::sinh(x);
1758 }
1759 #endif
1760 
1761 template <typename T>
1764  return tanh(x);
1765 }
1766 
1767 #if (!defined(EIGEN_GPUCC)) && EIGEN_FAST_MATH && !defined(SYCL_DEVICE_ONLY)
1769 #endif
1770 
1771 #if defined(SYCL_DEVICE_ONLY)
1772 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(tanh, tanh)
1773 #endif
1774 
1775 #if defined(EIGEN_GPUCC)
1776 template <>
1777 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float tanh(const float& x) {
1778  return ::tanhf(x);
1779 }
1780 
1781 template <>
1782 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double tanh(const double& x) {
1783  return ::tanh(x);
1784 }
1785 #endif
1786 
1787 template <typename T>
1790  return fmod(a, b);
1791 }
1792 
1793 #if defined(SYCL_DEVICE_ONLY)
1794 SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(fmod, fmod)
1795 #endif
1796 
1797 #if defined(EIGEN_GPUCC)
1798 template <>
1799 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float fmod(const float& a, const float& b) {
1800  return ::fmodf(a, b);
1801 }
1802 
1803 template <>
1804 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double fmod(const double& a, const double& b) {
1805  return ::fmod(a, b);
1806 }
1807 #endif
1808 
1809 #if defined(SYCL_DEVICE_ONLY)
1810 #undef SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_BINARY
1811 #undef SYCL_SPECIALIZE_SIGNED_INTEGER_TYPES_UNARY
1812 #undef SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_BINARY
1813 #undef SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY
1814 #undef SYCL_SPECIALIZE_INTEGER_TYPES_BINARY
1815 #undef SYCL_SPECIALIZE_UNSIGNED_INTEGER_TYPES_UNARY
1816 #undef SYCL_SPECIALIZE_FLOATING_TYPES_BINARY
1817 #undef SYCL_SPECIALIZE_FLOATING_TYPES_UNARY
1818 #undef SYCL_SPECIALIZE_FLOATING_TYPES_UNARY_FUNC_RET_TYPE
1819 #undef SYCL_SPECIALIZE_GEN_UNARY_FUNC
1820 #undef SYCL_SPECIALIZE_UNARY_FUNC
1821 #undef SYCL_SPECIALIZE_GEN1_BINARY_FUNC
1822 #undef SYCL_SPECIALIZE_GEN2_BINARY_FUNC
1823 #undef SYCL_SPECIALIZE_BINARY_FUNC
1824 #endif
1825 
1828  return a << n;
1829 }
1830 
1833  using UnsignedScalar = typename numext::get_integer_by_size<sizeof(Scalar)>::unsigned_type;
1834  return bit_cast<Scalar, UnsignedScalar>(bit_cast<UnsignedScalar, Scalar>(a) >> n);
1835 }
1836 
1839  using SignedScalar = typename numext::get_integer_by_size<sizeof(Scalar)>::signed_type;
1840  return bit_cast<Scalar, SignedScalar>(bit_cast<SignedScalar, Scalar>(a) >> n);
1841 }
1842 
1843 } // end namespace numext
1844 
1845 namespace internal {
1846 
1847 template <typename T>
1848 EIGEN_DEVICE_FUNC bool isfinite_impl(const std::complex<T>& x) {
1850 }
1851 
1852 template <typename T>
1853 EIGEN_DEVICE_FUNC bool isnan_impl(const std::complex<T>& x) {
1855 }
1856 
1857 template <typename T>
1858 EIGEN_DEVICE_FUNC bool isinf_impl(const std::complex<T>& x) {
1859  return ((numext::isinf)(numext::real(x)) || (numext::isinf)(numext::imag(x))) && (!(numext::isnan)(x));
1860 }
1861 
1862 /****************************************************************************
1863  * Implementation of fuzzy comparisons *
1864  ****************************************************************************/
1865 
1866 template <typename Scalar, bool IsComplex, bool IsInteger>
1868 
1869 template <typename Scalar>
1870 struct scalar_fuzzy_default_impl<Scalar, false, false> {
1872  template <typename OtherScalar>
1873  EIGEN_DEVICE_FUNC static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y,
1874  const RealScalar& prec) {
1875  return numext::abs(x) <= numext::abs(y) * prec;
1876  }
1877  EIGEN_DEVICE_FUNC static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec) {
1878  return numext::abs(x - y) <= numext::mini(numext::abs(x), numext::abs(y)) * prec;
1879  }
1880  EIGEN_DEVICE_FUNC static inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, const RealScalar& prec) {
1881  return x <= y || isApprox(x, y, prec);
1882  }
1883 };
1884 
1885 template <typename Scalar>
1886 struct scalar_fuzzy_default_impl<Scalar, false, true> {
1888  template <typename OtherScalar>
1889  EIGEN_DEVICE_FUNC static inline bool isMuchSmallerThan(const Scalar& x, const Scalar&, const RealScalar&) {
1890  return x == Scalar(0);
1891  }
1892  EIGEN_DEVICE_FUNC static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar&) { return x == y; }
1893  EIGEN_DEVICE_FUNC static inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, const RealScalar&) {
1894  return x <= y;
1895  }
1896 };
1897 
1898 template <typename Scalar>
1899 struct scalar_fuzzy_default_impl<Scalar, true, false> {
1901  template <typename OtherScalar>
1902  EIGEN_DEVICE_FUNC static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y,
1903  const RealScalar& prec) {
1904  return numext::abs2(x) <= numext::abs2(y) * prec * prec;
1905  }
1906  EIGEN_DEVICE_FUNC static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec) {
1907  return numext::abs2(x - y) <= numext::mini(numext::abs2(x), numext::abs2(y)) * prec * prec;
1908  }
1909 };
1910 
1911 template <typename Scalar>
1913  : scalar_fuzzy_default_impl<Scalar, NumTraits<Scalar>::IsComplex, NumTraits<Scalar>::IsInteger> {};
1914 
1915 template <typename Scalar, typename OtherScalar>
1917  const Scalar& x, const OtherScalar& y,
1918  const typename NumTraits<Scalar>::Real& precision = NumTraits<Scalar>::dummy_precision()) {
1919  return scalar_fuzzy_impl<Scalar>::template isMuchSmallerThan<OtherScalar>(x, y, precision);
1920 }
1921 
1922 template <typename Scalar>
1924  const Scalar& x, const Scalar& y,
1925  const typename NumTraits<Scalar>::Real& precision = NumTraits<Scalar>::dummy_precision()) {
1926  return scalar_fuzzy_impl<Scalar>::isApprox(x, y, precision);
1927 }
1928 
1929 template <typename Scalar>
1931  const Scalar& x, const Scalar& y,
1932  const typename NumTraits<Scalar>::Real& precision = NumTraits<Scalar>::dummy_precision()) {
1934 }
1935 
1936 /******************************************
1937 *** The special case of the bool type ***
1938 ******************************************/
1939 
1940 template <>
1942  typedef bool RealScalar;
1943 
1944  template <typename OtherScalar>
1945  EIGEN_DEVICE_FUNC static inline bool isMuchSmallerThan(const bool& x, const bool&, const bool&) {
1946  return !x;
1947  }
1948 
1949  EIGEN_DEVICE_FUNC static inline bool isApprox(bool x, bool y, bool) { return x == y; }
1950 
1951  EIGEN_DEVICE_FUNC static inline bool isApproxOrLessThan(const bool& x, const bool& y, const bool&) {
1952  return (!x) || y;
1953  }
1954 };
1955 
1956 } // end namespace internal
1957 
1958 // Default implementations that rely on other numext implementations
1959 namespace internal {
1960 
1961 // Specialization for complex types that are not supported by std::expm1.
1962 template <typename RealScalar>
1963 struct expm1_impl<std::complex<RealScalar>> {
1965 
1966  EIGEN_DEVICE_FUNC static inline std::complex<RealScalar> run(const std::complex<RealScalar>& x) {
1967  RealScalar xr = x.real();
1968  RealScalar xi = x.imag();
1969  // expm1(z) = exp(z) - 1
1970  // = exp(x + i * y) - 1
1971  // = exp(x) * (cos(y) + i * sin(y)) - 1
1972  // = exp(x) * cos(y) - 1 + i * exp(x) * sin(y)
1973  // Imag(expm1(z)) = exp(x) * sin(y)
1974  // Real(expm1(z)) = exp(x) * cos(y) - 1
1975  // = exp(x) * cos(y) - 1.
1976  // = expm1(x) + exp(x) * (cos(y) - 1)
1977  // = expm1(x) + exp(x) * (2 * sin(y / 2) ** 2)
1978  RealScalar erm1 = numext::expm1<RealScalar>(xr);
1979  RealScalar er = erm1 + RealScalar(1.);
1980  RealScalar sin2 = numext::sin(xi / RealScalar(2.));
1981  sin2 = sin2 * sin2;
1982  RealScalar s = numext::sin(xi);
1983  RealScalar real_part = erm1 - RealScalar(2.) * er * sin2;
1984  return std::complex<RealScalar>(real_part, er * s);
1985  }
1986 };
1987 
1988 template <typename T>
1989 struct rsqrt_impl {
1990  EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE T run(const T& x) { return T(1) / numext::sqrt(x); }
1991 };
1992 
1993 #if defined(EIGEN_GPU_COMPILE_PHASE)
1994 template <typename T>
1995 struct conj_impl<std::complex<T>, true> {
1996  EIGEN_DEVICE_FUNC static inline std::complex<T> run(const std::complex<T>& x) {
1997  return std::complex<T>(numext::real(x), -numext::imag(x));
1998  }
1999 };
2000 #endif
2001 
2002 } // end namespace internal
2003 
2004 } // end namespace Eigen
2005 
2006 #endif // EIGEN_MATHFUNCTIONS_H
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
AnnoyingScalar cos(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:136
AnnoyingScalar acos(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:138
AnnoyingScalar sin(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:137
AnnoyingScalar conj(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:133
AnnoyingScalar imag(const AnnoyingScalar &)
Definition: AnnoyingScalar.h:132
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Eigen::Triplet< double > T
Definition: EigenUnitTest.cpp:11
#define EIGEN_ALWAYS_INLINE
Definition: Macros.h:845
#define EIGEN_USING_STD(FUNC)
Definition: Macros.h:1090
#define EIGEN_CONSTEXPR
Definition: Macros.h:758
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define eigen_assert(x)
Definition: Macros.h:910
#define EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
Definition: Macros.h:900
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
#define EIGEN_MATHFUNC_IMPL(func, scalar)
Definition: MathFunctions.h:64
#define EIGEN_LN2
Definition: MathFunctions.h:18
#define EIGEN_PI
Definition: MathFunctions.h:16
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
Definition: StaticAssert.h:74
ArrayXXf table(10, 4)
Scalar * b
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:46
@ IsComplex
Definition: common.h:73
float real
Definition: datatypes.h:10
RealScalar s
Definition: level1_cplx_impl.h:130
return int(ret)+1
if n return
Definition: level1_cplx_impl.h:31
const Scalar * a
Definition: level2_cplx_impl.h:32
#define isfinite(X)
Definition: main.h:111
EIGEN_DEVICE_FUNC Scalar expm1(const Scalar &x)
Definition: MathFunctions.h:433
EIGEN_DEVICE_FUNC Scalar log1p(const Scalar &x)
Definition: MathFunctions.h:496
EIGEN_DEVICE_FUNC int clz(BitsType bits)
Definition: MathFunctions.h:644
EIGEN_DEVICE_FUNC std::enable_if_t<!(std::numeric_limits< T >::has_quiet_NaN||std::numeric_limits< T >::has_signaling_NaN), bool > isnan_impl(const T &)
Definition: MathFunctions.h:802
@ meta_floor_log2_terminate
Definition: MathFunctions.h:566
@ meta_floor_log2_move_up
Definition: MathFunctions.h:566
@ meta_floor_log2_move_down
Definition: MathFunctions.h:566
@ meta_floor_log2_bogus
Definition: MathFunctions.h:566
const Scalar & y
Definition: RandomImpl.h:36
EIGEN_DEVICE_FUNC std::enable_if_t<!std::numeric_limits< T >::has_infinity, bool > isinf_impl(const T &)
Definition: MathFunctions.h:788
EIGEN_DEVICE_FUNC bool isApprox(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
Definition: MathFunctions.h:1923
EIGEN_DEVICE_FUNC std::enable_if_t<!(std::numeric_limits< T >::has_infinity||std::numeric_limits< T >::has_quiet_NaN||std::numeric_limits< T >::has_signaling_NaN), bool > isfinite_impl(const T &)
Definition: MathFunctions.h:773
EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
Definition: MathFunctions.h:1916
EIGEN_DEVICE_FUNC NewType cast(const OldType &x)
Definition: MathFunctions.h:362
EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS T ptanh_float(const T &a_x)
Definition: GenericPacketMathFunctions.h:1155
EIGEN_DEVICE_FUNC std::complex< T > complex_log(const std::complex< T > &z)
Definition: MathFunctionsImpl.h:250
EIGEN_DEVICE_FUNC std::complex< T > complex_sqrt(const std::complex< T > &a_x)
Definition: MathFunctionsImpl.h:175
EIGEN_DEVICE_FUNC int ctz(BitsType bits)
Definition: MathFunctions.h:650
EIGEN_DEVICE_FUNC std::complex< T > complex_rsqrt(const std::complex< T > &a_x)
Definition: MathFunctionsImpl.h:211
EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar &x
EIGEN_DEVICE_FUNC bool isApproxOrLessThan(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
Definition: MathFunctions.h:1930
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T log(const T &x)
Definition: MathFunctions.h:1332
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool() isinf(const Eigen::bfloat16 &h)
Definition: BFloat16.h:747
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T acosh(const T &x)
Definition: MathFunctions.h:1631
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool equal_strict(const X &x, const Y &y)
Definition: Meta.h:571
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool() isfinite(const Eigen::bfloat16 &h)
Definition: BFloat16.h:752
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T asinh(const T &x)
Definition: MathFunctions.h:1660
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T fmod(const T &a, const T &b)
Definition: MathFunctions.h:1788
EIGEN_DEVICE_FUNC internal::add_const_on_value_type_t< EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar)> imag_ref(const Scalar &x)
Definition: MathFunctions.h:1072
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::enable_if_t< NumTraits< T >::IsSigned||NumTraits< T >::IsComplex, typename NumTraits< T >::Real > abs(const T &x)
Definition: MathFunctions.h:1355
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T rsqrt(const T &x)
Definition: MathFunctions.h:1327
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool() isnan(const Eigen::bfloat16 &h)
Definition: BFloat16.h:742
EIGEN_DEVICE_FUNC internal::add_const_on_value_type_t< EIGEN_MATHFUNC_RETVAL(real_ref, Scalar)> real_ref(const Scalar &x)
Definition: MathFunctions.h:1051
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T asin(const T &x)
Definition: MathFunctions.h:1654
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar logical_shift_left(const Scalar &a, int n)
Definition: MathFunctions.h:1827
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T tanh(const T &x)
Definition: MathFunctions.h:1762
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T cbrt(const T &x)
Definition: MathFunctions.h:1320
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T atan(const T &x)
Definition: MathFunctions.h:1683
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T atanh(const T &x)
Definition: MathFunctions.h:1695
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T cosh(const T &x)
Definition: MathFunctions.h:1718
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T exp(const T &x)
Definition: MathFunctions.h:1424
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T sin(const T &x)
Definition: MathFunctions.h:1581
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar arithmetic_shift_right(const Scalar &a, int n)
Definition: MathFunctions.h:1838
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float sqrt(const float &x)
Definition: arch/SSE/MathFunctions.h:69
EIGEN_DEVICE_FUNC internal::pow_impl< ScalarX, ScalarY >::result_type pow(const ScalarX &x, const ScalarY &y)
Definition: MathFunctions.h:1161
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T tan(const T &x)
Definition: MathFunctions.h:1603
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
Definition: MathFunctions.h:920
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar logical_shift_right(const Scalar &a, int n)
Definition: MathFunctions.h:1832
EIGEN_DEVICE_FUNC bool abs2(bool x)
Definition: MathFunctions.h:1102
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T sinh(const T &x)
Definition: MathFunctions.h:1740
EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_DEVICE_FUNC bool sqrt< bool >(const bool &x)
Definition: MathFunctions.h:1310
EIGEN_DEVICE_FUNC static constexpr EIGEN_ALWAYS_INLINE Scalar signbit(const Scalar &x)
Definition: MathFunctions.h:1419
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T exp2(const T &x)
Definition: MathFunctions.h:1481
Map< const Array< unsigned char, sizeof(T), 1 > > bits(const T &x)
Definition: packetmath_test_shared.h:36
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
auto run(Kernel kernel, Args &&... args) -> decltype(kernel(args...))
Definition: gpu_test_helper.h:414
AutoDiffScalar< Matrix< typename internal::traits< internal::remove_all_t< DerTypeA > >::Scalar, Dynamic, 1 > > atan2(const AutoDiffScalar< DerTypeA > &a, const AutoDiffScalar< DerTypeB > &b)
Definition: AutoDiffScalar.h:558
squared absolute value
Definition: GlobalFunctions.h:87
const AutoDiffScalar< DerType > & real(const AutoDiffScalar< DerType > &x)
Definition: AutoDiffScalar.h:486
DerType::Scalar imag(const AutoDiffScalar< DerType > &)
Definition: AutoDiffScalar.h:490
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
Definition: AutoDiffScalar.h:482
Real fabs(const Real &a)
Definition: boostmultiprec.cpp:117
std::string lower(std::string s)
returns the input string after converting upper-case characters to lower case
Definition: StringHelpers.cc:11
Definition: Eigen_Colamd.h:49
list x
Definition: plotDoE.py:28
@ IsSigned
Definition: NumTraits.h:175
@ IsComplex
Definition: NumTraits.h:176
T Real
Definition: NumTraits.h:183
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition: XprHelper.h:1043
static EIGEN_DEVICE_FUNC RealScalar run(const Scalar &x)
Definition: MathFunctions.h:224
NumTraits< Scalar >::Real RealScalar
Definition: MathFunctions.h:223
Definition: MathFunctions.h:215
static EIGEN_DEVICE_FUNC RealScalar run(const Scalar &x)
Definition: MathFunctions.h:217
NumTraits< Scalar >::Real RealScalar
Definition: MathFunctions.h:216
Definition: MathFunctions.h:228
static EIGEN_DEVICE_FUNC RealScalar run(const Scalar &x)
Definition: MathFunctions.h:230
NumTraits< Scalar >::Real RealScalar
Definition: MathFunctions.h:229
Definition: MathFunctions.h:236
NumTraits< Scalar >::Real type
Definition: MathFunctions.h:237
Definition: MathFunctions.h:54
void type
Definition: MathFunctions.h:55
NumTraits< Scalar >::Real RealScalar
Definition: MathFunctions.h:392
static EIGEN_DEVICE_FUNC RealScalar run(const Scalar &x)
Definition: MathFunctions.h:393
static EIGEN_DEVICE_FUNC RealScalar run(const Scalar &x)
Definition: MathFunctions.h:382
NumTraits< Scalar >::Real RealScalar
Definition: MathFunctions.h:381
Definition: MathFunctions.h:377
Definition: MathFunctions.h:416
Definition: MathFunctions.h:419
NumTraits< Scalar >::Real type
Definition: MathFunctions.h:420
static EIGEN_DEVICE_FUNC bool run(const OldType &x)
Definition: MathFunctions.h:345
Definition: MathFunctions.h:339
static EIGEN_DEVICE_FUNC NewType run(const OldType &x)
Definition: MathFunctions.h:340
static EIGEN_DEVICE_FUNC Scalar run(const Scalar &x)
Definition: MathFunctions.h:196
Definition: MathFunctions.h:190
static EIGEN_DEVICE_FUNC Scalar run(const Scalar &x)
Definition: MathFunctions.h:191
Definition: MathFunctions.h:203
Definition: MathFunctions.h:206
Scalar type
Definition: MathFunctions.h:207
Definition: MathFunctions.h:604
static EIGEN_DEVICE_FUNC int ctz(BitsType bits)
Definition: MathFunctions.h:624
static EIGEN_DEVICE_FUNC int clz(BitsType bits)
Definition: MathFunctions.h:607
Definition: MathFunctions.h:454
static EIGEN_DEVICE_FUNC Scalar run(const Scalar &x)
Definition: MathFunctions.h:455
Definition: MathFunctions.h:463
Scalar type
Definition: MathFunctions.h:464
Definition: MathFunctionsImpl.h:164
Definition: MathFunctions.h:330
NumTraits< Scalar >::Real type
Definition: MathFunctions.h:331
static EIGEN_DEVICE_FUNC RealScalar run(const Scalar &x)
Definition: MathFunctions.h:118
NumTraits< Scalar >::Real RealScalar
Definition: MathFunctions.h:117
Definition: MathFunctions.h:110
static EIGEN_DEVICE_FUNC RealScalar run(const Scalar &)
Definition: MathFunctions.h:112
NumTraits< Scalar >::Real RealScalar
Definition: MathFunctions.h:111
Definition: MathFunctions.h:125
EIGEN_DEVICE_FUNC static EIGEN_CONSTEXPR const Scalar run(const Scalar &)
Definition: MathFunctions.h:174
EIGEN_DEVICE_FUNC static EIGEN_CONSTEXPR Scalar run(Scalar &)
Definition: MathFunctions.h:173
Definition: MathFunctions.h:163
static EIGEN_DEVICE_FUNC const RealScalar & run(const Scalar &x)
Definition: MathFunctions.h:166
static EIGEN_DEVICE_FUNC RealScalar & run(Scalar &x)
Definition: MathFunctions.h:165
NumTraits< Scalar >::Real RealScalar
Definition: MathFunctions.h:164
Definition: MathFunctions.h:178
Definition: MathFunctions.h:181
NumTraits< Scalar >::Real & type
Definition: MathFunctions.h:182
Definition: MathFunctions.h:136
NumTraits< Scalar >::Real type
Definition: MathFunctions.h:137
@ value
Definition: Meta.h:206
Definition: MathFunctions.h:509
static EIGEN_DEVICE_FUNC Scalar run(const Scalar &x)
Definition: MathFunctions.h:512
Definition: MathFunctions.h:529
Scalar type
Definition: MathFunctions.h:530
static EIGEN_DEVICE_FUNC std::complex< Scalar > run(const std::complex< Scalar > &z)
Definition: MathFunctions.h:485
Definition: MathFunctions.h:476
static EIGEN_DEVICE_FUNC Scalar run(const Scalar &x)
Definition: MathFunctions.h:477
Definition: MathFunctions.h:569
@ value
Definition: MathFunctions.h:572
@ middle
Definition: MathFunctions.h:571
Definition: MathFunctions.h:581
static EIGEN_DEVICE_FUNC Scalar run(const Scalar &x)
Definition: MathFunctions.h:308
static EIGEN_DEVICE_FUNC RealScalar run(const Scalar &x)
Definition: MathFunctions.h:300
NumTraits< Scalar >::Real RealScalar
Definition: MathFunctions.h:299
Definition: MathFunctions.h:295
Definition: MathFunctions.h:315
Definition: MathFunctions.h:318
NumTraits< Scalar >::Real type
Definition: MathFunctions.h:319
ScalarX result_type
Definition: MathFunctions.h:551
static EIGEN_DEVICE_FUNC ScalarX run(ScalarX x, ScalarY y)
Definition: MathFunctions.h:552
Definition: MathFunctions.h:539
static EIGEN_DEVICE_FUNC result_type run(const ScalarX &x, const ScalarY &y)
Definition: MathFunctions.h:543
ScalarBinaryOpTraits< ScalarX, ScalarY, internal::scalar_pow_op< ScalarX, ScalarY > >::ReturnType result_type
Definition: MathFunctions.h:542
static EIGEN_DEVICE_FUNC RealScalar run(const Scalar &x)
Definition: MathFunctions.h:83
NumTraits< Scalar >::Real RealScalar
Definition: MathFunctions.h:82
Definition: MathFunctions.h:75
static EIGEN_DEVICE_FUNC RealScalar run(const Scalar &x)
Definition: MathFunctions.h:77
NumTraits< Scalar >::Real RealScalar
Definition: MathFunctions.h:76
Definition: MathFunctions.h:90
Definition: MathFunctions.h:145
static EIGEN_DEVICE_FUNC const RealScalar & run(const Scalar &x)
Definition: MathFunctions.h:148
NumTraits< Scalar >::Real RealScalar
Definition: MathFunctions.h:146
static EIGEN_DEVICE_FUNC RealScalar & run(Scalar &x)
Definition: MathFunctions.h:147
Definition: MathFunctions.h:154
NumTraits< Scalar >::Real & type
Definition: MathFunctions.h:155
Definition: MathFunctions.h:101
NumTraits< Scalar >::Real type
Definition: MathFunctions.h:102
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex< T > run(const std::complex< T > &x)
Definition: MathFunctions.h:280
Definition: MathFunctions.h:1989
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T run(const T &x)
Definition: MathFunctions.h:1990
Definition: MathFunctions.h:286
Scalar type
Definition: MathFunctions.h:287
static EIGEN_DEVICE_FUNC bool isApproxOrLessThan(const Scalar &x, const Scalar &y, const RealScalar &prec)
Definition: MathFunctions.h:1880
static EIGEN_DEVICE_FUNC bool isApprox(const Scalar &x, const Scalar &y, const RealScalar &prec)
Definition: MathFunctions.h:1877
NumTraits< Scalar >::Real RealScalar
Definition: MathFunctions.h:1871
static EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const RealScalar &prec)
Definition: MathFunctions.h:1873
static EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const Scalar &x, const Scalar &, const RealScalar &)
Definition: MathFunctions.h:1889
NumTraits< Scalar >::Real RealScalar
Definition: MathFunctions.h:1887
static EIGEN_DEVICE_FUNC bool isApproxOrLessThan(const Scalar &x, const Scalar &y, const RealScalar &)
Definition: MathFunctions.h:1893
static EIGEN_DEVICE_FUNC bool isApprox(const Scalar &x, const Scalar &y, const RealScalar &)
Definition: MathFunctions.h:1892
NumTraits< Scalar >::Real RealScalar
Definition: MathFunctions.h:1900
static EIGEN_DEVICE_FUNC bool isApprox(const Scalar &x, const Scalar &y, const RealScalar &prec)
Definition: MathFunctions.h:1906
static EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const RealScalar &prec)
Definition: MathFunctions.h:1902
Definition: MathFunctions.h:1867
static EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const bool &x, const bool &, const bool &)
Definition: MathFunctions.h:1945
bool RealScalar
Definition: MathFunctions.h:1942
static EIGEN_DEVICE_FUNC bool isApprox(bool x, bool y, bool)
Definition: MathFunctions.h:1949
static EIGEN_DEVICE_FUNC bool isApproxOrLessThan(const bool &x, const bool &y, const bool &)
Definition: MathFunctions.h:1951
Definition: MathFunctions.h:1913
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex< T > run(const std::complex< T > &x)
Definition: MathFunctions.h:260
Definition: MathFunctions.h:245
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Scalar run(const Scalar &x)
Definition: MathFunctions.h:246
Definition: MathFunctions.h:266
Scalar type
Definition: MathFunctions.h:267
void signed_type
Definition: Meta.h:47
typename get_integer_by_size< Size >::signed_type intSize_t
Definition: MathFunctions.h:1400
EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE Scalar run(const Scalar &x)
Definition: MathFunctions.h:1401
EIGEN_DEVICE_FUNC static constexpr EIGEN_ALWAYS_INLINE Scalar run(const Scalar &)
Definition: MathFunctions.h:1416
EIGEN_DEVICE_FUNC static constexpr EIGEN_ALWAYS_INLINE Scalar run(const Scalar &x)
Definition: MathFunctions.h:1412
Definition: MathFunctions.h:1395
Definition: datatypes.h:12
void run(const string &dir_name, LinearSolver *linear_solver_pt, const unsigned nel_1d, bool mess_up_order)
Definition: two_d_poisson_compare_solvers.cc:317