7 #ifndef IMPCORE_HARMONIC_WELL_H
8 #define IMPCORE_HARMONIC_WELL_H
10 #include <IMP/core/core_config.h>
14 IMPCORE_BEGIN_NAMESPACE
26 double get_score(
double x)
const {
28 return .5 * k_ * square(x - lb_);
30 return .5 * k_ * square(x - ub_);
34 double get_derivative(
double x)
const {
36 return k_ * (x - lb_);
38 return k_ * (x - ub_);
46 : lb_(well.first), ub_(well.second), k_(k) {
48 "The width should be non-negative");
53 return DerivativePair(get_score(feature), get_derivative(feature));
56 virtual double evaluate(
double feature)
const {
return get_score(feature); }
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Single variable function.
std::pair< Float, Float > FloatRange
A pair representing the allowed range for a Float attribute.
A more IMP-like version of the std::vector.
A well with harmonic barriers.
HarmonicWell(const FloatRange &well, double k)
Initialize with the lower and upper bounds and the spring constant.
virtual DerivativePair evaluate_with_derivative(double feature) const
Calculate score and derivative with respect to the given feature.
virtual double evaluate(double feature) const
Calculate score with respect to the given feature.
For backwards compatibility.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Abstract single variable functor class for score functions.