7 #ifndef IMPCORE_LINEAR_H
8 #define IMPCORE_LINEAR_H
10 #include <IMP/core/core_config.h>
12 #include <cereal/access.hpp>
13 #include <cereal/types/base_class.hpp>
14 #include <cereal/types/polymorphic.hpp>
16 IMPCORE_BEGIN_NAMESPACE
25 Linear(
double offset,
double slope) : slope_(slope), offset_(offset) {}
28 void set_slope(
double f) { slope_ = f; }
30 void set_offset(
double f) { offset_ = f; }
32 virtual double evaluate(
double feature)
const override {
33 return (feature - offset_) * slope_;
44 double slope_, offset_;
46 friend class cereal::access;
48 template<
class Archive>
void serialize(Archive &ar) {
49 ar(cereal::base_class<UnaryFunction>(
this),
#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.
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
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.