7 #ifndef IMPCORE_LINEAR_H
8 #define IMPCORE_LINEAR_H
10 #include <IMP/core/core_config.h>
14 IMPCORE_BEGIN_NAMESPACE
23 Linear(
double offset,
double slope) : slope_(slope), offset_(offset) {}
25 void set_slope(
double f) { slope_ = f; }
27 void set_offset(
double f) { offset_ = f; }
29 virtual double evaluate(
double feature)
const IMP_OVERRIDE {
30 return (feature - offset_) * slope_;
41 double slope_, offset_;
virtual double evaluate(double feature) const
Calculate score with respect to the given feature.
Import IMP/kernel/UnaryFunction.h in the namespace.
Abstract single variable functor class for score functions.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
virtual DerivativePair evaluate_with_derivative(double feature) const
Calculate score and derivative with respect to the given feature.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Import IMP/kernel/unary_function_macros.h in the namespace.
Linear(double offset, double slope)
Create with the given offset and slope.