Home | History | Annotate | Download | only in gtx
      1 ///////////////////////////////////////////////////////////////////////////////////////////////////
      2 // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
      3 ///////////////////////////////////////////////////////////////////////////////////////////////////
      4 // Created : 2005-12-21
      5 // Updated : 2005-12-27
      6 // Licence : This source is under MIT License
      7 // File    : glm/gtx/optimum_pow.inl
      8 ///////////////////////////////////////////////////////////////////////////////////////////////////
      9 
     10 namespace glm
     11 {
     12 	template <typename genType>
     13 	GLM_FUNC_QUALIFIER genType pow2(genType const & x)
     14 	{
     15 		return x * x;
     16 	}
     17 
     18 	template <typename genType>
     19 	GLM_FUNC_QUALIFIER genType pow3(genType const & x)
     20 	{
     21 		return x * x * x;
     22 	}
     23 
     24 	template <typename genType>
     25 	GLM_FUNC_QUALIFIER genType pow4(genType const & x)
     26 	{
     27 		return (x * x) * (x * x);
     28 	}
     29 
     30 	GLM_FUNC_QUALIFIER bool powOfTwo(int x)
     31 	{
     32 		return !(x & (x - 1));
     33 	}
     34 
     35 	template <precision P>
     36 	GLM_FUNC_QUALIFIER detail::tvec2<bool, P> powOfTwo(detail::tvec2<int, P> const & x)
     37 	{
     38 		return detail::tvec2<bool, P>(
     39 			powOfTwo(x.x),
     40 			powOfTwo(x.y));
     41 	}
     42 
     43 	template <precision P>
     44 	GLM_FUNC_QUALIFIER detail::tvec3<bool, P> powOfTwo(detail::tvec3<int, P> const & x)
     45 	{
     46 		return detail::tvec3<bool, P>(
     47 			powOfTwo(x.x),
     48 			powOfTwo(x.y),
     49 			powOfTwo(x.z));
     50 	}
     51 
     52 	template <precision P>
     53 	GLM_FUNC_QUALIFIER detail::tvec4<bool, P> powOfTwo(detail::tvec4<int, P> const & x)
     54 	{
     55 		return detail::tvec4<bool, P>(
     56 			powOfTwo(x.x),
     57 			powOfTwo(x.y),
     58 			powOfTwo(x.z),
     59 			powOfTwo(x.w));
     60 	}
     61 }//namespace glm
     62