7 #ifndef IMPCORE_LINEAR_H
8 #define IMPCORE_LINEAR_H
10 #include <IMP/core/core_config.h>
13 IMPCORE_BEGIN_NAMESPACE
22 Linear(
double offset,
double slope) : slope_(slope), offset_(offset) {}
24 void set_slope(
double f) { slope_ = f; }
26 void set_offset(
double f) { offset_ = f; }
28 virtual double evaluate(
double feature)
const override {
29 return (feature - offset_) * slope_;
40 double slope_, offset_;
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Single variable function.
virtual DerivativePair evaluate_with_derivative(double feature) const override
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.
virtual double evaluate(double feature) const override
Calculate score with respect to the given feature.
Linear(double offset, double slope)
Create with the given offset and slope.
Abstract single variable functor class for score functions.