TuttleOFX  1
sqrt.hpp
Go to the documentation of this file.
00001 #ifndef _TERRY_NUMERIC_SQRT_HPP_
00002 #define _TERRY_NUMERIC_SQRT_HPP_
00003 
00004 #include <terry/numeric/operations.hpp>
00005 #include <terry/globals.hpp>
00006 
00007 #include <boost/gil/color_base_algorithm.hpp>
00008 
00009 #include <cmath>
00010 
00011 namespace terry {
00012 namespace numeric {
00013 
00014 template <typename Channel, typename ChannelR>
00015 struct channel_sqrt_t : public std::unary_function<Channel, ChannelR>
00016 {
00017         GIL_FORCEINLINE
00018         ChannelR operator( )( typename channel_traits<Channel>::const_reference ch ) const
00019         {
00020                 typedef typename floating_channel_type_t<ChannelR>::type T;
00021                 return std::sqrt( T( ch ) );
00022         }
00023 };
00024 
00025 template <typename PixelRef, typename PixelR = PixelRef> // models pixel concept
00026 struct pixel_sqrt_t
00027 {
00028         GIL_FORCEINLINE
00029         PixelR operator ( ) (const PixelRef & p ) const
00030         {
00031                 PixelR result;
00032                 boost::gil::static_transform( p, result, channel_sqrt_t<typename channel_type<PixelRef>::type, typename channel_type<PixelR>::type > ( ) );
00033                 return result;
00034         }
00035 };
00036 
00037 }
00038 }
00039 
00040 #endif