Clutter Engine 0.0.1
Loading...
Searching...
No Matches
func_exponential.inl
Go to the documentation of this file.
1
3
5#include "_vectorize.hpp"
6#include <limits>
7#include <cmath>
8#include <cassert>
9
10namespace glm{
11namespace detail
12{
13# if GLM_HAS_CXX11_STL
14 using std::log2;
15# else
16 template<typename genType>
17 genType log2(genType Value)
18 {
19 return std::log(Value) * static_cast<genType>(1.4426950408889634073599246810019);
20 }
21# endif
22
23 template<length_t L, typename T, qualifier Q, bool isFloat, bool Aligned>
25 {
26 GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& v)
27 {
28 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'log2' only accept floating-point inputs. Include <glm/gtc/integer.hpp> for integer inputs.");
29
31 }
32 };
33
34 template<length_t L, typename T, qualifier Q, bool Aligned>
36 {
37 GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& x)
38 {
39 return detail::functor1<vec, L, T, T, Q>::call(std::sqrt, x);
40 }
41 };
42
43 template<length_t L, typename T, qualifier Q, bool Aligned>
45 {
46 GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& x)
47 {
48 return static_cast<T>(1) / sqrt(x);
49 }
50 };
51
52 template<length_t L, bool Aligned>
53 struct compute_inversesqrt<L, float, lowp, Aligned>
54 {
55 GLM_FUNC_QUALIFIER static vec<L, float, lowp> call(vec<L, float, lowp> const& x)
56 {
58 vec<L, float, lowp> xhalf(tmp * 0.5f);
59 vec<L, uint, lowp>* p = reinterpret_cast<vec<L, uint, lowp>*>(const_cast<vec<L, float, lowp>*>(&x));
60 vec<L, uint, lowp> i = vec<L, uint, lowp>(0x5f375a86) - (*p >> vec<L, uint, lowp>(1));
61 vec<L, float, lowp>* ptmp = reinterpret_cast<vec<L, float, lowp>*>(&i);
62 tmp = *ptmp;
63 tmp = tmp * (1.5f - xhalf * tmp * tmp);
64 return tmp;
65 }
66 };
67}//namespace detail
68
69 // pow
70 using std::pow;
71 template<length_t L, typename T, qualifier Q>
72 GLM_FUNC_QUALIFIER vec<L, T, Q> pow(vec<L, T, Q> const& base, vec<L, T, Q> const& exponent)
73 {
74 return detail::functor2<vec, L, T, Q>::call(pow, base, exponent);
75 }
76
77 // exp
78 using std::exp;
79 template<length_t L, typename T, qualifier Q>
80 GLM_FUNC_QUALIFIER vec<L, T, Q> exp(vec<L, T, Q> const& x)
81 {
83 }
84
85 // log
86 using std::log;
87 template<length_t L, typename T, qualifier Q>
88 GLM_FUNC_QUALIFIER vec<L, T, Q> log(vec<L, T, Q> const& x)
89 {
91 }
92
93# if GLM_HAS_CXX11_STL
94 using std::exp2;
95# else
96 //exp2, ln2 = 0.69314718055994530941723212145818f
97 template<typename genType>
98 GLM_FUNC_QUALIFIER genType exp2(genType x)
99 {
100 GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'exp2' only accept floating-point inputs");
101
102 return std::exp(static_cast<genType>(0.69314718055994530941723212145818) * x);
103 }
104# endif
105
106 template<length_t L, typename T, qualifier Q>
107 GLM_FUNC_QUALIFIER vec<L, T, Q> exp2(vec<L, T, Q> const& x)
108 {
110 }
111
112 // log2, ln2 = 0.69314718055994530941723212145818f
113 template<typename genType>
114 GLM_FUNC_QUALIFIER genType log2(genType x)
115 {
116 return log2(vec<1, genType>(x)).x;
117 }
118
119 template<length_t L, typename T, qualifier Q>
124
125 // sqrt
126 using std::sqrt;
127 template<length_t L, typename T, qualifier Q>
128 GLM_FUNC_QUALIFIER vec<L, T, Q> sqrt(vec<L, T, Q> const& x)
129 {
130 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'sqrt' only accept floating-point inputs");
132 }
133
134 // inversesqrt
135 template<typename genType>
136 GLM_FUNC_QUALIFIER genType inversesqrt(genType x)
137 {
138 return static_cast<genType>(1) / sqrt(x);
139 }
140
141 template<length_t L, typename T, qualifier Q>
142 GLM_FUNC_QUALIFIER vec<L, T, Q> inversesqrt(vec<L, T, Q> const& x)
143 {
144 GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'inversesqrt' only accept floating-point inputs");
146 }
147}//namespace glm
148
149#if GLM_CONFIG_SIMD == GLM_ENABLE
151#endif
152
GLM_FUNC_QUALIFIER vec< L, T, Q > sqrt(vec< L, T, Q > const &x)
Definition func_exponential.inl:128
GLM_FUNC_QUALIFIER vec< L, T, Q > pow(vec< L, T, Q > const &base, vec< L, T, Q > const &exponent)
Definition func_exponential.inl:72
GLM_FUNC_QUALIFIER vec< L, T, Q > log(vec< L, T, Q > const &x)
Definition func_exponential.inl:88
GLM_FUNC_QUALIFIER vec< L, T, Q > exp(vec< L, T, Q > const &x)
Definition func_exponential.inl:80
detail namespace with internal helper functions
Definition json.h:249
Core features
Definition common.hpp:21
@ lowp
By default lowp qualifier is also packed.
Definition qualifier.hpp:23
Definition func_exponential.inl:45
Definition func_exponential.inl:25
Definition func_exponential.inl:36
Definition _vectorize.hpp:7
Definition _vectorize.hpp:46
Definition qualifier.hpp:60
Definition qualifier.hpp:35