IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
IsEvenReg.h
Go to the documentation of this file.
1 // IsEvenReg.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_ISEVENREG_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_ISEVENREG_H__
17 
21 #include <IPSDKUtil/InstructionSet/Arithmetic/detail/FloorReg.h>
26 
27 #include <boost/type_traits/is_integral.hpp>
28 
29 namespace ipsdk {
30 namespace simd {
31 namespace detail {
32 
35 
37 template <eInstructionSet::domain IS, typename T>
38 struct IsEvenReg<IS, T, typename boost::enable_if<typename boost::is_integral<T>::type>::type>
39 {
40  static IPSDK_FORCEINLINE
42  act(const typename RegType<IS, T>::Type& in)
43  {
44  typename RegType<IS, T>::Type out;
45  act(in, out);
46  return out;
47  }
48 
49  static IPSDK_FORCEINLINE
50  void
51  act(const typename RegType<IS, T>::Type& in,
52  typename RegMaskType<IS, T>::Type& out)
53  {
54  typedef typename RegType<IS, T>::Type Reg;
55 
56  Reg one, inAndOne, zero;
57  AssignReg<IS, T>::act(zero, 0);
58  AssignReg<IS, T>::act(one, 1);
59  BitwiseAndReg<IS, T>::act(in, one, inAndOne);
60  IsEqualReg<IS, T>::act(inAndOne, zero, out);
61  }
62 };
63 
64 template <eInstructionSet::domain IS>
65 struct IsEvenReg<IS, ipReal32>
66 {
67  static IPSDK_FORCEINLINE
69  act(const typename RegType<IS, ipReal32>::Type& in)
70  {
72  act(in, out);
73  return out;
74  }
75 
76  static IPSDK_FORCEINLINE
77  void
78  act(const typename RegType<IS, ipReal32>::Type& in,
79  typename RegMaskType<IS, ipReal32>::Type& out)
80  {
81  typedef typename RegType<IS, ipReal32>::Type Reg;
82 
83  Reg halfOne, halfIn, halfInFloor;
84  AssignReg<IS, ipReal32>::act(halfOne, 0.5f);
85  MulReg<IS, ipReal32>::act(in, halfOne, halfIn);
86  FloorReg<IS, ipReal32>::act(halfIn, halfInFloor);
87  IsEqualReg<IS, ipReal32>::act(halfIn, halfInFloor, out);
88  }
89 };
90 
93 
94 } // end of namespace detail
95 } // end of namespace simd
96 } // end of namespace ipsdk
97 
98 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_ISEVENREG_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Definition: IsEqualRegDecl.h:35
IsEqualReg<eInstructionSet::domain instructionSet, typename T, typename Enable=void> structure...
template structure which is specialized to implement the computation of value rounded to closest even...
Definition: FloorReg.h:36
Definition: DataItemNodeHdrMacrosDetails.h:48
RegType class.
Definition of import/export macro for library.
Definition: MulReg.h:39
Definition: RegMaskType.h:29
template structure which is specialized to implement the isEven function
Definition: IsEvenReg.h:35
Definition: RegType.h:29
Definition: BitwiseAndReg.h:30
Definition: AssignRegDecl.h:31
float ipReal32
Base types definition.
Definition: BaseTypes.h:56