IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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-2026 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>
15IMPSCOREFUNCTOR_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.*/
19template <class Score, int D = 2>
20class ScoreUnaryFunction : public IMP::UnaryFunction {
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
38#ifndef SWIG
39 const Score &get_score() const { return score_; }
40#endif
41
42 IMP_OBJECT_METHODS(ScoreUnaryFunction);
43};
44
45IMPSCOREFUNCTOR_END_NAMESPACE
46
47#endif /* IMPSCORE_FUNCTOR_SCORE_UNARY_FUNCTION_H */
A Score on the distance between a pair of particles.
Single variable function.
A class to store a fixed array of same-typed values.
Definition Array.h:40
Abstract single variable functor class for score functions.
virtual double evaluate(double feature) const override
Calculate score with respect to the given feature.
virtual DerivativePair evaluate_with_derivative(double feature) const override
Calculate score and derivative 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
Helper macros for implementing IMP Objects.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
A functor for computing a distance based score for D particles.
Definition Score.h:20