9#ifndef IMPEXAMPLE_EXAMPLE_UNARY_FUNCTION_H
10#define IMPEXAMPLE_EXAMPLE_UNARY_FUNCTION_H
12#include <IMP/example/example_config.h>
16#include <cereal/access.hpp>
17#include <cereal/types/base_class.hpp>
18#include <cereal/types/polymorphic.hpp>
20IMPEXAMPLE_BEGIN_NAMESPACE
41 Float get_center()
const {
return center_; }
42 Float get_force_constant()
const {
return k_; }
48 virtual double evaluate(
double feature)
const override {
49 return .5 * k_ * algebra::get_squared(feature - center_);
54 friend class cereal::access;
55 template<
class Archive>
void serialize(Archive &ar) {
56 ar(cereal::base_class<UnaryFunction>(
this), center_, k_);
61IMPEXAMPLE_END_NAMESPACE
Single variable function.
Functions to deal with very common math operations.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
virtual DerivativePair evaluate_with_derivative(double feature) const override
Calculate score and derivative with respect to the given feature.
virtual double evaluate(double feature) const override
Calculate score with respect to the given feature.
ExampleUnaryFunction(Float center, Float k)
double Float
Basic floating-point value (could be float, double...).
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Various general useful functions for IMP.