/
ScoreUnaryFunction.h
43 lines (34 loc) · 1.28 KB
/
ScoreUnaryFunction.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* \file IMP/score_functor/ScoreUnaryFunction.h
* \brief A Score on the distance between a pair of particles.
*
* Copyright 2007-2022 IMP Inventors. All rights reserved.
*/
#ifndef IMPSCORE_FUNCTOR_SCORE_UNARY_FUNCTION_H
#define IMPSCORE_FUNCTOR_SCORE_UNARY_FUNCTION_H
#include <IMP/score_functor/score_functor_config.h>
#include "Score.h"
#include <IMP/UnaryFunction.h>
#include <IMP/object_macros.h>
IMPSCOREFUNCTOR_BEGIN_NAMESPACE
/** A UnaryFunction that uses a Score. This can only be used with
Scores that ignore their model and ParticleIndex arguments.*/
template <class Score, int D = 2>
class ScoreUnaryFunction : public IMP::UnaryFunction {
Score score_;
public:
ScoreUnaryFunction(const Score &score, std::string name = "UnaryFunction%1%")
: UnaryFunction(name), score_(score) {}
virtual DerivativePair evaluate_with_derivative(double feature) const
override {
return score_.get_score_and_derivative(
nullptr, Array<D, ParticleIndex>(), feature);
}
virtual double evaluate(double feature) const override {
return score_.get_score(nullptr, Array<D, ParticleIndex>(),
feature);
}
IMP_OBJECT_METHODS(ScoreUnaryFunction);
};
IMPSCOREFUNCTOR_END_NAMESPACE
#endif /* IMPSCORE_FUNCTOR_SCORE_UNARY_FUNCTION_H */