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 : 2007-05-21
      5 // Updated : 2010-02-12
      6 // Licence : This source is under MIT License
      7 // File    : gtx_component_wise.inl
      8 ///////////////////////////////////////////////////////////////////////////////////////////////////
      9 
     10 namespace glm
     11 {
     12 	template <typename T, precision P, template <typename, precision> class vecType>
     13 	GLM_FUNC_QUALIFIER T compAdd(vecType<T, P> const & v)
     14 	{
     15 		T result(0);
     16 		for(length_t i = 0; i < v.length(); ++i)
     17 			result += v[i];
     18 		return result;
     19 	}
     20 
     21 	template <typename T, precision P, template <typename, precision> class vecType>
     22 	GLM_FUNC_QUALIFIER T compMul(vecType<T, P> const & v)
     23 	{
     24 		T result(1);
     25 		for(length_t i = 0; i < v.length(); ++i)
     26 			result *= v[i];
     27 		return result;
     28 	}
     29 
     30 	template <typename T, precision P, template <typename, precision> class vecType>
     31 	GLM_FUNC_QUALIFIER T compMin(vecType<T, P> const & v)
     32 	{
     33 		T result(v[0]);
     34 		for(length_t i = 1; i < v.length(); ++i)
     35 			result = min(result, v[i]);
     36 		return result;
     37 	}
     38 
     39 	template <typename T, precision P, template <typename, precision> class vecType>
     40 	GLM_FUNC_QUALIFIER T compMax(vecType<T, P> const & v)
     41 	{
     42 		T result(v[0]);
     43 		for(length_t i = 1; i < v.length(); ++i)
     44 			result = max(result, v[i]);
     45 		return result;
     46 	}
     47 }//namespace glm
     48