IMP  2.1.0
The Integrative Modeling Platform
ScoreUnaryFunction.h
Go to the documentation of this file.
1 /**
2  * \file IMP/score_functor/ScoreUnaryFunction.h
3  * \brief A Score on the distance between a pair of particles.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPSCORE_FUNCTOR_SCORE_UNARY_FUNCTION_H
9 #define IMPSCORE_FUNCTOR_SCORE_UNARY_FUNCTION_H
10 
11 #include <IMP/score_functor/score_functor_config.h>
12 #include "Score.h"
13 #include <IMP/UnaryFunction.h>
14 #include <IMP/base/object_macros.h>
15 IMPSCOREFUNCTOR_BEGIN_NAMESPACE
16 
17 /** A UnaryFunction that uses a Score. This can only be used with
18  Scores that ignore their model and kernel::ParticleIndex arguments.*/
19 template <class Score, int D = 2>
21  Score score_;
22 
23  public:
24  ScoreUnaryFunction(const Score &score, std::string name = "UnaryFunction%1%")
25  : UnaryFunction(name), score_(score) {}
26 
27  virtual DerivativePair evaluate_with_derivative(double feature) const
28  IMP_OVERRIDE {
29  return score_.get_score_and_derivative(
30  nullptr, base::Array<D, kernel::ParticleIndex>(), feature);
31  }
32 
33  virtual double evaluate(double feature) const IMP_OVERRIDE {
34  return score_.get_score(nullptr, base::Array<D, kernel::ParticleIndex>(),
35  feature);
36  }
37 
39 };
40 
41 IMPSCOREFUNCTOR_END_NAMESPACE
42 
43 #endif /* IMPSCORE_FUNCTOR_SCORE_UNARY_FUNCTION_H */
Import IMP/kernel/UnaryFunction.h in the namespace.
IMP::kernel::UnaryFunction UnaryFunction
Abstract single variable functor class for score functions.
A class to store an fixed array of same-typed values.
Definition: base/Array.h:33
virtual double evaluate(double feature) const
Calculate score with respect to the given feature.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
virtual DerivativePair evaluate_with_derivative(double feature) const
Calculate score and derivative with respect to the given feature.
A Score on the distance between a pair of particles.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition: base/types.h:23
Various general useful macros for IMP.