IMP  2.0.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 ParticleIndex arguments.*/
19 template <class Score, int D=2>
21  Score score_;
22 public:
23  ScoreUnaryFunction(const Score &score, std::string name="UnaryFunction%1%"):
24  UnaryFunction(name),
25  score_(score){}
26 
27  virtual DerivativePair evaluate_with_derivative(double feature) const
28  IMP_OVERRIDE {
29  return score_.get_score_and_derivative(nullptr,
31  feature);
32  }
33 
34  virtual double evaluate(double feature) const IMP_OVERRIDE {
35  return score_.get_score(nullptr,
37  feature);
38  }
39 
41 };
42 
43 IMPSCOREFUNCTOR_END_NAMESPACE
44 
45 #endif /* IMPSCORE_FUNCTOR_SCORE_UNARY_FUNCTION_H */