• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/// @ref core
2/// @file glm/detail/func_vector_relational.inl
3
4#include <limits>
5
6namespace glm
7{
8	template <typename T, precision P, template <typename, precision> class vecType>
9	GLM_FUNC_QUALIFIER vecType<bool, P> lessThan(vecType<T, P> const & x, vecType<T, P> const & y)
10	{
11		assert(x.length() == y.length());
12
13		vecType<bool, P> Result(uninitialize);
14		for(length_t i = 0; i < x.length(); ++i)
15			Result[i] = x[i] < y[i];
16
17		return Result;
18	}
19
20	template <typename T, precision P, template <typename, precision> class vecType>
21	GLM_FUNC_QUALIFIER vecType<bool, P> lessThanEqual(vecType<T, P> const & x, vecType<T, P> const & y)
22	{
23		assert(x.length() == y.length());
24
25		vecType<bool, P> Result(uninitialize);
26		for(length_t i = 0; i < x.length(); ++i)
27			Result[i] = x[i] <= y[i];
28		return Result;
29	}
30
31	template <typename T, precision P, template <typename, precision> class vecType>
32	GLM_FUNC_QUALIFIER vecType<bool, P> greaterThan(vecType<T, P> const & x, vecType<T, P> const & y)
33	{
34		assert(x.length() == y.length());
35
36		vecType<bool, P> Result(uninitialize);
37		for(length_t i = 0; i < x.length(); ++i)
38			Result[i] = x[i] > y[i];
39		return Result;
40	}
41
42	template <typename T, precision P, template <typename, precision> class vecType>
43	GLM_FUNC_QUALIFIER vecType<bool, P> greaterThanEqual(vecType<T, P> const & x, vecType<T, P> const & y)
44	{
45		assert(x.length() == y.length());
46
47		vecType<bool, P> Result(uninitialize);
48		for(length_t i = 0; i < x.length(); ++i)
49			Result[i] = x[i] >= y[i];
50		return Result;
51	}
52
53	template <typename T, precision P, template <typename, precision> class vecType>
54	GLM_FUNC_QUALIFIER vecType<bool, P> equal(vecType<T, P> const & x, vecType<T, P> const & y)
55	{
56		assert(x.length() == y.length());
57
58		vecType<bool, P> Result(uninitialize);
59		for(length_t i = 0; i < x.length(); ++i)
60			Result[i] = x[i] == y[i];
61		return Result;
62	}
63
64	template <typename T, precision P, template <typename, precision> class vecType>
65	GLM_FUNC_QUALIFIER vecType<bool, P> notEqual(vecType<T, P> const & x, vecType<T, P> const & y)
66	{
67		assert(x.length() == y.length());
68
69		vecType<bool, P> Result(uninitialize);
70		for(length_t i = 0; i < x.length(); ++i)
71			Result[i] = x[i] != y[i];
72		return Result;
73	}
74
75	template <precision P, template <typename, precision> class vecType>
76	GLM_FUNC_QUALIFIER bool any(vecType<bool, P> const & v)
77	{
78		bool Result = false;
79		for(length_t i = 0; i < v.length(); ++i)
80			Result = Result || v[i];
81		return Result;
82	}
83
84	template <precision P, template <typename, precision> class vecType>
85	GLM_FUNC_QUALIFIER bool all(vecType<bool, P> const & v)
86	{
87		bool Result = true;
88		for(length_t i = 0; i < v.length(); ++i)
89			Result = Result && v[i];
90		return Result;
91	}
92
93	template <precision P, template <typename, precision> class vecType>
94	GLM_FUNC_QUALIFIER vecType<bool, P> not_(vecType<bool, P> const & v)
95	{
96		vecType<bool, P> Result(uninitialize);
97		for(length_t i = 0; i < v.length(); ++i)
98			Result[i] = !v[i];
99		return Result;
100	}
101}//namespace glm
102
103#if GLM_ARCH != GLM_ARCH_PURE && GLM_HAS_UNRESTRICTED_UNIONS
104#	include "func_vector_relational_simd.inl"
105#endif
106