IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
IsOddReg.h
Go to the documentation of this file.
1 // IsOddReg.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_ISODDREG_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_ISODDREG_H__
17 
21 #include <IPSDKUtil/InstructionSet/Arithmetic/detail/FloorReg.h>
28 
29 #include <boost/type_traits/is_integral.hpp>
30 
31 namespace ipsdk {
32 namespace simd {
33 namespace detail {
34 
37 
39 template <eInstructionSet::domain IS, typename T>
40 struct IsOddReg<IS, T, typename boost::enable_if<typename boost::is_integral<T>::type>::type>
41 {
42  static IPSDK_FORCEINLINE
44  act(const typename RegType<IS, T>::Type& in)
45  {
46  typename RegMaskType<IS, T>::Type out;
47  act(in, out);
48  return out;
49  }
50 
51  static IPSDK_FORCEINLINE
52  void
53  act(const typename RegType<IS, T>::Type& in,
54  typename RegMaskType<IS, T>::Type& out)
55  {
56  typedef typename RegType<IS, T>::Type Reg;
57 
58  Reg one, inAndOne, zero;
59  AssignReg<IS, T>::act(zero, 0);
60  AssignReg<IS, T>::act(one, 1);
61  BitwiseAndReg<IS, T>::act(in, one, inAndOne);
62  IsNotEqualReg<IS, T>::act(inAndOne, zero, out);
63  }
64 };
65 
66 template <eInstructionSet::domain IS>
67 struct IsOddReg<IS, ipReal32>
68 {
69  static IPSDK_FORCEINLINE
71  act(const typename RegType<IS, ipReal32>::Type& in)
72  {
74  act(in, out);
75  return out;
76  }
77 
78  static IPSDK_FORCEINLINE
79  void
80  act(const typename RegType<IS, ipReal32>::Type& in,
81  typename RegMaskType<IS, ipReal32>::Type& out)
82  {
83  typedef typename RegType<IS, ipReal32>::Type Reg;
84 
85  Reg one, inMinusOne, halfOne, halfInMinusOne, halfInMinusOneFloor;
87  SubReg<IS, ipReal32>::act(in, one, inMinusOne);
88  AssignReg<IS, ipReal32>::act(halfOne, 0.5f);
89  MulReg<IS, ipReal32>::act(inMinusOne, halfOne, halfInMinusOne);
90  FloorReg<IS, ipReal32>::act(halfInMinusOne, halfInMinusOneFloor);
91  IsEqualReg<IS, ipReal32>::act(halfInMinusOne, halfInMinusOneFloor, out);
92  }
93 };
94 
97 
98 } // end of namespace detail
99 } // end of namespace simd
100 } // end of namespace ipsdk
101 
102 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_SSE2_ISODDREG_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Definition: SubReg.h:39
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: IsNotEqualRegDecl.h:30
Definition: RegMaskType.h:29
Definition: RegType.h:29
Definition: BitwiseAndReg.h:30
Definition: AssignRegDecl.h:31
float ipReal32
Base types definition.
Definition: BaseTypes.h:56
template structure which is specialized to implement the isOdd function
Definition: IsOddReg.h:35