26 #ifndef radprofIntegral_hpp
27 #define radprofIntegral_hpp
31 #include <type_traits>
33 #include "../mxException.hpp"
35 #include "constants.hpp"
61 template<
typename vectorScT,
typename vectorT>
67 typedef typename vectorT::value_type floatT;
69 static_assert( std::is_floating_point<
typename std::remove_cv<floatT>::type>::value,
"radprofIntegral: function must be floating point");
71 if(r.size() != p.size())
73 mxThrowException(
err::sizeerr,
"radprofIntegral",
"vectors must have same size");
78 mxThrowException(
err::sizeerr,
"radprofIntegral",
"must be at least 2 elements in radial profile");
83 if(inczero) s = p[0]*pow(r[0],2);
86 s += 0.5*p[n]*(pow(r[n+1],2) - pow(r[n],2));
88 for(n=1; n < r.size()-1; ++n)
90 s += p[n]*(pow(r[n],2) - pow(r[n-1],2));
93 s += 0.5*p[n]*(pow(r[n],2) - pow(r[n-1],2));
98 return s*pi<floatT>();
mxException for a size error
vectorT::value_type radprofIntegral(vectorScT r, vectorT p, bool inczero=false)
Calculate the 2D integral given a radial profile.