4 #include <boost/math/special_functions/legendre.hpp>    13         throw itk::ExceptionObject(__FILE__, __LINE__,
    14                                    "Legendre polynomials first derivative only implemented for L > 1",ITK_LOCATION);
    22         factor = std::tgamma(L - M + 1) / std::tgamma (L + M + 1);
    27     double sqValue = value * value;
    28     if (fabs (value) == 1)
    35         sqValue = value * value;
    38     double resVal = L * value * boost::math::legendre_p(L,M,value) - (L+M) * boost::math::legendre_p(L-1,M,value);
    40     resVal *= factor / (sqValue - 1.0);
    49         throw itk::ExceptionObject(__FILE__, __LINE__,
    50                                    "Legendre polynomials second derivative only implemented for L > 2",ITK_LOCATION);
    58         factor = std::tgamma (L - M + 1) / std::tgamma (L + M + 1);
    63     double sqValue = value * value;
    64     if (fabs (value) == 1)
    71         sqValue = value * value;
    74     double resVal = L * ((L - 1) * sqValue - 1) * boost::math::legendre_p(L,M,value);
    75     resVal += (L + M) * (3 - 2*L) * value * boost::math::legendre_p(L-1,M,value);
    76     resVal += (L + M) * (L + M - 1) * boost::math::legendre_p(L-2,M,value);
    78     resVal *= factor / ((sqValue - 1.0) * (sqValue - 1.0));
 double legendre_second_derivative(int L, int M, double value)
double legendre_first_derivative(int L, int M, double value)