31 template <
typename ScalarT>
32 void func(ScalarT& f,
const ScalarT&
x) {
36 int main(
int argc,
char **argv)
48 for (
int k=0; k<deg; k++) {
64 for (
int k=0; k<deg; k++) {
66 for (
int j=0; j<=k; j++)
72 std::cout <<
"Taylor series solution = " << std::endl
76 std::cout <<
"Taylor series solution derivative= " << std::endl
77 << dxdx0 << std::endl;
90 std::cout <<
"Exact expansion = " << std::endl
94 std::cout <<
"Exact expansion derivative = " << std::endl
95 << dudx0 << std::endl;
100 for (
int k=0; k<=deg; k++) {
102 if (err > max_err) max_err = err;
104 std::cout <<
"Maximum relative error = " << max_err << std::endl;
107 double deriv_max_err = 0.0;
108 double deriv_err = 0.0;
109 for (
int k=0; k<=deg; k++) {
112 if (deriv_err > deriv_max_err) deriv_max_err = deriv_err;
114 std::cout <<
"Maximum derivative relative error = " << deriv_max_err
117 double tol = 1.0e-12;
118 if ((max_err < tol) && (deriv_max_err < tol)) {
119 std::cout <<
"\nExample passed!" << std::endl;
123 std::cout <<
"\nSomething is wrong, example failed!" << std::endl;
void resize(int d, bool keep_coeffs)
Resize polynomial to degree d.
T & fastAccessCoeff(int i)
Returns degree i term without bounds checking.
const T * coeff() const
Returns Taylor coefficient array.
void reserve(int d)
Reserve space for a degree d polynomial.
const T func(int n, T *x)