IMP logo
IMP Reference Guide  2.10.0
The Integrative Modeling Platform
UnaryFunction.h
Go to the documentation of this file.
1 /**
2  * \file IMP/UnaryFunction.h \brief Single variable function.
3  *
4  * Copyright 2007-2018 IMP Inventors. All rights reserved.
5  */
6 
7 #ifndef IMPKERNEL_UNARY_FUNCTION_H
8 #define IMPKERNEL_UNARY_FUNCTION_H
9 
10 #include <IMP/kernel_config.h>
11 #include "base_types.h"
12 #include <IMP/Object.h>
13 
14 IMPKERNEL_BEGIN_NAMESPACE
15 
16 //! Abstract single variable functor class for score functions.
17 /** These functors take a single feature value, and return a corresponding
18  score (and optionally also the first derivative).
19 
20  Implementers should implement two functions:
21  - virtual double evaluate(double feature) const
22  - virtual DerivativePair evaluate_with_derivative(double feature) const
23  also add IMP_OBJECT_METHODS(Name) macro for Object methods
24  */
25 class IMPKERNELEXPORT UnaryFunction : public IMP::Object {
26  public:
27  UnaryFunction(std::string name = "UnaryFunction%1%");
28 
29  //! Calculate score with respect to the given feature.
30  /** \param[in] feature Value of feature being tested.
31  \return Score
32  */
33  virtual double evaluate(double feature) const
34 #ifdef SWIG
35  = 0;
36 #else
37  {
38  // to support easy generic classes
39  return evaluate(feature);
40  }
41 #endif
42 
43  //! Calculate score and derivative with respect to the given feature.
44  /** \param[in] feature Value of feature being tested.
45  \return a DerivativePair containing the score and its partial derivative
46  with respect to the given feature.
47  */
48  virtual DerivativePair evaluate_with_derivative(double feature) const {
49  // to support easy generic classes
50  return evaluate_with_derivative(feature);
51  }
52 
54 };
55 
57 
58 IMPKERNEL_END_NAMESPACE
59 
60 #endif /* IMPKERNEL_UNARY_FUNCTION_H */
Basic types used by IMP.
virtual double evaluate(double feature) const
Calculate score with respect to the given feature.
Definition: UnaryFunction.h:33
#define IMP_REF_COUNTED_DESTRUCTOR(Name)
Ref counted objects should have private destructors.
Common base class for heavy weight IMP objects.
Definition: Object.h:106
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition: types.h:23
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Definition: object_macros.h:44
A shared base class to help in debugging and things.
virtual DerivativePair evaluate_with_derivative(double feature) const
Calculate score and derivative with respect to the given feature.
Definition: UnaryFunction.h:48
Abstract single variable functor class for score functions.
Definition: UnaryFunction.h:25