IMP logo
IMP Reference Guide  2.20.2
The Integrative Modeling Platform
UnaryFunctionEvaluate.h
Go to the documentation of this file.
1 /**
2  * \file IMP/score_functor/UnaryFunctionEvaluate.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_UNARY_FUNCTION_EVALUATE_H
9 #define IMPSCORE_FUNCTOR_UNARY_FUNCTION_EVALUATE_H
10 
11 #include <IMP/score_functor/score_functor_config.h>
12 #include "Score.h"
13 #include <IMP/UnaryFunction.h>
14 #include <IMP/value_macros.h>
15 #include <IMP/Pointer.h>
16 #include <cereal/access.hpp>
17 
18 IMPSCOREFUNCTOR_BEGIN_NAMESPACE
19 
20 /** A DistanceScore that uses a UnaryFunction.*/
21 class UnaryFunctionEvaluate : public Score {
23 
24  friend class cereal::access;
25 
26  template<class Archive> void serialize(Archive &ar) {
27  ar(uf_);
28  }
29 
30  public:
33  template <unsigned int D>
34  double get_score(Model *,
36  double distance) const {
37  return uf_->evaluate(distance);
38  }
39  template <unsigned int D>
40  DerivativePair get_score_and_derivative(
41  Model *, const Array<D, ParticleIndex> &,
42  double distance) const {
43  return uf_->evaluate_with_derivative(distance);
44  }
45 };
46 
47 IMPSCOREFUNCTOR_END_NAMESPACE
48 
49 #endif /* IMPSCORE_FUNCTOR_UNARY_FUNCTION_EVALUATE_H */
A class to store a fixed array of same-typed values.
Definition: Array.h:35
Single variable function.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
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: types.h:22
A nullptr-initialized pointer to an IMP Object.
Macros to help in implementing Value objects.
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