IMP logo
IMP Reference Guide  develop.36b5e40f34,2024/10/14
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-2022 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/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 
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  override {
29  return score_.get_score_and_derivative(
30  nullptr, Array<D, ParticleIndex>(), feature);
31  }
32 
33  virtual double evaluate(double feature) const override {
34  return score_.get_score(nullptr, Array<D, ParticleIndex>(),
35  feature);
36  }
37 
39 };
40 
41 IMPSCOREFUNCTOR_END_NAMESPACE
42 
43 #endif /* IMPSCORE_FUNCTOR_SCORE_UNARY_FUNCTION_H */
Helper macros for implementing IMP Objects.
A class to store a fixed array of same-typed values.
Definition: Array.h:40
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Single variable function.
virtual DerivativePair evaluate_with_derivative(double feature) const override
Calculate score and derivative with respect to the given feature.
A Score on the distance between a pair of particles.
virtual double evaluate(double feature) const override
Calculate score with respect to the given feature.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition: types.h:22
A functor for computing a distance based score for D particles.
Definition: Score.h:20
Abstract single variable functor class for score functions.
Definition: UnaryFunction.h:27