IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
NormalRandomReg.h
Go to the documentation of this file.
1 // NormalRandomReg.h:
3 // ------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_DETAIL_NORMALRANDOMREG_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_DETAIL_NORMALRANDOMREG_H__
17 
21 #include <IPSDKUtil/InstructionSet/Arithmetic/detail/SignedUnsignedOpReg.h>
29 
30 #include <boost/math/constants/constants.hpp>
31 
32 #include <math.h>
33 
34 namespace ipsdk {
35 namespace simd {
36 namespace detail {
37 
40 
41 template <eInstructionSet::domain is, eInstructionSet::domain isFma>
43 
44 static
45 IPSDK_FORCEINLINE
46 void
47 act(const typename RegType<is, ipReal32>::Type& rMean,
48  const typename RegType<is, ipReal32>::Type& rSigma,
49  const typename RegType<is, ipReal32>::Type& rUnifRand1,
50  const typename RegType<is, ipReal32>::Type& rUnifRand2,
51  typename RegType<is, ipReal32>::Type& rOut1,
52  typename RegType<is, ipReal32>::Type& rOut2)
53 {
54  typename RegType<is, ipReal32>::Type rTwo, rSqrt2LogU1;
55  AssignReg<is, ipReal32>::act(rTwo, 2.0f);
56  LogReg<is, isFma, ipReal32>::act(rUnifRand1, rSqrt2LogU1);
57  MulReg<is, ipReal32>::act(rSqrt2LogU1, rTwo, rSqrt2LogU1);
58  UnaryMinusReg<is, ipReal32>::act(rSqrt2LogU1, rSqrt2LogU1);
59  SqrtReg<is, ipReal32>::act(rSqrt2LogU1, rSqrt2LogU1);
60 
61  const ipReal32 two_pi = 2.0f*boost::math::constants::pi<ipReal32>();
62  typename RegType<is, ipReal32>::Type rTwoPi, rAngle;
63  AssignReg<is, ipReal32>::act(rTwoPi, two_pi);
64  MulReg<is, ipReal32>::act(rTwoPi, rUnifRand2, rAngle);
65 
66  typename RegType<is, ipReal32>::Type rCos, rSin;
69 
70  MulReg<is, ipReal32>::act(rCos, rSqrt2LogU1, rOut1);
71  MulReg<is, ipReal32>::act(rOut1, rSigma, rOut1);
72  AddReg<is, ipReal32>::act(rOut1, rMean, rOut1);
73 
74  MulReg<is, ipReal32>::act(rSin, rSqrt2LogU1, rOut2);
75  MulReg<is, ipReal32>::act(rOut2, rSigma, rOut2);
76  AddReg<is, ipReal32>::act(rOut2, rMean, rOut2);
77 }
78 };
79 
82 
83 } // end of namespace detail
84 } // end of namespace simd
85 } // end of namespace ipsdk
86 
87 #endif // __IPSDKUTIL_INSTRUCTIONSET_DETAIL_NORMALRANDOMREG_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Definition: NormalRandomReg.h:42
cos function; returns the calculation of the cosine on all the elements of one input pack operand ...
Definition: SqrtReg.h:39
RegType class.
mul function; returns the product of 2 input pack operandes
sqrt function; returns the square root of a pack
log function; returns the result of a natural logarithm on all the elements of one input pack operand...
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
template structure which is specialized to implement the computation of sine on a scalar or a registe...
Definition: SinReg.h:40
Definition: MulReg.h:39
Definition: UnaryMinusReg.h:40
sin function; returns the calculation of the sine on all the elements of one input pack operand ...
Definition: RegType.h:29
template structure which is specialized to implement the computation of cosine on a scalar or a regis...
Definition: CosReg.h:39
template structure which is specialized to implement the computation of natural logarithm on a scalar...
Definition: LogReg.h:40
Definition: AssignRegDecl.h:31
float ipReal32
Base types definition.
Definition: BaseTypes.h:56