~mir-team/mir/in-process-egl+input-conglomeration

« back to all changes in this revision

Viewing changes to 3rd_party/glm/glm/core/func_exponential.inl

Merged trunk and fixed issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
///////////////////////////////////////////////////////////////////////////////////
2
 
/// OpenGL Mathematics (glm.g-truc.net)
3
 
///
4
 
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5
 
/// Permission is hereby granted, free of charge, to any person obtaining a copy
6
 
/// of this software and associated documentation files (the "Software"), to deal
7
 
/// in the Software without restriction, including without limitation the rights
8
 
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 
/// copies of the Software, and to permit persons to whom the Software is
10
 
/// furnished to do so, subject to the following conditions:
11
 
/// 
12
 
/// The above copyright notice and this permission notice shall be included in
13
 
/// all copies or substantial portions of the Software.
14
 
/// 
15
 
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
 
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
 
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
 
/// THE SOFTWARE.
22
 
///
23
 
/// @ref core
24
 
/// @file glm/core/func_exponential.inl
25
 
/// @date 2008-08-03 / 2011-06-15
26
 
/// @author Christophe Riccio
27
 
///////////////////////////////////////////////////////////////////////////////////
28
 
 
29
 
#include "_vectorize.hpp"
30
 
 
31
 
namespace glm
32
 
{
33
 
    // pow
34
 
    template <typename genType>
35
 
    GLM_FUNC_QUALIFIER genType pow
36
 
        (
37
 
                genType const & x, 
38
 
                genType const & y
39
 
        )
40
 
    {
41
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'pow' only accept floating-point input");
42
 
 
43
 
        return ::std::pow(x, y);
44
 
    }
45
 
 
46
 
        VECTORIZE_VEC_VEC(pow)
47
 
 
48
 
    // exp
49
 
    template <typename genType>
50
 
    GLM_FUNC_QUALIFIER genType exp
51
 
        (
52
 
                genType const & x
53
 
        )
54
 
    {
55
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'exp' only accept floating-point input");
56
 
 
57
 
        return ::std::exp(x);
58
 
    }
59
 
 
60
 
        VECTORIZE_VEC(exp)
61
 
 
62
 
    // log
63
 
    template <typename genType>
64
 
    GLM_FUNC_QUALIFIER genType log
65
 
        (
66
 
                genType const & x
67
 
        )
68
 
    {
69
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'log' only accept floating-point input");
70
 
 
71
 
        return ::std::log(x);
72
 
    }
73
 
 
74
 
        VECTORIZE_VEC(log)
75
 
 
76
 
    //exp2, ln2 = 0.69314718055994530941723212145818f
77
 
    template <typename genType>
78
 
    GLM_FUNC_QUALIFIER genType exp2
79
 
        (
80
 
                genType const & x
81
 
        )
82
 
    {
83
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'exp2' only accept floating-point input");
84
 
 
85
 
        return ::std::exp(genType(0.69314718055994530941723212145818) * x);
86
 
    }
87
 
 
88
 
        VECTORIZE_VEC(exp2)
89
 
 
90
 
namespace _detail
91
 
{
92
 
        template <int _PATH = detail::float_or_int_value::GLM_ERROR>
93
 
        struct _compute_log2
94
 
        {
95
 
                template <typename T>
96
 
                T operator() (T const & Value) const;
97
 
/*
98
 
                {
99
 
                        GLM_STATIC_ASSERT(0, "'log2' parameter has an invalid template parameter type. GLM core features only supports floating-point types, include <glm/gtx/integer.hpp> for integer types support. Others types are not supported.");
100
 
                        return Value;
101
 
                }
102
 
*/
103
 
        };
104
 
 
105
 
        template <>
106
 
        struct _compute_log2<detail::float_or_int_value::GLM_FLOAT>
107
 
        {
108
 
                template <typename T>
109
 
                T operator() (T const & Value) const
110
 
                {
111
 
                        return T(::std::log(Value)) / T(0.69314718055994530941723212145818);
112
 
                }
113
 
        };
114
 
    
115
 
}//namespace _detail
116
 
 
117
 
    // log2, ln2 = 0.69314718055994530941723212145818f
118
 
    template <typename genType>
119
 
    GLM_FUNC_QUALIFIER genType log2
120
 
        (
121
 
                genType const & x
122
 
        )
123
 
    {
124
 
                assert(x > genType(0)); // log2 is only defined on the range (0, inf]
125
 
                return _detail::_compute_log2<detail::float_or_int_trait<genType>::ID>()(x);
126
 
    }
127
 
 
128
 
        VECTORIZE_VEC(log2)
129
 
 
130
 
    // sqrt
131
 
    template <typename genType>
132
 
    GLM_FUNC_QUALIFIER genType sqrt
133
 
        (
134
 
                genType const & x
135
 
        )
136
 
    {
137
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sqrt' only accept floating-point input");
138
 
 
139
 
        return genType(::std::sqrt(x));
140
 
    }
141
 
 
142
 
        VECTORIZE_VEC(sqrt)
143
 
 
144
 
    template <typename genType>
145
 
    GLM_FUNC_QUALIFIER genType inversesqrt
146
 
        (
147
 
                genType const & x
148
 
        )
149
 
    {
150
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'inversesqrt' only accept floating-point input");
151
 
 
152
 
        return genType(1) / ::std::sqrt(x);
153
 
    }
154
 
 
155
 
        VECTORIZE_VEC(inversesqrt)
156
 
 
157
 
}//namespace glm