Changeset 2081
 Timestamp:
 Nov 17, 2012, 2:24:44 PM (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/lol/math/vector.h
r2057 r2081 35 35 #endif 36 36 37 #define DECLARE_VECTOR_TYPEDEFS(tname, suffix) \37 #define LOL_VECTOR_TYPEDEFS(tname, suffix) \ 38 38 template <typename T> struct tname; \ 39 39 typedef tname<half> f16##suffix; \ … … 51 51 typedef tname<real> r##suffix; \ 52 52 53 DECLARE_VECTOR_TYPEDEFS(Vec2, vec2) 54 DECLARE_VECTOR_TYPEDEFS(Cmplx, cmplx) 55 DECLARE_VECTOR_TYPEDEFS(Vec3, vec3) 56 DECLARE_VECTOR_TYPEDEFS(Vec4, vec4) 57 DECLARE_VECTOR_TYPEDEFS(Quat, quat) 58 DECLARE_VECTOR_TYPEDEFS(Mat2, mat2) 59 DECLARE_VECTOR_TYPEDEFS(Mat3, mat3) 60 DECLARE_VECTOR_TYPEDEFS(Mat4, mat4) 53 LOL_VECTOR_TYPEDEFS(Vec2, vec2) 54 LOL_VECTOR_TYPEDEFS(Cmplx, cmplx) 55 LOL_VECTOR_TYPEDEFS(Vec3, vec3) 56 LOL_VECTOR_TYPEDEFS(Vec4, vec4) 57 LOL_VECTOR_TYPEDEFS(Quat, quat) 58 LOL_VECTOR_TYPEDEFS(Mat2, mat2) 59 LOL_VECTOR_TYPEDEFS(Mat3, mat3) 60 LOL_VECTOR_TYPEDEFS(Mat4, mat4) 61 62 #undef LOL_VECTOR_TYPEDEFS 61 63 62 64 /* … … 139 141 */ 140 142 141 #define DECLARE_MEMBER_OPS(tname, first) \143 #define LOL_MEMBER_OPS(tname, first) \ 142 144 inline T& operator[](size_t n) { return *(&this>first + n); } \ 143 145 inline T const& operator[](size_t n) const { return *(&this>first + n); } \ … … 247 249 : BVec2<T>(v[0], v[1]) {} 248 250 249 DECLARE_MEMBER_OPS(Vec2, x)251 LOL_MEMBER_OPS(Vec2, x) 250 252 251 253 template<typename U> … … 263 265 inline Cmplx(T X, T Y) : x(X), y(Y) {} 264 266 265 DECLARE_MEMBER_OPS(Cmplx, x)267 LOL_MEMBER_OPS(Cmplx, x) 266 268 267 269 inline Cmplx<T> operator *(Cmplx<T> const &val) const … … 501 503 static Vec3<T> toeuler(Quat<T> const &q); 502 504 503 DECLARE_MEMBER_OPS(Vec3, x)505 LOL_MEMBER_OPS(Vec3, x) 504 506 505 507 template<typename U> … … 908 910 : BVec4<T>(v[0], v[1], v[2], v[3]) {} 909 911 910 DECLARE_MEMBER_OPS(Vec4, x)912 LOL_MEMBER_OPS(Vec4, x) 911 913 912 914 template<typename U> … … 927 929 Quat(Mat4<T> const &m); 928 930 929 DECLARE_MEMBER_OPS(Quat, w)931 LOL_MEMBER_OPS(Quat, w) 930 932 931 933 static Quat<T> rotate(T angle, T x, T y, T z); … … 1033 1035 * vec /(vec, vec) 1034 1036 */ 1035 #define DECLARE_VECTOR_VECTOR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \1037 #define LOL_VECTOR_VECTOR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \ 1036 1038 tprefix \ 1037 1039 inline tname<tf> operator op(tname<t1> const &a, tname<t2> const &b) \ … … 1049 1051 * vec /=(vec, vec) 1050 1052 */ 1051 #define DECLARE_VECTOR_VECTOR_OP(tname, op, tprefix, type) \1053 #define LOL_VECTOR_VECTOR_OP(tname, op, tprefix, type) \ 1052 1054 tprefix \ 1053 1055 inline tname<type> operator op##=(tname<type> &a, tname<type> const &b) \ … … 1061 1063 * vec min(scalar, vec) (also max, fmod) 1062 1064 */ 1063 #define DECLARE_VECTOR_MINMAX_OP(tname, op, tprefix, type) \1065 #define LOL_VECTOR_MINMAX_FUN(tname, op, tprefix, type) \ 1064 1066 tprefix \ 1065 1067 inline tname<type> op(tname<type> const &a, tname<type> const &b) \ … … 1098 1100 * vec clamp(vec, scalar, scalar) 1099 1101 */ 1100 #define DECLARE_VECTOR_CLAMP_OP(tname, tprefix, type) \1102 #define LOL_VECTOR_CLAMP_FUN(tname, tprefix, type) \ 1101 1103 tprefix \ 1102 1104 inline tname<type> clamp(tname<type> const &x, \ … … 1135 1137 * bool <(vec, vec) 1136 1138 */ 1137 #define DECLARE_VECTOR_VECTOR_BOOLOP(tname, op, op2, ret, tprefix, t1, t2) \1139 #define LOL_VECTOR_VECTOR_BOOL_OP(tname, op, op2, ret, tprefix, t1, t2) \ 1138 1140 tprefix \ 1139 1141 inline bool operator op(tname<t1> const &a, tname<t2> const &b) \ … … 1149 1151 * vec /(vec, scalar) (also complex & quaternion) 1150 1152 */ 1151 #define DECLARE_VECTOR_SCALAR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \1153 #define LOL_VECTOR_SCALAR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \ 1152 1154 tprefix \ 1153 1155 inline tname<tf> operator op(tname<t1> const &a, t2 const &val) \ … … 1163 1165 * vec /(scalar, vec) (NOT for complex & quaternion!) 1164 1166 */ 1165 #define DECLARE_SCALAR_VECTOR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \1167 #define LOL_SCALAR_VECTOR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \ 1166 1168 tprefix \ 1167 1169 inline tname<tf> operator op(t1 const &val, tname<t2> const &a) \ … … 1177 1179 * vec /=(vec, scalar) (also complex & quaternion) 1178 1180 */ 1179 #define DECLARE_VECTOR_SCALAR_OP(tname, op, tprefix, type) \1181 #define LOL_VECTOR_SCALAR_OP(tname, op, tprefix, type) \ 1180 1182 tprefix \ 1181 1183 inline tname<type> operator op##=(tname<type> &a, type const &val) \ … … 1184 1186 } 1185 1187 1186 #define DECLARE_UNARY_OPS(tname, tprefix, type) \1188 #define LOL_UNARY_OPS(tname, tprefix, type) \ 1187 1189 tprefix \ 1188 1190 inline tname<type> operator (tname<type> const &a) \ … … 1192 1194 ret[n] = a[n]; \ 1193 1195 return ret; \ 1194 } \ 1195 \ 1196 } 1197 1198 #define LOL_UNARY_FUNS(tname, tprefix, type) \ 1196 1199 tprefix \ 1197 1200 inline type sqlength(tname<type> const &a) \ … … 1225 1228 } 1226 1229 1227 #define DECLARE_BINARY_NONVECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \1228 DECLARE_VECTOR_VECTOR_COERCE_OP(tname, , tprefix, t1, t2, tf) \1229 DECLARE_VECTOR_VECTOR_COERCE_OP(tname, +, tprefix, t1, t2, tf) \1230 #define LOL_BINARY_NONVECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \ 1231 LOL_VECTOR_VECTOR_COERCE_OP(tname, , tprefix, t1, t2, tf) \ 1232 LOL_VECTOR_VECTOR_COERCE_OP(tname, +, tprefix, t1, t2, tf) \ 1230 1233 \ 1231 DECLARE_VECTOR_SCALAR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \1232 DECLARE_VECTOR_SCALAR_COERCE_OP(tname, /, tprefix, t1, t2, tf) \1233 DECLARE_SCALAR_VECTOR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \1234 LOL_VECTOR_SCALAR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \ 1235 LOL_VECTOR_SCALAR_COERCE_OP(tname, /, tprefix, t1, t2, tf) \ 1236 LOL_SCALAR_VECTOR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \ 1234 1237 \ 1235 DECLARE_VECTOR_VECTOR_BOOLOP(tname, ==, ==, true, tprefix, t1, t2) \ 1236 DECLARE_VECTOR_VECTOR_BOOLOP(tname, !=, ==, false, tprefix, t1, t2) \ 1237 \ 1238 LOL_VECTOR_VECTOR_BOOL_OP(tname, ==, ==, true, tprefix, t1, t2) \ 1239 LOL_VECTOR_VECTOR_BOOL_OP(tname, !=, ==, false, tprefix, t1, t2) 1240 1241 #define LOL_BINARY_NONVECTOR_COERCE_FUNS(tname, tprefix, t1, t2, tf) \ 1238 1242 tprefix \ 1239 1243 inline tf dot(tname<t1> const &a, tname<t2> const &b) \ … … 1253 1257 } 1254 1258 1255 #define DECLARE_BINARY_VECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \1256 DECLARE_SCALAR_VECTOR_COERCE_OP(tname, /, tprefix, t1, t2, tf)1257 1258 #define DECLARE_VEC_3_COERCE_OPS(tname, tprefix, t1, t2, tf) \1259 #define LOL_BINARY_VECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \ 1260 LOL_SCALAR_VECTOR_COERCE_OP(tname, /, tprefix, t1, t2, tf) 1261 1262 #define LOL_VEC_3_COERCE_FUNS(tname, tprefix, t1, t2, tf) \ 1259 1263 tprefix \ 1260 1264 inline tname<tf> cross(tname<t1> const &a, tname<t2> const &b) \ … … 1265 1269 } 1266 1270 1267 #define DECLARE_BINARY_NONVECTOR_OPS(tname, tprefix, type) \1268 DECLARE_BINARY_NONVECTOR_COERCE_OPS(tname, tprefix, type, type, type) \1271 #define LOL_BINARY_NONVECTOR_OPS(tname, tprefix, type) \ 1272 LOL_BINARY_NONVECTOR_COERCE_OPS(tname, tprefix, type, type, type) \ 1269 1273 \ 1270 DECLARE_VECTOR_VECTOR_OP(tname, , tprefix, type) \1271 DECLARE_VECTOR_VECTOR_OP(tname, +, tprefix, type) \1274 LOL_VECTOR_VECTOR_OP(tname, , tprefix, type) \ 1275 LOL_VECTOR_VECTOR_OP(tname, +, tprefix, type) \ 1272 1276 \ 1273 DECLARE_VECTOR_SCALAR_OP(tname, *, tprefix, type) \ 1274 DECLARE_VECTOR_SCALAR_OP(tname, /, tprefix, type) 1275 1276 #define DECLARE_BINARY_VECTOR_OPS(tname, tprefix, type) \ 1277 DECLARE_BINARY_VECTOR_COERCE_OPS(tname, tprefix, type, type, type) \ 1277 LOL_VECTOR_SCALAR_OP(tname, *, tprefix, type) \ 1278 LOL_VECTOR_SCALAR_OP(tname, /, tprefix, type) 1279 1280 #define LOL_BINARY_NONVECTOR_FUNS(tname, tprefix, type) \ 1281 LOL_BINARY_NONVECTOR_COERCE_FUNS(tname, tprefix, type, type, type) \ 1282 1283 #define LOL_BINARY_VECTOR_OPS(tname, tprefix, type) \ 1284 LOL_BINARY_VECTOR_COERCE_OPS(tname, tprefix, type, type, type) 1285 1286 #define LOL_BINARY_VECTOR_FUNS(tname, tprefix, type) \ 1287 LOL_VECTOR_MINMAX_FUN(tname, min, tprefix, type) \ 1288 LOL_VECTOR_MINMAX_FUN(tname, max, tprefix, type) \ 1289 LOL_VECTOR_MINMAX_FUN(tname, fmod, tprefix, type) \ 1290 LOL_VECTOR_CLAMP_FUN(tname, tprefix, type) 1291 1292 #define LOL_VECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \ 1293 LOL_VECTOR_VECTOR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \ 1294 LOL_VECTOR_VECTOR_COERCE_OP(tname, /, tprefix, t1, t2, tf) \ 1278 1295 \ 1279 DECLARE_VECTOR_MINMAX_OP(tname, min, tprefix, type) \ 1280 DECLARE_VECTOR_MINMAX_OP(tname, max, tprefix, type) \ 1281 DECLARE_VECTOR_MINMAX_OP(tname, fmod, tprefix, type) \ 1282 DECLARE_VECTOR_CLAMP_OP(tname, tprefix, type) 1283 1284 #define DECLARE_VECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \ 1285 DECLARE_VECTOR_VECTOR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \ 1286 DECLARE_VECTOR_VECTOR_COERCE_OP(tname, /, tprefix, t1, t2, tf) \ 1296 LOL_VECTOR_VECTOR_BOOL_OP(tname, <=, <=, true, tprefix, t1, t2) \ 1297 LOL_VECTOR_VECTOR_BOOL_OP(tname, >=, >=, true, tprefix, t1, t2) \ 1298 LOL_VECTOR_VECTOR_BOOL_OP(tname, <, <, true, tprefix, t1, t2) \ 1299 LOL_VECTOR_VECTOR_BOOL_OP(tname, >, >, true, tprefix, t1, t2) 1300 1301 #define LOL_VECTOR_OPS(tname, tprefix, type) \ 1302 LOL_VECTOR_COERCE_OPS(tname, static, type, type, type) \ 1287 1303 \ 1288 DECLARE_VECTOR_VECTOR_BOOLOP(tname, <=, <=, true, tprefix, t1, t2) \ 1289 DECLARE_VECTOR_VECTOR_BOOLOP(tname, >=, >=, true, tprefix, t1, t2) \ 1290 DECLARE_VECTOR_VECTOR_BOOLOP(tname, <, <, true, tprefix, t1, t2) \ 1291 DECLARE_VECTOR_VECTOR_BOOLOP(tname, >, >, true, tprefix, t1, t2) 1292 1293 #define DECLARE_VECTOR_OPS(tname, tprefix, type) \ 1294 DECLARE_VECTOR_COERCE_OPS(tname, static, type, type, type) \ 1304 LOL_VECTOR_VECTOR_OP(tname, *, tprefix, type) \ 1305 LOL_VECTOR_VECTOR_OP(tname, /, tprefix, type) 1306 1307 #define LOL_ALL_NONVECTOR_OPS_AND_FUNS(tname) \ 1308 LOL_BINARY_NONVECTOR_OPS(tname, template<typename T> static, T) \ 1309 LOL_BINARY_NONVECTOR_FUNS(tname, template<typename T> static, T) \ 1310 LOL_UNARY_OPS(tname, template<typename T> static, T) \ 1311 LOL_UNARY_FUNS(tname, template<typename T> static, T) 1312 1313 #define LOL_ALL_VECTOR_OPS_INNER(tname, type) \ 1314 LOL_BINARY_VECTOR_OPS(tname, static, type) \ 1315 LOL_BINARY_NONVECTOR_OPS(tname, static, type) \ 1316 LOL_UNARY_OPS(tname, static, type) \ 1317 LOL_VECTOR_OPS(tname, static, type) 1318 1319 #define LOL_ALL_VECTOR_FUNS_INNER(tname, type) \ 1320 LOL_BINARY_VECTOR_FUNS(tname, static, type) \ 1321 LOL_BINARY_NONVECTOR_FUNS(tname, static, type) \ 1322 LOL_UNARY_FUNS(tname, static, type) 1323 1324 #define LOL_ALL_VECTOR_OPS_AND_FUNS(type) \ 1325 namespace x##type \ 1326 { \ 1327 LOL_ALL_VECTOR_OPS_INNER(Vec2, type) \ 1328 LOL_ALL_VECTOR_OPS_INNER(Vec3, type) \ 1329 LOL_ALL_VECTOR_OPS_INNER(Vec4, type) \ 1330 } \ 1331 using namespace x##type; \ 1332 LOL_ALL_VECTOR_FUNS_INNER(Vec2, type) \ 1333 LOL_ALL_VECTOR_FUNS_INNER(Vec3, type) \ 1334 LOL_ALL_VECTOR_FUNS_INNER(Vec4, type) \ 1335 LOL_VEC_3_COERCE_FUNS(Vec3, static, type, type, type) 1336 1337 #define LOL_VEC_ANY_COERCE_OPS(tname, tlow, thigh) \ 1338 LOL_BINARY_NONVECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \ 1339 LOL_BINARY_NONVECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) \ 1340 LOL_BINARY_VECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \ 1341 LOL_BINARY_VECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) \ 1295 1342 \ 1296 DECLARE_VECTOR_VECTOR_OP(tname, *, tprefix, type) \ 1297 DECLARE_VECTOR_VECTOR_OP(tname, /, tprefix, type) 1298 1299 #define DECLARE_ALL_NONVECTOR_OPS(tname) \ 1300 DECLARE_BINARY_NONVECTOR_OPS(tname, template<typename T> static, T) \ 1301 DECLARE_UNARY_OPS(tname, template<typename T> static, T) 1302 1303 #define DECLARE_ALL_VECTOR_OPS_INNER(tname, type) \ 1304 DECLARE_BINARY_VECTOR_OPS(tname, static, type) \ 1305 DECLARE_BINARY_NONVECTOR_OPS(tname, static, type) \ 1306 DECLARE_UNARY_OPS(tname, static, type) \ 1307 DECLARE_VECTOR_OPS(tname, static, type) \ 1308 1309 #define DECLARE_ALL_VECTOR_OPS(type) \ 1310 namespace x##type \ 1311 { \ 1312 DECLARE_ALL_VECTOR_OPS_INNER(Vec2, type) \ 1313 DECLARE_ALL_VECTOR_OPS_INNER(Vec3, type) \ 1314 DECLARE_ALL_VECTOR_OPS_INNER(Vec4, type) \ 1315 \ 1316 DECLARE_VEC_3_COERCE_OPS(Vec3, static, type, type, type) \ 1317 } 1318 1319 #define DECLARE_VEC_ANY_COERCE_OPS(tname, tlow, thigh) \ 1320 DECLARE_BINARY_NONVECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \ 1321 DECLARE_BINARY_NONVECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) \ 1322 DECLARE_BINARY_VECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \ 1323 DECLARE_BINARY_VECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) \ 1324 \ 1325 DECLARE_VECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \ 1326 DECLARE_VECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) 1327 1328 #define DECLARE_ALL_VECTOR_COERCE_OPS(tlow, thigh) \ 1343 LOL_VECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \ 1344 LOL_VECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) 1345 1346 #define LOL_VEC_ANY_COERCE_FUNS(tname, tlow, thigh) \ 1347 LOL_BINARY_NONVECTOR_COERCE_FUNS(tname, static, tlow, thigh, thigh) \ 1348 LOL_BINARY_NONVECTOR_COERCE_FUNS(tname, static, thigh, tlow, thigh) 1349 1350 #define LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(tlow, thigh) \ 1329 1351 namespace x##tlow##thigh \ 1330 1352 { \ 1331 DECLARE_VEC_ANY_COERCE_OPS(Vec2, tlow, thigh) \1332 DECLARE_VEC_ANY_COERCE_OPS(Vec3, tlow, thigh) \1333 DECLARE_VEC_ANY_COERCE_OPS(Vec4, tlow, thigh) \1353 LOL_VEC_ANY_COERCE_OPS(Vec2, tlow, thigh) \ 1354 LOL_VEC_ANY_COERCE_OPS(Vec3, tlow, thigh) \ 1355 LOL_VEC_ANY_COERCE_OPS(Vec4, tlow, thigh) \ 1334 1356 } \ 1335 namespace y##tlow##thigh\1336 {\1337 DECLARE_VEC_3_COERCE_OPS(Vec3, static, tlow, thigh, thigh) \1338 DECLARE_VEC_3_COERCE_OPS(Vec3, static, thigh, tlow, thigh) \1339 } \1340 1341 DECLARE_ALL_NONVECTOR_OPS(Cmplx)1342 DECLARE_ALL_NONVECTOR_OPS(Quat)1357 LOL_VEC_ANY_COERCE_FUNS(Vec2, tlow, thigh) \ 1358 LOL_VEC_ANY_COERCE_FUNS(Vec3, tlow, thigh) \ 1359 LOL_VEC_ANY_COERCE_FUNS(Vec4, tlow, thigh) \ 1360 LOL_VEC_3_COERCE_FUNS(Vec3, static, tlow, thigh, thigh) \ 1361 LOL_VEC_3_COERCE_FUNS(Vec3, static, thigh, tlow, thigh) 1362 1363 LOL_ALL_NONVECTOR_OPS_AND_FUNS(Cmplx) 1364 LOL_ALL_NONVECTOR_OPS_AND_FUNS(Quat) 1343 1365 1344 1366 /* Disable warning about unary operator applied to unsigned type */ … … 1348 1370 #endif 1349 1371 1350 DECLARE_ALL_VECTOR_OPS(half)1351 DECLARE_ALL_VECTOR_OPS(float)1352 DECLARE_ALL_VECTOR_OPS(double)1353 DECLARE_ALL_VECTOR_OPS(ldouble)1354 DECLARE_ALL_VECTOR_OPS(int8_t)1355 DECLARE_ALL_VECTOR_OPS(uint8_t)1356 DECLARE_ALL_VECTOR_OPS(int16_t)1357 DECLARE_ALL_VECTOR_OPS(uint16_t)1358 DECLARE_ALL_VECTOR_OPS(int32_t)1359 DECLARE_ALL_VECTOR_OPS(uint32_t)1360 DECLARE_ALL_VECTOR_OPS(int64_t)1361 DECLARE_ALL_VECTOR_OPS(uint64_t)1372 LOL_ALL_VECTOR_OPS_AND_FUNS(half) 1373 LOL_ALL_VECTOR_OPS_AND_FUNS(float) 1374 LOL_ALL_VECTOR_OPS_AND_FUNS(double) 1375 LOL_ALL_VECTOR_OPS_AND_FUNS(ldouble) 1376 LOL_ALL_VECTOR_OPS_AND_FUNS(int8_t) 1377 LOL_ALL_VECTOR_OPS_AND_FUNS(uint8_t) 1378 LOL_ALL_VECTOR_OPS_AND_FUNS(int16_t) 1379 LOL_ALL_VECTOR_OPS_AND_FUNS(uint16_t) 1380 LOL_ALL_VECTOR_OPS_AND_FUNS(int32_t) 1381 LOL_ALL_VECTOR_OPS_AND_FUNS(uint32_t) 1382 LOL_ALL_VECTOR_OPS_AND_FUNS(int64_t) 1383 LOL_ALL_VECTOR_OPS_AND_FUNS(uint64_t) 1362 1384 1363 1385 #if defined _MSC_VER … … 1383 1405 * of always promoting smaller types to int, we allow int8_t op int16_t to 1384 1406 * return an int16_t. */ 1385 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, uint8_t)1386 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, int16_t)1387 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, uint16_t)1388 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, int32_t)1389 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, uint32_t)1390 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, int64_t)1391 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, uint64_t)1392 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, float)1393 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, double)1394 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, ldouble)1395 1396 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, int16_t)1397 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, uint16_t)1398 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, int32_t)1399 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, uint32_t)1400 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, int64_t)1401 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, uint64_t)1402 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, float)1403 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, double)1404 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, ldouble)1405 1406 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, uint16_t)1407 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, int32_t)1408 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, uint32_t)1409 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, int64_t)1410 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, uint64_t)1411 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, float)1412 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, double)1413 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, ldouble)1414 1415 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, int32_t)1416 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, uint32_t)1417 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, int64_t)1418 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, uint64_t)1419 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, float)1420 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, double)1421 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, ldouble)1422 1423 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, uint32_t)1424 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, int64_t)1425 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, uint64_t)1426 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, float)1427 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, double)1428 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, ldouble)1429 1430 DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, int64_t)1431 DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, uint64_t)1432 DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, float)1433 DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, double)1434 DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, ldouble)1435 1436 DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, uint64_t)1437 DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, float)1438 DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, double)1439 DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, ldouble)1440 1441 DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, float)1442 DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, double)1443 DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, ldouble)1444 1445 DECLARE_ALL_VECTOR_COERCE_OPS(float, double)1446 DECLARE_ALL_VECTOR_COERCE_OPS(float, ldouble)1447 1448 DECLARE_ALL_VECTOR_COERCE_OPS(double, ldouble)1407 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, uint8_t) 1408 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, int16_t) 1409 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, uint16_t) 1410 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, int32_t) 1411 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, uint32_t) 1412 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, int64_t) 1413 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, uint64_t) 1414 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, float) 1415 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, double) 1416 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, ldouble) 1417 1418 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, int16_t) 1419 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, uint16_t) 1420 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, int32_t) 1421 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, uint32_t) 1422 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, int64_t) 1423 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, uint64_t) 1424 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, float) 1425 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, double) 1426 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, ldouble) 1427 1428 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, uint16_t) 1429 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, int32_t) 1430 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, uint32_t) 1431 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, int64_t) 1432 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, uint64_t) 1433 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, float) 1434 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, double) 1435 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, ldouble) 1436 1437 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, int32_t) 1438 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, uint32_t) 1439 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, int64_t) 1440 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, uint64_t) 1441 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, float) 1442 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, double) 1443 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, ldouble) 1444 1445 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, uint32_t) 1446 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, int64_t) 1447 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, uint64_t) 1448 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, float) 1449 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, double) 1450 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, ldouble) 1451 1452 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, int64_t) 1453 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, uint64_t) 1454 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, float) 1455 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, double) 1456 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, ldouble) 1457 1458 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, uint64_t) 1459 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, float) 1460 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, double) 1461 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, ldouble) 1462 1463 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint64_t, float) 1464 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint64_t, double) 1465 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint64_t, ldouble) 1466 1467 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(float, double) 1468 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(float, ldouble) 1469 1470 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(double, ldouble) 1449 1471 1450 1472 /* FIXME: vectors of "half" are deactivated for now, because they … … 1454 1476 /* All integer types are promoted to half; all floating point types 1455 1477 * cause half to be promoted. */ 1456 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, half)1457 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, half)1458 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, half)1459 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, half)1460 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, half)1461 DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, half)1462 DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, half)1463 DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, half)1464 1465 DECLARE_ALL_VECTOR_COERCE_OPS(half, float)1466 DECLARE_ALL_VECTOR_COERCE_OPS(half, double)1467 DECLARE_ALL_VECTOR_COERCE_OPS(half, ldouble)1478 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, half) 1479 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, half) 1480 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, half) 1481 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, half) 1482 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, half) 1483 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, half) 1484 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, half) 1485 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint64_t, half) 1486 1487 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(half, float) 1488 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(half, double) 1489 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(half, ldouble) 1468 1490 #endif 1469 1491 … … 1473 1495 #if 0 1474 1496 /* All types are promoted to real */ 1475 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, real)1476 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, real)1477 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, real)1478 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, real)1479 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, real)1480 DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, real)1481 DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, real)1482 DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, real)1483 DECLARE_ALL_VECTOR_COERCE_OPS(half, real)1484 DECLARE_ALL_VECTOR_COERCE_OPS(float, real)1485 DECLARE_ALL_VECTOR_COERCE_OPS(double, real)1486 DECLARE_ALL_VECTOR_COERCE_OPS(ldouble, real)1497 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, real) 1498 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, real) 1499 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, real) 1500 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, real) 1501 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, real) 1502 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, real) 1503 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, real) 1504 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint64_t, real) 1505 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(half, real) 1506 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(float, real) 1507 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(double, real) 1508 LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(ldouble, real) 1487 1509 #endif 1488 1510 … … 1491 1513 #define ACTIVATE_COERCE_NAMESPACES_INNER(tlow, thigh) \ 1492 1514 namespace x##tlow##thigh {} \ 1493 namespace y##tlow##thigh {} \ 1494 using namespace x##tlow##thigh; \ 1495 using namespace y##tlow##thigh; 1515 using namespace x##tlow##thigh; 1496 1516 1497 1517 #define ACTIVATE_COERCE_NAMESPACES(tlow) \ … … 1532 1552 #endif 1533 1553 1534 #undef DECLARE_VECTOR_TYPEDEFS 1535 #undef DECLARE_MEMBER_OPS 1536 #undef DECLARE_VECTOR_VECTOR_OP 1537 #undef DECLARE_VECTOR_VECTOR_BOOLOP 1538 #undef DECLARE_VECTOR_SCALAR_OP 1539 #undef DECLARE_BINARY_VECTOR_OPS 1540 #undef DECLARE_BINARY_NONVECTOR_OPS 1541 #undef DECLARE_UNARY_OPS 1542 #undef DECLARE_ALL_NONVECTOR_OPS 1543 #undef DECLARE_ALL_VECTOR_OPS_INNER 1544 #undef DECLARE_ALL_VECTOR_OPS 1554 #undef LOL_MEMBER_OPS 1555 1556 #undef LOL_VECTOR_VECTOR_COERCE_OP 1557 #undef LOL_VECTOR_VECTOR_OP 1558 #undef LOL_VECTOR_MINMAX_FUN 1559 #undef LOL_VECTOR_CLAMP_FUN 1560 #undef LOL_VECTOR_VECTOR_BOOL_OP 1561 #undef LOL_VECTOR_SCALAR_COERCE_OP 1562 #undef LOL_SCALAR_VECTOR_COERCE_OP 1563 #undef LOL_VECTOR_SCALAR_OP 1564 1565 #undef LOL_BINARY_VECTOR_OPS 1566 #undef LOL_BINARY_VECTOR_FUNS 1567 #undef LOL_BINARY_NONVECTOR_OPS 1568 #undef LOL_BINARY_NONVECTOR_FUNS 1569 #undef LOL_UNARY_OPS 1570 #undef LOL_UNARY_FUNS 1571 #undef LOL_BINARY_NONVECTOR_COERCE_OPS 1572 #undef LOL_BINARY_NONVECTOR_COERCE_FUNS 1573 #undef LOL_BINARY_VECTOR_COERCE_OPS 1574 #undef LOL_VECTOR_COERCE_OPS 1575 #undef LOL_VEC_3_COERCE_FUNS 1576 #undef LOL_VEC_ANY_COERCE_OPS 1577 #undef LOL_VEC_ANY_COERCE_FUNS 1578 #undef LOL_VECTOR_OPS 1579 1580 #undef LOL_ALL_NONVECTOR_OPS_AND_FUNS 1581 #undef LOL_ALL_VECTOR_OPS_INNER 1582 #undef LOL_ALL_VECTOR_FUNS_INNER 1583 #undef LOL_ALL_VECTOR_OPS_AND_FUNS 1584 #undef LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS 1545 1585 1546 1586 /*
Note: See TracChangeset
for help on using the changeset viewer.