1.0.2 API documentation: _vectorize.hpp Source File

| 1.0.2 API documentation

_vectorize.hpp
1 #pragma once
2
3 namespace glm{
4 namespace detail
5 {
6 template<template<length_t L, typename T, qualifier Q> class vec, length_t L, typename R, typename T, qualifier Q>
7 struct functor1{};
8
9 template<template<length_t L, typename T, qualifier Q> class vec, typename R, typename T, qualifier Q>
10 struct functor1<vec, 1, R, T, Q>
11 {
12 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<1, R, Q> call(R (*Func) (T x), vec<1, T, Q> const& v)
13 {
14 return vec<1, R, Q>(Func(v.x));
15 }
16 };
17
18 template<template<length_t L, typename T, qualifier Q> class vec, typename R, typename T, qualifier Q>
19 struct functor1<vec, 2, R, T, Q>
20 {
21 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<2, R, Q> call(R (*Func) (T x), vec<2, T, Q> const& v)
22 {
23 return vec<2, R, Q>(Func(v.x), Func(v.y));
24 }
25 };
26
27 template<template<length_t L, typename T, qualifier Q> class vec, typename R, typename T, qualifier Q>
28 struct functor1<vec, 3, R, T, Q>
29 {
30 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<3, R, Q> call(R (*Func) (T x), vec<3, T, Q> const& v)
31 {
32 return vec<3, R, Q>(Func(v.x), Func(v.y), Func(v.z));
33 }
34 };
35
36 template<template<length_t L, typename T, qualifier Q> class vec, typename R, typename T, qualifier Q>
37 struct functor1<vec, 4, R, T, Q>
38 {
39 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<4, R, Q> call(R (*Func) (T x), vec<4, T, Q> const& v)
40 {
41 return vec<4, R, Q>(Func(v.x), Func(v.y), Func(v.z), Func(v.w));
42 }
43 };
44
45 template<template<length_t L, typename T, qualifier Q> class vec, length_t L, typename T, qualifier Q>
46 struct functor2{};
47
48 template<template<length_t L, typename T, qualifier Q> class vec, typename T, qualifier Q>
49 struct functor2<vec, 1, T, Q>
50 {
51 GLM_FUNC_QUALIFIER static vec<1, T, Q> call(T (*Func) (T x, T y), vec<1, T, Q> const& a, vec<1, T, Q> const& b)
52 {
53 return vec<1, T, Q>(Func(a.x, b.x));
54 }
55
56 template<typename Fct>
57 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<1, T, Q> call(Fct Func, vec<1, T, Q> const& a, vec<1, T, Q> const& b)
58 {
59 return vec<1, T, Q>(Func(a.x, b.x));
60 }
61 };
62
63 template<template<length_t L, typename T, qualifier Q> class vec, typename T, qualifier Q>
64 struct functor2<vec, 2, T, Q>
65 {
66 GLM_FUNC_QUALIFIER static vec<2, T, Q> call(T (*Func) (T x, T y), vec<2, T, Q> const& a, vec<2, T, Q> const& b)
67 {
68 return vec<2, T, Q>(Func(a.x, b.x), Func(a.y, b.y));
69 }
70
71 template<typename Fct>
72 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<2, T, Q> call(Fct Func, vec<2, T, Q> const& a, vec<2, T, Q> const& b)
73 {
74 return vec<2, T, Q>(Func(a.x, b.x), Func(a.y, b.y));
75 }
76 };
77
78 template<template<length_t L, typename T, qualifier Q> class vec, typename T, qualifier Q>
79 struct functor2<vec, 3, T, Q>
80 {
81 GLM_FUNC_QUALIFIER static vec<3, T, Q> call(T (*Func) (T x, T y), vec<3, T, Q> const& a, vec<3, T, Q> const& b)
82 {
83 return vec<3, T, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z));
84 }
85
86 template<class Fct>
87 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<3, T, Q> call(Fct Func, vec<3, T, Q> const& a, vec<3, T, Q> const& b)
88 {
89 return vec<3, T, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z));
90 }
91 };
92
93 template<template<length_t L, typename T, qualifier Q> class vec, typename T, qualifier Q>
94 struct functor2<vec, 4, T, Q>
95 {
96 GLM_FUNC_QUALIFIER static vec<4, T, Q> call(T (*Func) (T x, T y), vec<4, T, Q> const& a, vec<4, T, Q> const& b)
97 {
98 return vec<4, T, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z), Func(a.w, b.w));
99 }
100
101 template<class Fct>
102 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<4, T, Q> call(Fct Func, vec<4, T, Q> const& a, vec<4, T, Q> const& b)
103 {
104 return vec<4, T, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z), Func(a.w, b.w));
105 }
106 };
107
108 template<template<length_t L, typename T, qualifier Q> class vec, length_t L, typename T, qualifier Q>
109 struct functor2_vec_sca{};
110
111 template<template<length_t L, typename T, qualifier Q> class vec, typename T, qualifier Q>
112 struct functor2_vec_sca<vec, 1, T, Q>
113 {
114 GLM_FUNC_QUALIFIER static vec<1, T, Q> call(T (*Func) (T x, T y), vec<1, T, Q> const& a, T b)
115 {
116 return vec<1, T, Q>(Func(a.x, b));
117 }
118 template<class Fct>
119 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<1, T, Q> call(Fct Func, vec<1, T, Q> const& a, T b)
120 {
121 return vec<1, T, Q>(Func(a.x, b));
122 }
123 };
124
125 template<template<length_t L, typename T, qualifier Q> class vec, typename T, qualifier Q>
126 struct functor2_vec_sca<vec, 2, T, Q>
127 {
128 GLM_FUNC_QUALIFIER static vec<2, T, Q> call(T (*Func) (T x, T y), vec<2, T, Q> const& a, T b)
129 {
130 return vec<2, T, Q>(Func(a.x, b), Func(a.y, b));
131 }
132
133 template<class Fct>
134 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<2, T, Q> call(Fct Func, vec<2, T, Q> const& a, T b)
135 {
136 return vec<2, T, Q>(Func(a.x, b), Func(a.y, b));
137 }
138 };
139
140 template<template<length_t L, typename T, qualifier Q> class vec, typename T, qualifier Q>
141 struct functor2_vec_sca<vec, 3, T, Q>
142 {
143 GLM_FUNC_QUALIFIER static vec<3, T, Q> call(T (*Func) (T x, T y), vec<3, T, Q> const& a, T b)
144 {
145 return vec<3, T, Q>(Func(a.x, b), Func(a.y, b), Func(a.z, b));
146 }
147
148 template<class Fct>
149 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<3, T, Q> call(Fct Func, vec<3, T, Q> const& a, T b)
150 {
151 return vec<3, T, Q>(Func(a.x, b), Func(a.y, b), Func(a.z, b));
152 }
153 };
154
155 template<template<length_t L, typename T, qualifier Q> class vec, typename T, qualifier Q>
156 struct functor2_vec_sca<vec, 4, T, Q>
157 {
158 GLM_FUNC_QUALIFIER static vec<4, T, Q> call(T (*Func) (T x, T y), vec<4, T, Q> const& a, T b)
159 {
160 return vec<4, T, Q>(Func(a.x, b), Func(a.y, b), Func(a.z, b), Func(a.w, b));
161 }
162 template<class Fct>
163 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<4, T, Q> call(Fct Func, vec<4, T, Q> const& a, T b)
164 {
165 return vec<4, T, Q>(Func(a.x, b), Func(a.y, b), Func(a.z, b), Func(a.w, b));
166 }
167 };
168
169 template<length_t L, typename T, qualifier Q>
170 struct functor2_vec_int {};
171
172 template<typename T, qualifier Q>
173 struct functor2_vec_int<1, T, Q>
174 {
175 GLM_FUNC_QUALIFIER static vec<1, int, Q> call(int (*Func) (T x, int y), vec<1, T, Q> const& a, vec<1, int, Q> const& b)
176 {
177 return vec<1, int, Q>(Func(a.x, b.x));
178 }
179
180 template<class Fct>
181 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<1, int, Q> call(Fct Func, vec<1, T, Q> const& a, vec<1, int, Q> const& b)
182 {
183 return vec<1, int, Q>(Func(a.x, b.x));
184 }
185 };
186
187 template<typename T, qualifier Q>
188 struct functor2_vec_int<2, T, Q>
189 {
190 GLM_FUNC_QUALIFIER static vec<2, int, Q> call(int (*Func) (T x, int y), vec<2, T, Q> const& a, vec<2, int, Q> const& b)
191 {
192 return vec<2, int, Q>(Func(a.x, b.x), Func(a.y, b.y));
193 }
194 template<class Fct>
195 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<2, int, Q> call(Fct Func, vec<2, T, Q> const& a, vec<2, int, Q> const& b)
196 {
197 return vec<2, int, Q>(Func(a.x, b.x), Func(a.y, b.y));
198 }
199 };
200
201 template<typename T, qualifier Q>
202 struct functor2_vec_int<3, T, Q>
203 {
204 GLM_FUNC_QUALIFIER static vec<3, int, Q> call(int (*Func) (T x, int y), vec<3, T, Q> const& a, vec<3, int, Q> const& b)
205 {
206 return vec<3, int, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z));
207 }
208 template<class Fct>
209 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<3, int, Q> call(Fct Func, vec<3, T, Q> const& a, vec<3, int, Q> const& b)
210 {
211 return vec<3, int, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z));
212 }
213 };
214
215 template<typename T, qualifier Q>
216 struct functor2_vec_int<4, T, Q>
217 {
218 GLM_FUNC_QUALIFIER static vec<4, int, Q> call(int (*Func) (T x, int y), vec<4, T, Q> const& a, vec<4, int, Q> const& b)
219 {
220 return vec<4, int, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z), Func(a.w, b.w));
221 }
222
223 template<class Fct>
224 GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<4, int, Q> call(Fct Func, vec<4, T, Q> const& a, vec<4, int, Q> const& b)
225 {
226 return vec<4, int, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z), Func(a.w, b.w));
227 }
228 };
229 }//namespace detail
230 }//namespace glm