functors/UnaryFunctors.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) 2008-2016 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_UNARY_FUNCTORS_H
11 #define EIGEN_UNARY_FUNCTORS_H
12 
13 #include "../InternalHeaderCheck.h"
14 
15 namespace Eigen {
16 
17 namespace internal {
18 
24 template<typename Scalar> struct scalar_opposite_op {
25  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return -a; }
26  template<typename Packet>
27  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const
28  { return internal::pnegate(a); }
29 };
30 template<typename Scalar>
31 struct functor_traits<scalar_opposite_op<Scalar> >
32 { enum {
34  PacketAccess = packet_traits<Scalar>::HasNegate };
35 };
36 
42 template<typename Scalar> struct scalar_abs_op {
43  typedef typename NumTraits<Scalar>::Real result_type;
44  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return numext::abs(a); }
45  template<typename Packet>
46  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const
47  { return internal::pabs(a); }
48 };
49 template<typename Scalar>
50 struct functor_traits<scalar_abs_op<Scalar> >
51 {
52  enum {
54  PacketAccess = packet_traits<Scalar>::HasAbs
55  };
56 };
57 
63 template<typename Scalar> struct scalar_score_coeff_op : scalar_abs_op<Scalar>
64 {
65  typedef void Score_is_abs;
66 };
67 template<typename Scalar>
68 struct functor_traits<scalar_score_coeff_op<Scalar> > : functor_traits<scalar_abs_op<Scalar> > {};
69 
70 /* Avoid recomputing abs when we know the score and they are the same. Not a true Eigen functor. */
71 template<typename Scalar, typename=void> struct abs_knowing_score
72 {
73  typedef typename NumTraits<Scalar>::Real result_type;
74  template<typename Score>
75  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a, const Score&) const { return numext::abs(a); }
76 };
77 template<typename Scalar> struct abs_knowing_score<Scalar, typename scalar_score_coeff_op<Scalar>::Score_is_abs>
78 {
79  typedef typename NumTraits<Scalar>::Real result_type;
80  template<typename Scal>
81  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const Scal&, const result_type& a) const { return a; }
82 };
83 
89 template<typename Scalar> struct scalar_abs2_op {
90  typedef typename NumTraits<Scalar>::Real result_type;
92  EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return numext::abs2(a); }
93  template<typename Packet>
94  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const
95  { return internal::pmul(a,a); }
96 };
97 template<typename Scalar>
98 struct functor_traits<scalar_abs2_op<Scalar> >
99 { enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasAbs2 }; };
100 
106 template<typename Scalar> struct scalar_conjugate_op {
108  EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return numext::conj(a); }
109  template<typename Packet>
110  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const { return internal::pconj(a); }
111 };
112 template<typename Scalar>
113 struct functor_traits<scalar_conjugate_op<Scalar> >
114 {
115  enum {
116  Cost = 0,
117  // Yes the cost is zero even for complexes because in most cases for which
118  // the cost is used, conjugation turns to be a no-op. Some examples:
119  // cost(a*conj(b)) == cost(a*b)
120  // cost(a+conj(b)) == cost(a+b)
121  // <etc.
122  // If we don't set it to zero, then:
123  // A.conjugate().lazyProduct(B.conjugate())
124  // will bake its operands. We definitely don't want that!
125  PacketAccess = packet_traits<Scalar>::HasConj
126  };
127 };
128 
134 template<typename Scalar> struct scalar_arg_op {
135  typedef typename NumTraits<Scalar>::Real result_type;
136  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const result_type operator() (const Scalar& a) const { return numext::arg(a); }
137  template<typename Packet>
138  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const
139  { return internal::parg(a); }
140 };
141 template<typename Scalar>
142 struct functor_traits<scalar_arg_op<Scalar> >
143 {
144  enum {
146  PacketAccess = packet_traits<Scalar>::HasArg
147  };
148 };
149 
155 template <typename Scalar>
156 struct scalar_carg_op {
157  using result_type = Scalar;
159  EIGEN_STRONG_INLINE const Scalar operator()(const Scalar& a) const { return Scalar(numext::arg(a)); }
160  template <typename Packet>
161  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const {
162  return pcarg(a);
163  }
164 };
165 template <typename Scalar>
166 struct functor_traits<scalar_carg_op<Scalar>> {
167  using RealScalar = typename NumTraits<Scalar>::Real;
168  enum { Cost = functor_traits<scalar_atan2_op<RealScalar>>::Cost, PacketAccess = packet_traits<RealScalar>::HasATan };
169 };
170 
176 template<typename Scalar, typename NewType>
177 struct scalar_cast_op {
178  typedef NewType result_type;
179  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const NewType operator() (const Scalar& a) const { return cast<Scalar, NewType>(a); }
180 };
181 
182 template<typename Scalar, typename NewType>
183 struct functor_traits<scalar_cast_op<Scalar,NewType> >
184 { enum { Cost = is_same<Scalar, NewType>::value ? 0 : NumTraits<NewType>::AddCost, PacketAccess = false }; };
185 
192 template <typename SrcType, typename DstType>
193 struct core_cast_op : scalar_cast_op<SrcType, DstType> {};
194 
195 template <typename SrcType, typename DstType>
196 struct functor_traits<core_cast_op<SrcType, DstType>> {
197  using CastingTraits = type_casting_traits<SrcType, DstType>;
198  enum {
199  Cost = is_same<SrcType, DstType>::value ? 0 : NumTraits<DstType>::AddCost,
200  PacketAccess = CastingTraits::VectorizedCast && (CastingTraits::SrcCoeffRatio <= 8)
201  };
202 };
203 
209 template<typename Scalar, int N>
210 struct scalar_shift_right_op {
211 
212  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const
213  { return a >> N; }
214  template<typename Packet>
215  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const
216  { return internal::parithmetic_shift_right<N>(a); }
217 };
218 template<typename Scalar, int N>
219 struct functor_traits<scalar_shift_right_op<Scalar,N> >
220 { enum { Cost = NumTraits<Scalar>::AddCost, PacketAccess = packet_traits<Scalar>::HasShift }; };
221 
227 template<typename Scalar, int N>
228 struct scalar_shift_left_op {
229  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const
230  { return a << N; }
231  template<typename Packet>
232  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet& a) const
233  { return internal::plogical_shift_left<N>(a); }
234 };
235 template<typename Scalar, int N>
236 struct functor_traits<scalar_shift_left_op<Scalar,N> >
237 { enum { Cost = NumTraits<Scalar>::AddCost, PacketAccess = packet_traits<Scalar>::HasShift }; };
238 
244 template<typename Scalar>
245 struct scalar_real_op {
246  typedef typename NumTraits<Scalar>::Real result_type;
248  EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return numext::real(a); }
249 };
250 template<typename Scalar>
251 struct functor_traits<scalar_real_op<Scalar> >
252 { enum { Cost = 0, PacketAccess = false }; };
253 
259 template<typename Scalar>
260 struct scalar_imag_op {
261  typedef typename NumTraits<Scalar>::Real result_type;
263  EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const { return numext::imag(a); }
264 };
265 template<typename Scalar>
266 struct functor_traits<scalar_imag_op<Scalar> >
267 { enum { Cost = 0, PacketAccess = false }; };
268 
274 template<typename Scalar>
275 struct scalar_real_ref_op {
276  typedef typename NumTraits<Scalar>::Real result_type;
278  EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return numext::real_ref(*const_cast<Scalar*>(&a)); }
279 };
280 template<typename Scalar>
281 struct functor_traits<scalar_real_ref_op<Scalar> >
282 { enum { Cost = 0, PacketAccess = false }; };
283 
289 template<typename Scalar>
290 struct scalar_imag_ref_op {
291  typedef typename NumTraits<Scalar>::Real result_type;
293  EIGEN_STRONG_INLINE result_type& operator() (const Scalar& a) const { return numext::imag_ref(*const_cast<Scalar*>(&a)); }
294 };
295 template<typename Scalar>
296 struct functor_traits<scalar_imag_ref_op<Scalar> >
297 { enum { Cost = 0, PacketAccess = false }; };
298 
305 template<typename Scalar> struct scalar_exp_op {
306  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return internal::pexp(a); }
307  template <typename Packet>
308  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pexp(a); }
309 };
310 template <typename Scalar>
311 struct functor_traits<scalar_exp_op<Scalar> > {
312  enum {
313  PacketAccess = packet_traits<Scalar>::HasExp,
314  // The following numbers are based on the AVX implementation.
315 #ifdef EIGEN_VECTORIZE_FMA
316  // Haswell can issue 2 add/mul/madd per cycle.
317  Cost =
318  (sizeof(Scalar) == 4
319  // float: 8 pmadd, 4 pmul, 2 padd/psub, 6 other
321  // double: 7 pmadd, 5 pmul, 3 padd/psub, 1 div, 13 other
324  scalar_div_cost<Scalar,packet_traits<Scalar>::HasDiv>::value))
325 #else
326  Cost =
327  (sizeof(Scalar) == 4
328  // float: 7 pmadd, 6 pmul, 4 padd/psub, 10 other
330  // double: 7 pmadd, 5 pmul, 3 padd/psub, 1 div, 13 other
333  scalar_div_cost<Scalar,packet_traits<Scalar>::HasDiv>::value))
334 #endif
335  };
336 };
337 
344 template<typename Scalar> struct scalar_expm1_op {
345  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::expm1(a); }
346  template <typename Packet>
347  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pexpm1(a); }
348 };
349 template <typename Scalar>
350 struct functor_traits<scalar_expm1_op<Scalar> > {
351  enum {
352  PacketAccess = packet_traits<Scalar>::HasExpm1,
353  Cost = functor_traits<scalar_exp_op<Scalar> >::Cost // TODO measure cost of expm1
354  };
355 };
356 
363 template<typename Scalar> struct scalar_log_op {
364  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::log(a); }
365  template <typename Packet>
366  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::plog(a); }
367 };
368 template <typename Scalar>
369 struct functor_traits<scalar_log_op<Scalar> > {
370  enum {
371  PacketAccess = packet_traits<Scalar>::HasLog,
372  Cost =
373  (PacketAccess
374  // The following numbers are based on the AVX implementation.
375 #ifdef EIGEN_VECTORIZE_FMA
376  // 8 pmadd, 6 pmul, 8 padd/psub, 16 other, can issue 2 add/mul/madd per cycle.
378 #else
379  // 8 pmadd, 6 pmul, 8 padd/psub, 20 other
381 #endif
382  // Measured cost of std::log.
383  : sizeof(Scalar)==4 ? 40 : 85)
384  };
385 };
386 
393 template<typename Scalar> struct scalar_log1p_op {
394  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::log1p(a); }
395  template <typename Packet>
396  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::plog1p(a); }
397 };
398 template <typename Scalar>
399 struct functor_traits<scalar_log1p_op<Scalar> > {
400  enum {
401  PacketAccess = packet_traits<Scalar>::HasLog1p,
402  Cost = functor_traits<scalar_log_op<Scalar> >::Cost // TODO measure cost of log1p
403  };
404 };
405 
412 template<typename Scalar> struct scalar_log10_op {
413  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { EIGEN_USING_STD(log10) return log10(a); }
414  template <typename Packet>
415  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::plog10(a); }
416 };
417 template<typename Scalar>
418 struct functor_traits<scalar_log10_op<Scalar> >
419 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasLog10 }; };
420 
427 template<typename Scalar> struct scalar_log2_op {
428  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return Scalar(EIGEN_LOG2E) * numext::log(a); }
429  template <typename Packet>
430  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::plog2(a); }
431 };
432 template<typename Scalar>
433 struct functor_traits<scalar_log2_op<Scalar> >
434 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasLog }; };
435 
440 template<typename Scalar> struct scalar_sqrt_op {
441  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::sqrt(a); }
442  template <typename Packet>
443  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::psqrt(a); }
444 };
445 template <typename Scalar>
446 struct functor_traits<scalar_sqrt_op<Scalar> > {
447  enum {
448 #if EIGEN_FAST_MATH
449  // The following numbers are based on the AVX implementation.
450  Cost = (sizeof(Scalar) == 8 ? 28
451  // 4 pmul, 1 pmadd, 3 other
454 #else
455  // The following numbers are based on min VSQRT throughput on Haswell.
456  Cost = (sizeof(Scalar) == 8 ? 28 : 14),
457 #endif
458  PacketAccess = packet_traits<Scalar>::HasSqrt
459  };
460 };
461 
462 // Boolean specialization to eliminate -Wimplicit-conversion-floating-point-to-bool warnings.
463 template<> struct scalar_sqrt_op<bool> {
464  EIGEN_DEPRECATED EIGEN_DEVICE_FUNC inline bool operator() (const bool& a) const { return a; }
465  template <typename Packet>
466  EIGEN_DEPRECATED EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return a; }
467 };
468 template <>
469 struct functor_traits<scalar_sqrt_op<bool> > {
470  enum { Cost = 1, PacketAccess = packet_traits<bool>::Vectorizable };
471 };
472 
477 template<typename Scalar> struct scalar_rsqrt_op {
478  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::rsqrt(a); }
479  template <typename Packet>
480  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::prsqrt(a); }
481 };
482 
483 template<typename Scalar>
484 struct functor_traits<scalar_rsqrt_op<Scalar> >
485 { enum {
486  Cost = 5 * NumTraits<Scalar>::MulCost,
487  PacketAccess = packet_traits<Scalar>::HasRsqrt
488  };
489 };
490 
495 template<typename Scalar> struct scalar_cos_op {
496  EIGEN_DEVICE_FUNC inline Scalar operator() (const Scalar& a) const { return numext::cos(a); }
497  template <typename Packet>
498  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pcos(a); }
499 };
500 template<typename Scalar>
501 struct functor_traits<scalar_cos_op<Scalar> >
502 {
503  enum {
504  Cost = 5 * NumTraits<Scalar>::MulCost,
505  PacketAccess = packet_traits<Scalar>::HasCos
506  };
507 };
508 
513 template<typename Scalar> struct scalar_sin_op {
514  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::sin(a); }
515  template <typename Packet>
516  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::psin(a); }
517 };
518 template<typename Scalar>
519 struct functor_traits<scalar_sin_op<Scalar> >
520 {
521  enum {
522  Cost = 5 * NumTraits<Scalar>::MulCost,
523  PacketAccess = packet_traits<Scalar>::HasSin
524  };
525 };
526 
527 
532 template<typename Scalar> struct scalar_tan_op {
533  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::tan(a); }
534  template <typename Packet>
535  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::ptan(a); }
536 };
537 template<typename Scalar>
538 struct functor_traits<scalar_tan_op<Scalar> >
539 {
540  enum {
541  Cost = 5 * NumTraits<Scalar>::MulCost,
542  PacketAccess = packet_traits<Scalar>::HasTan
543  };
544 };
545 
550 template<typename Scalar> struct scalar_acos_op {
551  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::acos(a); }
552  template <typename Packet>
553  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pacos(a); }
554 };
555 template<typename Scalar>
556 struct functor_traits<scalar_acos_op<Scalar> >
557 {
558  enum {
559  Cost = 5 * NumTraits<Scalar>::MulCost,
560  PacketAccess = packet_traits<Scalar>::HasACos
561  };
562 };
563 
568 template<typename Scalar> struct scalar_asin_op {
569  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::asin(a); }
570  template <typename Packet>
571  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pasin(a); }
572 };
573 template<typename Scalar>
574 struct functor_traits<scalar_asin_op<Scalar> >
575 {
576  enum {
577  Cost = 5 * NumTraits<Scalar>::MulCost,
578  PacketAccess = packet_traits<Scalar>::HasASin
579  };
580 };
581 
582 
587 template<typename Scalar> struct scalar_atan_op {
588  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::atan(a); }
589  template <typename Packet>
590  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::patan(a); }
591 };
592 template<typename Scalar>
593 struct functor_traits<scalar_atan_op<Scalar> >
594 {
595  enum {
596  Cost = 5 * NumTraits<Scalar>::MulCost,
597  PacketAccess = packet_traits<Scalar>::HasATan
598  };
599 };
600 
605 template <typename Scalar>
606 struct scalar_tanh_op {
607  EIGEN_DEVICE_FUNC inline const Scalar operator()(const Scalar& a) const { return numext::tanh(a); }
608  template <typename Packet>
609  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& x) const { return ptanh(x); }
610 };
611 
612 template <typename Scalar>
613 struct functor_traits<scalar_tanh_op<Scalar> > {
614  enum {
615  PacketAccess = packet_traits<Scalar>::HasTanh,
616  Cost = ( (EIGEN_FAST_MATH && is_same<Scalar,float>::value)
617 // The following numbers are based on the AVX implementation,
618 #ifdef EIGEN_VECTORIZE_FMA
619  // Haswell can issue 2 add/mul/madd per cycle.
620  // 9 pmadd, 2 pmul, 1 div, 2 other
623  scalar_div_cost<Scalar,packet_traits<Scalar>::HasDiv>::value)
624 #else
627  scalar_div_cost<Scalar,packet_traits<Scalar>::HasDiv>::value)
628 #endif
629  // This number assumes a naive implementation of tanh
632  2 * scalar_div_cost<Scalar,packet_traits<Scalar>::HasDiv>::value +
633  functor_traits<scalar_exp_op<Scalar> >::Cost))
634  };
635 };
636 
641 template <typename Scalar>
642 struct scalar_atanh_op {
643  EIGEN_DEVICE_FUNC inline const Scalar operator()(const Scalar& a) const { return numext::atanh(a); }
644  template <typename Packet>
645  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& x) const { return patanh(x); }
646 };
647 
648 template <typename Scalar>
649 struct functor_traits<scalar_atanh_op<Scalar> > {
650  enum {
651  Cost = 5 * NumTraits<Scalar>::MulCost,
652  PacketAccess = packet_traits<Scalar>::HasATanh
653  };
654 };
655 
660 template<typename Scalar> struct scalar_sinh_op {
661  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::sinh(a); }
662  template <typename Packet>
663  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::psinh(a); }
664 };
665 template<typename Scalar>
666 struct functor_traits<scalar_sinh_op<Scalar> >
667 {
668  enum {
669  Cost = 5 * NumTraits<Scalar>::MulCost,
670  PacketAccess = packet_traits<Scalar>::HasSinh
671  };
672 };
673 
678 template <typename Scalar>
679 struct scalar_asinh_op {
680  EIGEN_DEVICE_FUNC inline const Scalar operator()(const Scalar& a) const { return numext::asinh(a); }
681 };
682 
683 template <typename Scalar>
684 struct functor_traits<scalar_asinh_op<Scalar> > {
685  enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false };
686 };
687 
692 template<typename Scalar> struct scalar_cosh_op {
693  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const { return numext::cosh(a); }
694  template <typename Packet>
695  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pcosh(a); }
696 };
697 template<typename Scalar>
698 struct functor_traits<scalar_cosh_op<Scalar> >
699 {
700  enum {
701  Cost = 5 * NumTraits<Scalar>::MulCost,
702  PacketAccess = packet_traits<Scalar>::HasCosh
703  };
704 };
705 
710 template <typename Scalar>
711 struct scalar_acosh_op {
712  EIGEN_DEVICE_FUNC inline const Scalar operator()(const Scalar& a) const { return numext::acosh(a); }
713 };
714 
715 template <typename Scalar>
716 struct functor_traits<scalar_acosh_op<Scalar> > {
717  enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false };
718 };
719 
724 template<typename Scalar>
725 struct scalar_inverse_op {
726  EIGEN_DEVICE_FUNC inline Scalar operator() (const Scalar& a) const { return Scalar(1)/a; }
727  template<typename Packet>
728  EIGEN_DEVICE_FUNC inline const Packet packetOp(const Packet& a) const
729  { return internal::preciprocal(a); }
730 };
731 template <typename Scalar>
732 struct functor_traits<scalar_inverse_op<Scalar> > {
733  enum {
734  PacketAccess = packet_traits<Scalar>::HasDiv,
735  // If packet_traits<Scalar>::HasReciprocal then the Estimated cost is that
736  // of computing an approximation plus a single Newton-Raphson step, which
737  // consists of 1 pmul + 1 pmadd.
738  Cost = (packet_traits<Scalar>::HasReciprocal
740  : scalar_div_cost<Scalar, PacketAccess>::value)
741  };
742 };
743 
748 template<typename Scalar>
749 struct scalar_square_op {
750  EIGEN_DEVICE_FUNC inline Scalar operator() (const Scalar& a) const { return a*a; }
751  template<typename Packet>
752  EIGEN_DEVICE_FUNC inline const Packet packetOp(const Packet& a) const
753  { return internal::pmul(a,a); }
754 };
755 template<typename Scalar>
756 struct functor_traits<scalar_square_op<Scalar> >
757 { enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasMul }; };
758 
759 // Boolean specialization to avoid -Wint-in-bool-context warnings on GCC.
760 template<>
761 struct scalar_square_op<bool> {
762  EIGEN_DEPRECATED EIGEN_DEVICE_FUNC inline bool operator() (const bool& a) const { return a; }
763  template<typename Packet>
764  EIGEN_DEPRECATED EIGEN_DEVICE_FUNC inline const Packet packetOp(const Packet& a) const
765  { return a; }
766 };
767 template<>
768 struct functor_traits<scalar_square_op<bool> >
769 { enum { Cost = 0, PacketAccess = packet_traits<bool>::Vectorizable }; };
770 
775 template<typename Scalar>
776 struct scalar_cube_op {
777  EIGEN_DEVICE_FUNC inline Scalar operator() (const Scalar& a) const { return a*a*a; }
778  template<typename Packet>
779  EIGEN_DEVICE_FUNC inline const Packet packetOp(const Packet& a) const
780  { return internal::pmul(a,pmul(a,a)); }
781 };
782 template<typename Scalar>
783 struct functor_traits<scalar_cube_op<Scalar> >
784 { enum { Cost = 2*NumTraits<Scalar>::MulCost, PacketAccess = packet_traits<Scalar>::HasMul }; };
785 
786 // Boolean specialization to avoid -Wint-in-bool-context warnings on GCC.
787 template<>
788 struct scalar_cube_op<bool> {
789  EIGEN_DEPRECATED EIGEN_DEVICE_FUNC inline bool operator() (const bool& a) const { return a; }
790  template<typename Packet>
791  EIGEN_DEPRECATED EIGEN_DEVICE_FUNC inline const Packet packetOp(const Packet& a) const
792  { return a; }
793 };
794 template<>
795 struct functor_traits<scalar_cube_op<bool> >
796 { enum { Cost = 0, PacketAccess = packet_traits<bool>::Vectorizable }; };
797 
802 template<typename Scalar> struct scalar_round_op {
803  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return numext::round(a); }
804  template <typename Packet>
805  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pround(a); }
806 };
807 template<typename Scalar>
808 struct functor_traits<scalar_round_op<Scalar> >
809 {
810  enum {
812  PacketAccess = packet_traits<Scalar>::HasRound || NumTraits<Scalar>::IsInteger
813  };
814 };
815 
820 template<typename Scalar> struct scalar_floor_op {
821  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return numext::floor(a); }
822  template <typename Packet>
823  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pfloor(a); }
824 };
825 template<typename Scalar>
826 struct functor_traits<scalar_floor_op<Scalar> >
827 {
828  enum {
830  PacketAccess = packet_traits<Scalar>::HasFloor || NumTraits<Scalar>::IsInteger
831  };
832 };
833 
838 template<typename Scalar> struct scalar_rint_op {
839  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return numext::rint(a); }
840  template <typename Packet>
841  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::print(a); }
842 };
843 template<typename Scalar>
844 struct functor_traits<scalar_rint_op<Scalar> >
845 {
846  enum {
848  PacketAccess = packet_traits<Scalar>::HasRint || NumTraits<Scalar>::IsInteger
849  };
850 };
851 
856 template<typename Scalar> struct scalar_ceil_op {
857  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const { return numext::ceil(a); }
858  template <typename Packet>
859  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const { return internal::pceil(a); }
860 };
861 template<typename Scalar>
862 struct functor_traits<scalar_ceil_op<Scalar> >
863 {
864  enum {
866  PacketAccess = packet_traits<Scalar>::HasCeil || NumTraits<Scalar>::IsInteger
867  };
868 };
869 
874 template<typename Scalar, bool UseTypedPredicate=false>
875 struct scalar_isnan_op {
876  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator() (const Scalar& a) const {
877 #if defined(SYCL_DEVICE_ONLY)
878  return numext::isnan(a);
879 #else
881 #endif
882  }
883 };
884 
885 
886 template<typename Scalar>
887 struct scalar_isnan_op<Scalar, true> {
888  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator() (const Scalar& a) const {
889 #if defined(SYCL_DEVICE_ONLY)
890  return (numext::isnan(a) ? ptrue(a) : pzero(a));
891 #else
892  return (numext::isnan EIGEN_NOT_A_MACRO (a) ? ptrue(a) : pzero(a));
893 #endif
894  }
895  template <typename Packet>
896  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const {
897  return pisnan(a);
898  }
899 };
900 
901 template<typename Scalar, bool UseTypedPredicate>
902 struct functor_traits<scalar_isnan_op<Scalar, UseTypedPredicate> >
903 {
904  enum {
906  PacketAccess = packet_traits<Scalar>::HasCmp && UseTypedPredicate
907  };
908 };
909 
914 template<typename Scalar> struct scalar_isinf_op {
915  typedef bool result_type;
916  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const {
917 #if defined(SYCL_DEVICE_ONLY)
918  return numext::isinf(a);
919 #else
920  return (numext::isinf)(a);
921 #endif
922  }
923 };
924 template<typename Scalar>
925 struct functor_traits<scalar_isinf_op<Scalar> >
926 {
927  enum {
929  PacketAccess = false
930  };
931 };
932 
937 template<typename Scalar> struct scalar_isfinite_op {
938  typedef bool result_type;
939  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator() (const Scalar& a) const {
940 #if defined(SYCL_DEVICE_ONLY)
941  return numext::isfinite(a);
942 #else
943  return (numext::isfinite)(a);
944 #endif
945  }
946 };
947 template<typename Scalar>
948 struct functor_traits<scalar_isfinite_op<Scalar> >
949 {
950  enum {
952  PacketAccess = false
953  };
954 };
955 
961 template <typename Scalar>
962 struct scalar_boolean_not_op {
963  using result_type = Scalar;
964  // `false` any value `a` that satisfies `a == Scalar(0)`
965  // `true` is the complement of `false`
966  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const {
967  return a == Scalar(0) ? Scalar(1) : Scalar(0);
968  }
969  template <typename Packet>
970  EIGEN_STRONG_INLINE Packet packetOp(const Packet& a) const {
971  const Packet cst_one = pset1<Packet>(Scalar(1));
972  Packet not_a = pcmp_eq(a, pzero(a));
973  return pand(not_a, cst_one);
974  }
975 };
976 template <typename Scalar>
977 struct functor_traits<scalar_boolean_not_op<Scalar>> {
978  enum { Cost = NumTraits<Scalar>::AddCost, PacketAccess = packet_traits<Scalar>::HasCmp };
979 };
980 
981 template <typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
982 struct bitwise_unary_impl {
983  static constexpr size_t Size = sizeof(Scalar);
984  using uint_t = typename numext::get_integer_by_size<Size>::unsigned_type;
985  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_not(const Scalar& a) {
986  uint_t a_as_uint = numext::bit_cast<uint_t, Scalar>(a);
987  uint_t result = ~a_as_uint;
988  return numext::bit_cast<Scalar, uint_t>(result);
989  }
990 };
991 
992 template <typename Scalar>
993 struct bitwise_unary_impl<Scalar, true> {
994  using Real = typename NumTraits<Scalar>::Real;
995  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run_not(const Scalar& a) {
996  Real real_result = bitwise_unary_impl<Real>::run_not(numext::real(a));
997  Real imag_result = bitwise_unary_impl<Real>::run_not(numext::imag(a));
998  return Scalar(real_result, imag_result);
999  }
1000 };
1001 
1007 template <typename Scalar>
1008 struct scalar_bitwise_not_op {
1009  EIGEN_STATIC_ASSERT(!NumTraits<Scalar>::RequireInitialization, BITWISE OPERATIONS MAY ONLY BE PERFORMED ON PLAIN DATA TYPES)
1010  EIGEN_STATIC_ASSERT((!internal::is_same<Scalar, bool>::value), DONT USE BITWISE OPS ON BOOLEAN TYPES)
1011  using result_type = Scalar;
1012  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const {
1013  return bitwise_unary_impl<Scalar>::run_not(a);
1014  }
1015  template <typename Packet>
1016  EIGEN_STRONG_INLINE Packet packetOp(const Packet& a) const {
1017  return pandnot(ptrue(a), a);
1018  }
1019 };
1020 template <typename Scalar>
1021 struct functor_traits<scalar_bitwise_not_op<Scalar>> {
1022  enum { Cost = NumTraits<Scalar>::AddCost, PacketAccess = true };
1023 };
1024 
1029 template<typename Scalar>
1030 struct scalar_sign_op {
1031  EIGEN_DEVICE_FUNC inline const Scalar operator() (const Scalar& a) const
1032  {
1033  return numext::sign(a);
1034  }
1035 
1036  template <typename Packet>
1037  EIGEN_DEVICE_FUNC inline Packet packetOp(const Packet& a) const {
1038  return internal::psign(a);
1039  }
1040 };
1041 
1042 template<typename Scalar>
1043 struct functor_traits<scalar_sign_op<Scalar> >
1044 { enum {
1045  Cost =
1047  ? ( 8*NumTraits<Scalar>::MulCost ) // roughly
1049  PacketAccess = packet_traits<Scalar>::HasSign && packet_traits<Scalar>::Vectorizable
1050  };
1051 };
1052 
1057 template <typename T>
1058 struct scalar_logistic_op {
1059  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T operator()(const T& x) const {
1060  return packetOp(x);
1061  }
1062 
1063  template <typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1064  Packet packetOp(const Packet& x) const {
1065  const Packet one = pset1<Packet>(T(1));
1066  const Packet inf = pset1<Packet>(NumTraits<T>::infinity());
1067  const Packet e = pexp(x);
1068  const Packet inf_mask = pcmp_eq(e, inf);
1069  return pselect(inf_mask, one, pdiv(e, padd(one, e)));
1070  }
1071 };
1072 
1073 // TODO(rmlarsen): Enable the following on host when integer_packet is defined
1074 // for the relevant packet types.
1075 #ifdef EIGEN_GPU_CC
1076 
1092 template <>
1093 struct scalar_logistic_op<float> {
1094  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float operator()(const float& x) const {
1095  // Truncate at the first point where the interpolant is exactly one.
1096  const float cst_exp_hi = 16.6355324f;
1097  const float e = numext::exp(numext::mini(x, cst_exp_hi));
1098  return e / (1.0f + e);
1099  }
1100 
1101  template <typename Packet>
1102  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet
1103  packetOp(const Packet& _x) const {
1104  const Packet cst_zero = pset1<Packet>(0.0f);
1105  const Packet cst_one = pset1<Packet>(1.0f);
1106  const Packet cst_half = pset1<Packet>(0.5f);
1107  // Truncate at the first point where the interpolant is exactly one.
1108  const Packet cst_exp_hi = pset1<Packet>(16.6355324f);
1109  const Packet cst_exp_lo = pset1<Packet>(-104.f);
1110 
1111  // Clamp x to the non-trivial range where S(x). Outside this
1112  // interval the correctly rounded value of S(x) is either zero
1113  // or one.
1114  Packet zero_mask = pcmp_lt(_x, cst_exp_lo);
1115  Packet x = pmin(_x, cst_exp_hi);
1116 
1117  // 1. Multiplicative range reduction:
1118  // Reduce the range of x by a factor of 2. This avoids having
1119  // to compute exp(x) accurately where the result is a denormalized
1120  // value.
1121  x = pmul(x, cst_half);
1122 
1123  // 2. Subtractive range reduction:
1124  // Express exp(x) as exp(m*ln(2) + r) = 2^m*exp(r), start by extracting
1125  // m = floor(x/ln(2) + 0.5), such that x = m*ln(2) + r.
1126  const Packet cst_cephes_LOG2EF = pset1<Packet>(1.44269504088896341f);
1127  Packet m = pfloor(pmadd(x, cst_cephes_LOG2EF, cst_half));
1128  // Get r = x - m*ln(2). We use a trick from Cephes where the term
1129  // m*ln(2) is subtracted out in two parts, m*C1+m*C2 = m*ln(2),
1130  // to avoid accumulating truncation errors.
1131  const Packet cst_cephes_exp_C1 = pset1<Packet>(-0.693359375f);
1132  const Packet cst_cephes_exp_C2 = pset1<Packet>(2.12194440e-4f);
1133  Packet r = pmadd(m, cst_cephes_exp_C1, x);
1134  r = pmadd(m, cst_cephes_exp_C2, r);
1135 
1136  // 3. Compute an approximation to exp(r) using a degree 5 minimax polynomial.
1137  // We compute even and odd terms separately to increase instruction level
1138  // parallelism.
1139  Packet r2 = pmul(r, r);
1140  const Packet cst_p2 = pset1<Packet>(0.49999141693115234375f);
1141  const Packet cst_p3 = pset1<Packet>(0.16666877269744873046875f);
1142  const Packet cst_p4 = pset1<Packet>(4.1898667812347412109375e-2f);
1143  const Packet cst_p5 = pset1<Packet>(8.33471305668354034423828125e-3f);
1144 
1145  const Packet p_even = pmadd(r2, cst_p4, cst_p2);
1146  const Packet p_odd = pmadd(r2, cst_p5, cst_p3);
1147  const Packet p_low = padd(r, cst_one);
1148  Packet p = pmadd(r, p_odd, p_even);
1149  p = pmadd(r2, p, p_low);
1150 
1151  // 4. Undo subtractive range reduction exp(m*ln(2) + r) = 2^m * exp(r).
1152  Packet e = pldexp_fast_impl<Packet>::run(p, m);
1153 
1154  // 5. Undo multiplicative range reduction by using exp(r) = exp(r/2)^2.
1155  e = pmul(e, e);
1156 
1157  // Return exp(x) / (1 + exp(x))
1158  return pselect(zero_mask, cst_zero, pdiv(e, padd(cst_one, e)));
1159  }
1160 };
1161 #endif // #ifndef EIGEN_GPU_COMPILE_PHASE
1162 
1163 
1164 template <typename T>
1165 struct functor_traits<scalar_logistic_op<T> > {
1166  enum {
1167  // The cost estimate for float here here is for the common(?) case where
1168  // all arguments are greater than -9.
1169  Cost = scalar_div_cost<T, packet_traits<T>::HasDiv>::value +
1170  (internal::is_same<T, float>::value
1172  : NumTraits<T>::AddCost * 2 +
1173  functor_traits<scalar_exp_op<T> >::Cost),
1174  PacketAccess =
1175  packet_traits<T>::HasAdd && packet_traits<T>::HasDiv &&
1176  (internal::is_same<T, float>::value
1177  ? packet_traits<T>::HasMul && packet_traits<T>::HasMax &&
1178  packet_traits<T>::HasMin
1179  : packet_traits<T>::HasNegate && packet_traits<T>::HasExp)
1180  };
1181 };
1182 
1183 template <typename Scalar, typename ExponentScalar,
1184  bool IsBaseInteger = NumTraits<Scalar>::IsInteger,
1185  bool IsExponentInteger = NumTraits<ExponentScalar>::IsInteger,
1186  bool IsBaseComplex = NumTraits<Scalar>::IsComplex,
1187  bool IsExponentComplex = NumTraits<ExponentScalar>::IsComplex>
1188 struct scalar_unary_pow_op {
1189  typedef typename internal::promote_scalar_arg<
1190  Scalar, ExponentScalar,
1191  internal::has_ReturnType<ScalarBinaryOpTraits<Scalar,ExponentScalar,scalar_unary_pow_op> >::value>::type PromotedExponent;
1192  typedef typename ScalarBinaryOpTraits<Scalar, PromotedExponent, scalar_unary_pow_op>::ReturnType result_type;
1193  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE scalar_unary_pow_op(const ExponentScalar& exponent) : m_exponent(exponent) {}
1194  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const Scalar& a) const {
1196  return static_cast<result_type>(pow(a, m_exponent));
1197  }
1198 
1199  private:
1200  const ExponentScalar m_exponent;
1201  scalar_unary_pow_op() {}
1202 };
1203 
1204 template <typename T>
1205 constexpr int exponent_digits() {
1206  return CHAR_BIT * sizeof(T) - NumTraits<T>::digits() - NumTraits<T>::IsSigned;
1207 }
1208 
1209 template<typename From, typename To>
1210 struct is_floating_exactly_representable {
1211  // TODO(rmlarsen): Add radix to NumTraits and enable this check.
1212  // (NumTraits<To>::radix == NumTraits<From>::radix) &&
1213  static constexpr bool value = (exponent_digits<To>() >= exponent_digits<From>() &&
1215 };
1216 
1217 
1218 // Specialization for real, non-integer types, non-complex types.
1219 template <typename Scalar, typename ExponentScalar>
1220 struct scalar_unary_pow_op<Scalar, ExponentScalar, false, false, false, false> {
1221  template <bool IsExactlyRepresentable = is_floating_exactly_representable<ExponentScalar, Scalar>::value>
1222  std::enable_if_t<IsExactlyRepresentable, void> check_is_representable() const {}
1223 
1224  // Issue a deprecation warning if we do a narrowing conversion on the exponent.
1225  template <bool IsExactlyRepresentable = is_floating_exactly_representable<ExponentScalar, Scalar>::value>
1226  EIGEN_DEPRECATED std::enable_if_t<!IsExactlyRepresentable, void> check_is_representable() const {}
1227 
1228  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1229  scalar_unary_pow_op(const ExponentScalar& exponent) : m_exponent(static_cast<Scalar>(exponent)) {
1230  check_is_representable();
1231  }
1232 
1233  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const {
1235  return static_cast<Scalar>(pow(a, m_exponent));
1236  }
1237  template <typename Packet>
1238  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet& a) const {
1239  return unary_pow_impl<Packet, Scalar>::run(a, m_exponent);
1240  }
1241 
1242  private:
1243  const Scalar m_exponent;
1244  scalar_unary_pow_op() {}
1245 };
1246 
1247 template <typename Scalar, typename ExponentScalar, bool BaseIsInteger>
1248 struct scalar_unary_pow_op<Scalar, ExponentScalar, BaseIsInteger, true, false, false> {
1249  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE scalar_unary_pow_op(const ExponentScalar& exponent) : m_exponent(exponent) {}
1250  // TODO: error handling logic for complex^real_integer
1251  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const {
1252  return unary_pow_impl<Scalar, ExponentScalar>::run(a, m_exponent);
1253  }
1254  template <typename Packet>
1255  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet& a) const {
1256  return unary_pow_impl<Packet, ExponentScalar>::run(a, m_exponent);
1257  }
1258 
1259  private:
1260  const ExponentScalar m_exponent;
1261  scalar_unary_pow_op() {}
1262 };
1263 
1264 template <typename Scalar, typename ExponentScalar>
1265 struct functor_traits<scalar_unary_pow_op<Scalar, ExponentScalar>> {
1266  enum {
1267  GenPacketAccess = functor_traits<scalar_pow_op<Scalar, ExponentScalar>>::PacketAccess,
1268  IntPacketAccess = !NumTraits<Scalar>::IsComplex && packet_traits<Scalar>::HasMul && (packet_traits<Scalar>::HasDiv || NumTraits<Scalar>::IsInteger) && packet_traits<Scalar>::HasCmp,
1269  PacketAccess = NumTraits<ExponentScalar>::IsInteger ? IntPacketAccess : (IntPacketAccess && GenPacketAccess),
1270  Cost = functor_traits<scalar_pow_op<Scalar, ExponentScalar>>::Cost
1271  };
1272 };
1273 
1274 } // end namespace internal
1275 
1276 } // end namespace Eigen
1277 
1278 #endif // EIGEN_FUNCTORS_H
Matrix3f m
const SignReturnType sign() const
const ArgReturnType arg() const
const Log1pReturnType log1p() const
const Expm1ReturnType expm1() const
const ImagReturnType imag() const
RealReturnType real() const
Array< double, 1, 3 > e(1./3., 0.5, 2.)
IndexedView_or_Block operator()(const RowIndices &rowIndices, const ColIndices &colIndices)
#define EIGEN_DEPRECATED
Definition: Macros.h:923
#define EIGEN_USING_STD(FUNC)
Definition: Macros.h:1080
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:883
#define EIGEN_FAST_MATH
Definition: Macros.h:50
#define EIGEN_NOT_A_MACRO
Definition: Macros.h:804
#define EIGEN_LOG2E
Definition: MathFunctions.h:17
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
float * p
Eigen::Triplet< double > T
bfloat16 pow(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:626
Packet pmin(const Packet &a, const Packet &b)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pexpm1(const Packet &a)
Packet padd(const Packet &a, const Packet &b)
Packet8f pzero(const Packet8f &)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet plog10(const Packet &a)
Packet8h ptrue(const Packet8h &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet plog2(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet plog(const Packet &a)
Packet8h pandnot(const Packet8h &a, const Packet8h &b)
Packet4f pabs(const Packet4f &a)
Packet2cf pnegate(const Packet2cf &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pexp(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pcos(const Packet &a)
Packet4f pmadd(const Packet4f &a, const Packet4f &b, const Packet4f &c)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psin(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pacos(const Packet &a)
Packet2cf pcmp_eq(const Packet2cf &a, const Packet2cf &b)
Packet psign(const Packet &a)
Packet4f pselect(const Packet4f &mask, const Packet4f &a, const Packet4f &b)
Packet pmul(const Packet &a, const Packet &b)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet ptan(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pcosh(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pround(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet ptanh(const Packet &a)
Packet4f psqrt(const Packet4f &a)
Packet4f print(const Packet4f &a)
EIGEN_ALWAYS_INLINE Packet pcarg(const Packet &a)
Packet parg(const Packet &a)
Packet8h pand(const Packet8h &a, const Packet8h &b)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pceil(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet plog1p(const Packet &a)
Packet pdiv(const Packet &a, const Packet &b)
Packet preciprocal(const Packet &a)
Packet2cf pconj(const Packet2cf &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psinh(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pasin(const Packet &a)
Packet4i pcmp_lt(const Packet4i &a, const Packet4i &b)
Packet8f pisnan(const Packet8f &a)
constexpr int exponent_digits()
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet patanh(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet patan(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pfloor(const Packet &a)
Packet4f prsqrt(const Packet4f &a)
Scalar round(const Scalar &x)
EIGEN_ALWAYS_INLINE T cosh(const T &x)
EIGEN_ALWAYS_INLINE T tan(const T &x)
EIGEN_ALWAYS_INLINE bool() isinf(const Eigen::bfloat16 &h)
Definition: BFloat16.h:784
EIGEN_ALWAYS_INLINE T acosh(const T &x)
internal::add_const_on_value_type_t< EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) > imag_ref(const Scalar &x)
EIGEN_ALWAYS_INLINE T atan(const T &x)
EIGEN_ALWAYS_INLINE T atanh(const T &x)
bool abs2(bool x)
internal::add_const_on_value_type_t< EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) > real_ref(const Scalar &x)
EIGEN_ALWAYS_INLINE T sin(const T &x)
Scalar rint(const Scalar &x)
EIGEN_ALWAYS_INLINE T tanh(const T &x)
EIGEN_ALWAYS_INLINE T acos(const T &x)
EIGEN_ALWAYS_INLINE float sqrt(const float &x)
EIGEN_ALWAYS_INLINE T exp(const T &x)
EIGEN_ALWAYS_INLINE T sinh(const T &x)
Scalar() floor(const Scalar &x)
Scalar() ceil(const Scalar &x)
EIGEN_ALWAYS_INLINE T asinh(const T &x)
EIGEN_ALWAYS_INLINE bool() isnan(const Eigen::bfloat16 &h)
Definition: BFloat16.h:778
EIGEN_ALWAYS_INLINE bool() isfinite(const Eigen::bfloat16 &h)
Definition: BFloat16.h:790
EIGEN_ALWAYS_INLINE T asin(const T &x)
EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
EIGEN_ALWAYS_INLINE T cos(const T &x)
EIGEN_ALWAYS_INLINE std::enable_if_t< NumTraits< T >::IsSigned||NumTraits< T >::IsComplex, typename NumTraits< T >::Real > abs(const T &x)
EIGEN_ALWAYS_INLINE T rsqrt(const T &x)
EIGEN_ALWAYS_INLINE T log(const T &x)
: InteropHeaders
Definition: Core:139
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_log10_op< typename Derived::Scalar >, const Derived > log10(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_conjugate_op< typename Derived::Scalar >, const Derived > conj(const Eigen::ArrayBase< Derived > &x)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:231