IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
BitwiseSelectReg.h
Go to the documentation of this file.
1 // BitwiseSelectReg.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_LOGICAL_DETAIL_STD_BITWISESELECTREG_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_LOGICAL_DETAIL_STD_BITWISESELECTREG_H__
17 
20 
21 namespace ipsdk {
22 namespace simd {
23 namespace detail {
24 
27 
28 template <typename T>
30 {
31  static IPSDK_FORCEINLINE
32  T
33  act(const T& mask, const T& in1, const T& in2)
34  {
35  return (mask & in1) | ((~mask) & in2);
36  }
37 
38  static IPSDK_FORCEINLINE
39  void
40  act(const T& mask, const T& in1, const T& in2, T& out)
41  {
42  out = (mask & in1) | ((~mask) & in2);
43  }
44 };
45 
46 template <>
48 {
49  static IPSDK_FORCEINLINE
50  ipReal32
51  act(const ipReal32& mask, const ipReal32& in1, const ipReal32& in2)
52  {
53  const ipInt32 nMask = *reinterpret_cast<const ipInt32*>(&mask);
54  const ipInt32 nIn1 = *reinterpret_cast<const ipInt32*>(&in1);
55  const ipInt32 nIn2 = *reinterpret_cast<const ipInt32*>(&in2);
56  const ipInt32 nOut = (nMask & nIn1) | ((~nMask) & nIn2);
57  return *reinterpret_cast<const ipReal32*>(&nOut);
58  }
59 
60  static IPSDK_FORCEINLINE
61  void
62  act(const ipReal32& mask, const ipReal32& in1, const ipReal32& in2,
63  ipReal32& out)
64  {
65  const ipInt32 nMask = *reinterpret_cast<const ipInt32*>(&mask);
66  const ipInt32 nIn1 = *reinterpret_cast<const ipInt32*>(&in1);
67  const ipInt32 nIn2 = *reinterpret_cast<const ipInt32*>(&in2);
68  const ipInt32 nOut = (nMask & nIn1) | ((~nMask) & nIn2);
69  out = *reinterpret_cast<const ipReal32*>(&nOut);
70  }
71 };
72 
73 template <>
75 {
76  static IPSDK_FORCEINLINE
77  ipReal64
78  act(const ipReal64& mask, const ipReal64& in1, const ipReal64& in2)
79  {
80  const ipInt64 nMask = *reinterpret_cast<const ipInt64*>(&mask);
81  const ipInt64 nIn1 = *reinterpret_cast<const ipInt64*>(&in1);
82  const ipInt64 nIn2 = *reinterpret_cast<const ipInt64*>(&in2);
83  const ipInt64 nOut = (nMask & nIn1) | ((~nMask) & nIn2);
84  return *reinterpret_cast<const ipReal64*>(&nOut);
85  }
86 
87  static IPSDK_FORCEINLINE
88  void
89  act(const ipReal64& mask, const ipReal64& in1, const ipReal64& in2,
90  ipReal64& out)
91  {
92  const ipInt64 nMask = *reinterpret_cast<const ipInt64*>(&mask);
93  const ipInt64 nIn1 = *reinterpret_cast<const ipInt64*>(&in1);
94  const ipInt64 nIn2 = *reinterpret_cast<const ipInt64*>(&in2);
95  const ipInt64 nOut = (nMask & nIn1) | ((~nMask) & nIn2);
96  out = *reinterpret_cast<const ipReal64*>(&nOut);
97  }
98 };
99 
102 
103 } // end of namespace detail
104 } // end of namespace simd
105 } // end of namespace ipsdk
106 
107 #endif // __IPSDKUTIL_INSTRUCTIONSET_LOGICAL_DETAIL_STD_BITWISESELECTREG_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
int32_t ipInt32
Base types definition.
Definition: BaseTypes.h:52
Definition: BitwiseSelectReg.h:30
eInstructionSet
Enumerate for processor instruction set description.
Definition: InstructionSetTypes.h:31
Definition of import/export macro for library.
int64_t ipInt64
Base types definition.
Definition: BaseTypes.h:54
compiler optimisations only
Definition: InstructionSetTypes.h:34
float ipReal32
Base types definition.
Definition: BaseTypes.h:56