IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
TruncateReg.h
Go to the documentation of this file.
1 // TruncateReg.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_TRUNCATEREG_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_TRUNCATEREG_H__
17 
22 #include <IPSDKUtil/InstructionSet/Arithmetic/detail/AbsReg.h>
23 #include <IPSDKUtil/InstructionSet/Arithmetic/detail/FloorReg.h>
26 
27 namespace ipsdk {
28 namespace simd {
29 namespace detail {
30 
33 
35 template <eInstructionSet::domain IS>
36 struct TruncateReg<IS, ipReal32>
37 {
38  static IPSDK_FORCEINLINE
40  act(const typename RegType<IS, ipReal32>::Type& in)
41  {
42  typename RegType<IS, ipReal32>::Type out;
43  act(in, out);
44  return out;
45  }
46 
47  static IPSDK_FORCEINLINE
48  void
49  act(const typename RegType<IS, ipReal32>::Type& in,
50  typename RegType<IS, ipReal32>::Type& out)
51  {
52  typedef typename RegType<IS, ipReal32>::Type Reg;
53  typename RegType<IS, ipUInt32>::Type bitOfSignUI;
54  AssignReg<IS, ipUInt32>::act(bitOfSignUI, 0x80000000);
55  Reg bitOfSign;
56  BitwiseCastReg<IS, ipUInt32, ipReal32>::act(bitOfSignUI, bitOfSign);
57  BitwiseAndReg<IS, ipReal32>::act(bitOfSign, in, bitOfSign);
58  Reg res;
61  BitwiseOrReg<IS, ipReal32>::act(res, bitOfSign, out);
62  }
63 };
64 
66 template <eInstructionSet::domain IS>
67 struct TruncateReg<IS, ipReal64>
68 {
69  static IPSDK_FORCEINLINE
71  act(const typename RegType<IS, ipReal64>::Type& in)
72  {
73  typename RegType<IS, ipReal64>::Type out;
74  act(in, out);
75  return out;
76  }
77 
78  static IPSDK_FORCEINLINE
79  void
80  act(const typename RegType<IS, ipReal64>::Type& in,
81  typename RegType<IS, ipReal64>::Type& out)
82  {
83  typedef typename RegType<IS, ipReal64>::Type Reg;
84  typename RegType<IS, ipUInt64>::Type bitOfSignUI;
85  AssignReg<IS, ipUInt64>::act(bitOfSignUI, 0x8000000000000000);
86  Reg bitOfSign;
87  BitwiseCastReg<IS, ipUInt64, ipReal64>::act(bitOfSignUI, bitOfSign);
88  BitwiseAndReg<IS, ipReal64>::act(bitOfSign, in, bitOfSign);
89  Reg res;
92  BitwiseOrReg<IS, ipReal64>::act(res, bitOfSign, out);
93  }
94 };
95 
98 
99 } // end of namespace detail
100 } // end of namespace simd
101 } // end of namespace ipsdk
102 
103 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_TRUNCATEREG_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
template structure which is specialized to implement the computation of value rounded to closest even...
Definition: FloorReg.h:36
RegType class.
Definition: BitwiseOrReg.h:30
RegMaskType class.
Definition of import/export macro for library.
Definition: BitwiseCastReg.h:29
template structure which is specialized to implement the computation of abs function on a scalar or a...
Definition: AbsReg.h:46
template structure which is specialized to implement the computation of value truncated to nearest in...
Definition: TruncateReg.h:37
Definition: RegType.h:29
Definition: BitwiseAndReg.h:30
Definition: AssignRegDecl.h:31
float ipReal32
Base types definition.
Definition: BaseTypes.h:56