#ifndef glas_square_abs_hpp #define glas_square_abs_hpp #include #include #include #ifdef GLAS_COMPLEX # include #endif #include namespace glas { template struct square_abs_functor { typedef T argument_type ; typedef typename abs_functor::result_type result_type ; BOOST_STATIC_ASSERT( (boost::is_integral::value || boost::is_float::value) ) ; inline result_type operator() ( argument_type const& t ) const { return t * t ; } }; #ifdef GLAS_COMPLEX template struct square_abs_functor< std::complex > { typedef std::complex argument_type ; typedef typename abs_functor::result_type result_type ; inline result_type operator() ( argument_type const& t ) const { return t.real() * t.real() + t.imag() * t.imag() ; } }; #endif // GLAS_COMPLEX template inline typename square_abs_functor::result_type square_abs( T const& t ) { return square_abs_functor() ( t ) ; } } #endif // glas_square_abs_hpp