IMP  2.4.0
The Integrative Modeling Platform
kernel/UnaryFunction.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kernel/UnaryFunction.h \brief Single variable function.
3  *
4  * Copyright 2007-2015 IMP Inventors. All rights reserved.
5  */
6 
7 #ifndef IMPKERNEL_UNARY_FUNCTION_H
8 #define IMPKERNEL_UNARY_FUNCTION_H
9 
10 #include <IMP/kernel/kernel_config.h>
11 #include "base_types.h"
12 #include <IMP/base/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::base::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 FloatPair containing the score and its partial derivative
46  with respect to the given feaure.
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 */
virtual DerivativePair evaluate_with_derivative(double feature) const
Calculate score and derivative with respect to the given feature.
IMP::kernel::UnaryFunction UnaryFunction
Basic types used by IMP.
#define IMP_REF_COUNTED_DESTRUCTOR(Name)
Ref counted objects should have private destructors.
Abstract single variable functor class for score functions.
virtual double evaluate(double feature) const
Calculate score with respect to the given feature.
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 sets of objects.
Definition: object_macros.h:52
A shared base class to help in debugging and things.