Kokkos Core Kernels Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Kokkos_Functional.hpp
00001 #ifndef KOKKOS_FUNCTIONAL_HPP
00002 #define KOKKOS_FUNCTIONAL_HPP
00003 
00004 #include <Kokkos_Macros.hpp>
00005 #include <impl/Kokkos_Functional_impl.hpp>
00006 
00007 namespace Kokkos {
00008 
00009 // These should work for most types
00010 
00011 template <typename T>
00012 struct pod_hash
00013 {
00014   typedef T argument_type;
00015   typedef T first_argument_type;
00016   typedef uint32_t second_argument_type;
00017   typedef uint32_t result_type;
00018 
00019   KOKKOS_FORCEINLINE_FUNCTION
00020   uint32_t operator()(T const & t) const
00021   { return Impl::MurmurHash3_x86_32( &t, sizeof(T), 0); }
00022 
00023   KOKKOS_FORCEINLINE_FUNCTION
00024   uint32_t operator()(T const & t, uint32_t seed) const
00025   { return Impl::MurmurHash3_x86_32( &t, sizeof(T), seed); }
00026 };
00027 
00028 template <typename T>
00029 struct pod_equal_to
00030 {
00031   typedef T first_argument_type;
00032   typedef T second_argument_type;
00033   typedef bool result_type;
00034 
00035   KOKKOS_FORCEINLINE_FUNCTION
00036   bool operator()(T const & a, T const & b) const
00037   { return Impl::bitwise_equal(&a,&b); }
00038 };
00039 
00040 template <typename T>
00041 struct pod_not_equal_to
00042 {
00043   typedef T first_argument_type;
00044   typedef T second_argument_type;
00045   typedef bool result_type;
00046 
00047   KOKKOS_FORCEINLINE_FUNCTION
00048   bool operator()(T const & a, T const & b) const
00049   { return !Impl::bitwise_equal(&a,&b); }
00050 };
00051 
00052 template <typename T>
00053 struct equal_to
00054 {
00055   typedef T first_argument_type;
00056   typedef T second_argument_type;
00057   typedef bool result_type;
00058 
00059   KOKKOS_FORCEINLINE_FUNCTION
00060   bool operator()(T const & a, T const & b) const
00061   { return a == b; }
00062 };
00063 
00064 template <typename T>
00065 struct not_equal_to
00066 {
00067   typedef T first_argument_type;
00068   typedef T second_argument_type;
00069   typedef bool result_type;
00070 
00071   KOKKOS_FORCEINLINE_FUNCTION
00072   bool operator()(T const & a, T const & b) const
00073   { return a != b; }
00074 };
00075 
00076 
00077 template <typename T>
00078 struct greater
00079 {
00080   typedef T first_argument_type;
00081   typedef T second_argument_type;
00082   typedef bool result_type;
00083 
00084   KOKKOS_FORCEINLINE_FUNCTION
00085   bool operator()(T const & a, T const & b) const
00086   { return a > b; }
00087 };
00088 
00089 
00090 template <typename T>
00091 struct less
00092 {
00093   typedef T first_argument_type;
00094   typedef T second_argument_type;
00095   typedef bool result_type;
00096 
00097   KOKKOS_FORCEINLINE_FUNCTION
00098   bool operator()(T const & a, T const & b) const
00099   { return a < b; }
00100 };
00101 
00102 template <typename T>
00103 struct greater_equal
00104 {
00105   typedef T first_argument_type;
00106   typedef T second_argument_type;
00107   typedef bool result_type;
00108 
00109   KOKKOS_FORCEINLINE_FUNCTION
00110   bool operator()(T const & a, T const & b) const
00111   { return a >= b; }
00112 };
00113 
00114 
00115 template <typename T>
00116 struct less_equal
00117 {
00118   typedef T first_argument_type;
00119   typedef T second_argument_type;
00120   typedef bool result_type;
00121 
00122   KOKKOS_FORCEINLINE_FUNCTION
00123   bool operator()(T const & a, T const & b) const
00124   { return a <= b; }
00125 };
00126 
00127 } // namespace Kokkos
00128 
00129 
00130 #endif //KOKKOS_FUNCTIONAL_HPP
00131 
00132 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends