IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
RoundToNearestIntegralReg.h
1 // RoundToNearestIntegralReg.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_ROUNDTONEARESTINTEGRALREG_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_ROUNDTONEARESTINTEGRALREG_H__
17 
21 #include <IPSDKUtil/InstructionSet/Arithmetic/detail/RoundToNearestIntegralReg.h>
22 #include <IPSDKUtil/InstructionSet/Arithmetic/detail/AbsReg.h>
23 #include <IPSDKUtil/InstructionSet/Arithmetic/detail/AddReg.h>
24 #include <IPSDKUtil/InstructionSet/Arithmetic/detail/FloorReg.h>
30 
31 namespace ipsdk {
32 namespace simd {
33 namespace detail {
34 
37 
39 template <eInstructionSet::domain IS>
41 {
42  static IPSDK_FORCEINLINE
44  act(const typename RegType<IS, ipReal32>::Type& in)
45  {
46  typename RegType<IS, ipReal32>::Type out;
47  act(in, out);
48  return out;
49  }
50 
51  static IPSDK_FORCEINLINE
52  void
53  act(const typename RegType<IS, ipReal32>::Type& in,
54  typename RegType<IS, ipReal32>::Type& out)
55  {
56  typedef typename RegType<IS, ipReal32>::Type Reg;
57  typedef typename RegMaskType<IS, ipReal32>::Type RegMask;
58  Reg inAbs;
59  AbsReg<IS, ipReal32>::act(in, inAbs);
60  Reg inAbsRounded;
61  Reg half;
62  AssignReg<IS, ipReal32>::act(half, 0.5f);
63  AddReg<IS, ipReal32>::act(inAbs, half, inAbsRounded);
64  FloorReg<IS, ipReal32>::act(inAbsRounded, inAbsRounded);
65  Reg minusInAbsRounded;
66  UnaryMinusReg<IS, ipReal32>::act(inAbsRounded, minusInAbsRounded);
67  Reg zero;
69  RegMask inNeg;
70  IsLessReg<IS, ipReal32>::act(in, zero, inNeg);
71  IfElseReg<IS, ipReal32>::act(inNeg, minusInAbsRounded, inAbsRounded, out);
72  }
73 };
74 
77 
78 } // end of namespace detail
79 } // end of namespace simd
80 } // end of namespace ipsdk
81 
82 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_ROUNDTONEARESTINTEGRALREG_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
template structure which is specialized to implement the computation of value rounded to closest even...
Definition: FloorReg.h:36
RegType class.
template structure which is specialized to implement the computation of value rounded to closest even...
Definition: RoundToNearestIntegralReg.h:36
RegMaskType class.
Definition of import/export macro for library.
template structure which is specialized to implement the arithmetic addition on 2 scalars or 2 regist...
Definition: AddReg.h:37
Definition: IfElseReg.h:33
Definition: UnaryMinusReg.h:40
Definition: RegMaskType.h:29
template structure which is specialized to implement the computation of abs function on a scalar or a...
Definition: AbsReg.h:46
Definition: IsLessRegDecl.h:30
Definition: RegType.h:29
Definition: AssignRegDecl.h:31
float ipReal32
Base types definition.
Definition: BaseTypes.h:56