Я написал код реализации расчета любого порядка производной (значение) функции std :: tgamma (). Но этот код часто пересматривает выражения. Как можно это оптимизировать? < /P>
#include
#include
#include
namespace peter
{
template
struct multiplication;
template
struct polygamma
{ struct derivative
{ typedef polygamma type;
};
double operator()(const double _d) const
{ return boost::math::polygamma(ORDER, _d);
}
};
struct gamma
{ struct derivative
{ typedef multiplication type;
};
double operator()(const double _d) const
{ return std::tgamma(_d);
}
};
template
struct addition
{ struct derivative
{ typedef addition<
typename L::derivative::type,
typename R::derivative::type
> type;
};
double operator()(const double _d) const
{ return L()(_d) + R()(_d);
}
};
template
struct multiplication
{ struct derivative
{ typedef addition<
multiplication<
typename L::derivative::type,
R
>,
multiplication<
L,
typename R::derivative::type
>
> type;
};
double operator()(const double _d) const
{ return L()(_d) * R()(_d);
}
};
template
struct derive
{ typedef typename derive::type::derivative::type type;
};
template
struct derive
{ typedef T type;
};
}
int main()
{ //using namespace peter;
peter::derive
::type s;
std::cout
Подробнее здесь: https://stackoverflow.com/questions/793 ... r-any-give