ProteoWizard
Classes | Functions
pwiz::frequency::DerivativeTest Namespace Reference

Classes

class  VectorFunction
class  ParametrizedFunctionSlice
class  ParametrizedDerivativeSlice
class  AdaptedErrorFunction
class  AdaptedErrorDerivative

Functions

template<typename value_type >
void testDerivatives (const ParametrizedFunction< value_type > &f, double x, const ublas::vector< double > &p, std::ostream *os=0, double delta=1e-7, double epsilon=1e-4)
template<typename value_type >
void testDerivatives (const typename ParametrizedFunction< value_type >::ErrorFunction &e, const ublas::vector< double > &p, std::ostream *os=0, double delta=1e-7, double epsilon=1e-4)

Function Documentation

template<typename value_type >
void pwiz::frequency::DerivativeTest::testDerivatives ( const ParametrizedFunction< value_type > &  f,
double  x,
const ublas::vector< double > &  p,
std::ostream *  os = 0,
double  delta = 1e-7,
double  epsilon = 1e-4 
)

Definition at line 194 of file DerivativeTest.hpp.

References pwiz::frequency::DerivativeTest::VectorFunction< value_type >::differenceQuotient(), pwiz::frequency::ParametrizedFunction< value_type >::dp(), pwiz::frequency::ParametrizedFunction< value_type >::dp2(), epsilon, pwiz::frequency::DerivativeTest::VectorFunction< value_type >::printDifferenceQuotientSequence(), and unit_assert_matrices_equal.

{
using namespace std;
if (os)
{
*os << "x: " << x << endl;
*os << "p: " << p << endl;
}
if (os) *os << "f.dp: " << f.dp(x,p) << endl;
ParametrizedFunctionSlice<value_type> slice(f,x);
if (os) slice.printDifferenceQuotientSequence(p, *os);
ublas::matrix<value_type> dp(f.dp(x,p).size(),1);
column(dp,0) = f.dp(x,p);
unit_assert_matrices_equal(dp, slice.differenceQuotient(p,delta), epsilon);
if (os) *os << "f.dp2: " << f.dp2(x,p) << endl;
ParametrizedDerivativeSlice<value_type> derivativeSlice(f,x);
if (os) derivativeSlice.printDifferenceQuotientSequence(p, *os);
unit_assert_matrices_equal(f.dp2(x,p), derivativeSlice.differenceQuotient(p,delta), epsilon);
}
template<typename value_type >
void pwiz::frequency::DerivativeTest::testDerivatives ( const typename ParametrizedFunction< value_type >::ErrorFunction &  e,
const ublas::vector< double > &  p,
std::ostream *  os = 0,
double  delta = 1e-7,
double  epsilon = 1e-4 
)

Definition at line 226 of file DerivativeTest.hpp.

References pwiz::frequency::DerivativeTest::VectorFunction< double >::differenceQuotient(), pwiz::frequency::ParametrizedFunction< value_type >::ErrorFunction::dp(), pwiz::frequency::ParametrizedFunction< value_type >::ErrorFunction::dp2(), epsilon, pwiz::frequency::DerivativeTest::VectorFunction< double >::printDifferenceQuotientSequence(), and unit_assert_matrices_equal.

{
using namespace std;
if (os) *os << "p: " << p << endl;
if (os) *os << "e.dp: " << e.dp(p) << endl;
AdaptedErrorFunction<value_type> adapted(e);
if (os) adapted.printDifferenceQuotientSequence(p, *os);
ublas::matrix<value_type> dp(e.dp(p).size(), 1);
column(dp,0) = e.dp(p);
unit_assert_matrices_equal(dp, adapted.differenceQuotient(p,delta), epsilon);
if (os) *os << "e.dp2: " << e.dp2(p) << endl;
AdaptedErrorDerivative<value_type> adaptedDerivative(e);
if (os) adaptedDerivative.printDifferenceQuotientSequence(p, *os);
unit_assert_matrices_equal(e.dp2(p), adaptedDerivative.differenceQuotient(p,delta), epsilon);
}