53 template <
typename ScalarT>
54 void func(ScalarT& f,
const ScalarT& x) {
58 int main(
int argc,
char **argv)
70 for (
int k=0; k<deg; k++) {
86 for (
int k=0; k<deg; k++) {
88 for (
int j=0; j<=k; j++)
94 std::cout <<
"Taylor series solution = " << std::endl
98 std::cout <<
"Taylor series solution derivative= " << std::endl
99 << dxdx0 << std::endl;
112 std::cout <<
"Exact expansion = " << std::endl
116 std::cout <<
"Exact expansion derivative = " << std::endl
117 << dudx0 << std::endl;
120 double max_err = 0.0;
122 for (
int k=0; k<=deg; k++) {
124 if (err > max_err) max_err = err;
126 std::cout <<
"Maximum relative error = " << max_err << std::endl;
129 double deriv_max_err = 0.0;
130 double deriv_err = 0.0;
131 for (
int k=0; k<=deg; k++) {
134 if (deriv_err > deriv_max_err) deriv_max_err = deriv_err;
136 std::cout <<
"Maximum derivative relative error = " << deriv_max_err
139 double tol = 1.0e-12;
140 if ((max_err < tol) && (deriv_max_err < tol)) {
141 std::cout <<
"\nExample passed!" << std::endl;
145 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)