24#ifndef _DERIVATIVETEST_HPP_
25#define _DERIVATIVETEST_HPP_
38namespace DerivativeTest {
48template<
typename value_type>
55 virtual ublas::vector<value_type>
operator()(ublas::vector<double>
x)
const = 0;
59 std::ostream& os)
const;
66template<
typename value_type>
69 ublas::matrix<value_type> result(argumentCount(), valueCount());
71 for (
unsigned int i=0; i<argumentCount(); i++)
73 ublas::vector<double> x2(
x);
75 row(result, i) = ((*this)(x2)-(*
this)(
x))/delta;
81template<
typename value_type>
83 std::ostream& os)
const
87 for (
double delta=.1; delta>1e-9; delta/=10)
89 os << scientific << setprecision(1) <<
"[delta: " << delta <<
"] ";
90 os.unsetf(std::ios::scientific);
91 os << setprecision(8) << differenceQuotient(
x, delta) << endl;
100template<
typename value_type>
111 virtual ublas::vector<value_type>
operator()(ublas::vector<double> p)
const
113 ublas::vector<value_type> result(1);
114 result(0) =
f_(
x_, p);
124template<
typename value_type>
135 virtual ublas::vector<value_type>
operator()(ublas::vector<double> p)
const
146template<
typename value_type>
157 virtual ublas::vector<double>
operator()(ublas::vector<double> p)
const
159 ublas::vector<double> result(1);
169template<
typename value_type>
180 virtual ublas::vector<double>
operator()(ublas::vector<double> p)
const
193template<
typename value_type>
196 const ublas::vector<double>& p,
197 std::ostream* os = 0,
205 *os <<
"x: " <<
x << endl;
206 *os <<
"p: " << p << endl;
209 if (os) *os <<
"f.dp: " << f.
dp(
x,p) << endl;
213 ublas::matrix<value_type> dp(f.
dp(
x,p).size(),1);
214 column(dp,0) = f.
dp(
x,p);
217 if (os) *os <<
"f.dp2: " << f.
dp2(
x,p) << endl;
225template<
typename value_type>
227 const ublas::vector<double>& p,
228 std::ostream* os = 0,
234 if (os) *os <<
"p: " << p << endl;
236 if (os) *os <<
"e.dp: " << e.
dp(p) << endl;
240 ublas::matrix<value_type> dp(e.
dp(p).size(), 1);
241 column(dp,0) = e.
dp(p);
244 if (os) *os <<
"e.dp2: " << e.
dp2(p) << endl;
KernelTraitsBase< Kernel >::space_type::abscissa_type x
virtual unsigned int argumentCount() const
const ParametrizedFunction< value_type >::ErrorFunction & e_
virtual unsigned int valueCount() const
AdaptedErrorDerivative(const typename ParametrizedFunction< value_type >::ErrorFunction &e)
virtual ublas::vector< double > operator()(ublas::vector< double > p) const
virtual unsigned int argumentCount() const
virtual ublas::vector< double > operator()(ublas::vector< double > p) const
AdaptedErrorFunction(const typename ParametrizedFunction< value_type >::ErrorFunction &e)
const ParametrizedFunction< value_type >::ErrorFunction & e_
virtual unsigned int valueCount() const
ParametrizedDerivativeSlice(const ParametrizedFunction< value_type > &f, double x)
virtual unsigned int argumentCount() const
virtual ublas::vector< value_type > operator()(ublas::vector< double > p) const
const ParametrizedFunction< value_type > & f_
virtual unsigned int valueCount() const
ParametrizedFunctionSlice(const ParametrizedFunction< value_type > &f, double x)
virtual ublas::vector< value_type > operator()(ublas::vector< double > p) const
const ParametrizedFunction< value_type > & f_
virtual unsigned int argumentCount() const
virtual unsigned int valueCount() const
virtual ublas::vector< value_type > operator()(ublas::vector< double > x) const =0
virtual unsigned int valueCount() const =0
virtual unsigned int argumentCount() const =0
virtual ~VectorFunction()
void printDifferenceQuotientSequence(ublas::vector< double > x, std::ostream &os) const
ublas::matrix< value_type > differenceQuotient(ublas::vector< double > x, double delta) const
ublas::vector< double > dp(const ublas::vector< double > &p) const
ublas::matrix< double > dp2(const ublas::vector< double > &p) const
virtual ublas::matrix< value_type > dp2(double x, const ublas::vector< double > &p) const =0
virtual ublas::vector< value_type > dp(double x, const ublas::vector< double > &p) const =0
#define unit_assert_matrices_equal(A, B, epsilon)