Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
StlFunctors.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2008-2010 Gael Guennebaud <[email protected]>
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_STL_FUNCTORS_H
11#define EIGEN_STL_FUNCTORS_H
12
13// IWYU pragma: private
14#include "../InternalHeaderCheck.h"
15
16namespace Eigen {
17namespace internal {
18
19// default functor traits for STL functors:
20
21template <typename T>
22struct functor_traits<std::multiplies<T> > {
23 enum { Cost = NumTraits<T>::MulCost, PacketAccess = false };
24};
25
26template <typename T>
27struct functor_traits<std::divides<T> > {
28 enum { Cost = NumTraits<T>::MulCost, PacketAccess = false };
29};
30
31template <typename T>
32struct functor_traits<std::plus<T> > {
33 enum { Cost = NumTraits<T>::AddCost, PacketAccess = false };
34};
35
36template <typename T>
37struct functor_traits<std::minus<T> > {
38 enum { Cost = NumTraits<T>::AddCost, PacketAccess = false };
39};
40
41template <typename T>
42struct functor_traits<std::negate<T> > {
43 enum { Cost = NumTraits<T>::AddCost, PacketAccess = false };
44};
45
46template <typename T>
47struct functor_traits<std::logical_or<T> > {
48 enum { Cost = 1, PacketAccess = false };
49};
50
51template <typename T>
52struct functor_traits<std::logical_and<T> > {
53 enum { Cost = 1, PacketAccess = false };
54};
55
56template <typename T>
57struct functor_traits<std::logical_not<T> > {
58 enum { Cost = 1, PacketAccess = false };
59};
60
61template <typename T>
62struct functor_traits<std::greater<T> > {
63 enum { Cost = 1, PacketAccess = false };
64};
65
66template <typename T>
67struct functor_traits<std::less<T> > {
68 enum { Cost = 1, PacketAccess = false };
69};
70
71template <typename T>
72struct functor_traits<std::greater_equal<T> > {
73 enum { Cost = 1, PacketAccess = false };
74};
75
76template <typename T>
77struct functor_traits<std::less_equal<T> > {
78 enum { Cost = 1, PacketAccess = false };
79};
80
81template <typename T>
82struct functor_traits<std::equal_to<T> > {
83 enum { Cost = 1, PacketAccess = false };
84};
85
86template <typename T>
87struct functor_traits<std::not_equal_to<T> > {
88 enum { Cost = 1, PacketAccess = false };
89};
90
91#if (EIGEN_COMP_CXXVER < 17)
92// std::unary_negate is deprecated since c++17 and will be removed in c++20
93template <typename T>
94struct functor_traits<std::unary_negate<T> > {
95 enum { Cost = 1 + functor_traits<T>::Cost, PacketAccess = false };
96};
97
98// std::binary_negate is deprecated since c++17 and will be removed in c++20
99template <typename T>
100struct functor_traits<std::binary_negate<T> > {
101 enum { Cost = 1 + functor_traits<T>::Cost, PacketAccess = false };
102};
103#endif
104
105#ifdef EIGEN_STDEXT_SUPPORT
106
107template <typename T0, typename T1>
108struct functor_traits<std::project1st<T0, T1> > {
109 enum { Cost = 0, PacketAccess = false };
110};
111
112template <typename T0, typename T1>
113struct functor_traits<std::project2nd<T0, T1> > {
114 enum { Cost = 0, PacketAccess = false };
115};
116
117template <typename T0, typename T1>
118struct functor_traits<std::select2nd<std::pair<T0, T1> > > {
119 enum { Cost = 0, PacketAccess = false };
120};
121
122template <typename T0, typename T1>
123struct functor_traits<std::select1st<std::pair<T0, T1> > > {
124 enum { Cost = 0, PacketAccess = false };
125};
126
127template <typename T0, typename T1>
128struct functor_traits<std::unary_compose<T0, T1> > {
129 enum { Cost = functor_traits<T0>::Cost + functor_traits<T1>::Cost, PacketAccess = false };
130};
131
132template <typename T0, typename T1, typename T2>
133struct functor_traits<std::binary_compose<T0, T1, T2> > {
134 enum { Cost = functor_traits<T0>::Cost + functor_traits<T1>::Cost + functor_traits<T2>::Cost, PacketAccess = false };
135};
136
137#endif // EIGEN_STDEXT_SUPPORT
138
139// allow to add new functors and specializations of functor_traits from outside Eigen.
140// this macro is really needed because functor_traits must be specialized after it is declared but before it is used...
141#ifdef EIGEN_FUNCTORS_PLUGIN
142#include EIGEN_FUNCTORS_PLUGIN
143#endif
144
145} // end namespace internal
146
147} // end namespace Eigen
148
149#endif // EIGEN_STL_FUNCTORS_H
Namespace containing all symbols from the Eigen library.
Definition Core:137