IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
AcosReg.h
Go to the documentation of this file.
1 // AcosReg.h:
3 // -------------------
4 //
13 
14 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_ACOSREG_H__
15 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_ACOSREG_H__
16 
27 
29 
30 namespace ipsdk {
31 namespace simd {
32 namespace detail {
33 
36 
38 template <eInstructionSet::domain IS, typename T>
39 struct AcosReg<
40  IS,
41  T,
42  typename boost::enable_if<
43  typename boost::mpl::and_<
44  typename boost::mpl::not_equal_to<
45  boost::mpl::int_<IS>,
46  boost::mpl::int_<eInstructionSet::eIS_Standard>
47  >::type,
48  typename boost::is_float<T>::type
49  >::type
50  >::type
51 >
52 {
53  static IPSDK_FORCEINLINE
54  typename RegType<IS, T>::Type
55  act(const typename RegType<IS, T>::Type& in)
56  {
57  typename RegType<IS, T>::Type out;
58  act(in, out);
59  return out;
60  }
61 
62  static IPSDK_FORCEINLINE
63  void
64  act(const typename RegType<IS, T>::Type& in,
65  typename RegType<IS, T>::Type& out)
66  {
67  typedef typename RegType<IS, T>::Type Reg;
68  typedef typename RegMaskType<IS, T>::Type MaskReg;
69 
70  Reg cste0P5Reg, cstePiD2Reg;
71  simd::detail::AssignReg<IS, T>::act(cste0P5Reg, static_cast<T>(0.5));
72  simd::detail::AssignReg<IS, T>::act(cstePiD2Reg, static_cast<T>(M_PI_2));
73 
74  // check for input data range
75  Reg valReg;
76  MaskReg testReg;
77  simd::detail::IsGreaterReg<IS, T>::act(in, cste0P5Reg, testReg); // if (x > 0.5)
78 
79  // std::sqrt(0.5-0.5*x)
80  simd::detail::MulReg<IS, T>::act(cste0P5Reg, in, valReg);
81  simd::detail::SubReg<IS, T>::act(cste0P5Reg, valReg, valReg);
82  simd::detail::SqrtReg<IS, T>::act(valReg, valReg);
83 
84  // select value for asin computation
85  Reg asinReg;
86  simd::detail::IfElseReg<IS, T>::act(testReg, valReg, in, valReg);
87  simd::detail::AsinReg<IS, T>::act(valReg, asinReg);
88 
89  // compute solutions
90  Reg valReg1, valReg2;
91  simd::detail::AddReg<IS, T>::act(asinReg, asinReg, valReg1); // 2*asin_std(std::sqrt(0.5-0.5*x))
92  simd::detail::SubReg<IS, T>::act(cstePiD2Reg, asinReg, valReg2); // M_PI_2 - asin_std(x)
93  simd::detail::IfElseReg<IS, T>::act(testReg, valReg1, valReg2, out);
94 
95 
96  }
97 };
98 
101 
102 } // end of namespace detail
103 } // end of namespace simd
104 } // end of namespace ipsdk
105 
106 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_ACOSREG_H__
template structure which is specialized to implement the computation of asin function on a scalar or ...
Definition: AsinReg.h:38
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Definition: SubReg.h:39
template structure which is specialized to implement the computation of acos function on a scalar or ...
Definition: AcosReg.h:37
Definition: SqrtReg.h:39
abs function; returns the absolute value of a pack
Definition: IsGreaterRegDecl.h:30
Definition: DataItemNodeHdrMacrosDetails.h:48
RegType class.
mul function; returns the product of 2 input pack operandes
function assigning a given value of type T to a given Pack<instructionSet, T>
div function; returns the quotient of 2 input pack operandes
Definition of import/export macro for library.
asin function; returns the calculation of the arcsin function on all the elements of one input pack o...
sub function; returns the result of an arithmetic substraction on all the elements of 2 input pack op...
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: MulReg.h:39
Definition: RegMaskType.h:29
Definition: RegType.h:29
Definition: AssignRegDecl.h:31