8 #ifndef IMPSCORE_FUNCTOR_ADD_SCORES_H
9 #define IMPSCORE_FUNCTOR_ADD_SCORES_H
11 #include <IMP/score_functor/score_functor_config.h>
14 IMPSCOREFUNCTOR_BEGIN_NAMESPACE
17 template <
class BaseDistanceScore0,
class BaseDistanceScore1>
19 typedef BaseDistanceScore0 P0;
20 typedef BaseDistanceScore1 P1;
25 AddScores(BaseDistanceScore0 p0, BaseDistanceScore1 p1) : p0_(p0), p1_(p1) {}
26 template <
unsigned int D>
27 double get_score(
Model *m,
29 double distance)
const {
30 return p0_.get_score(m, pi, distance) + p1_.get_score(m, pi, distance);
32 template <
unsigned int D>
35 double distance)
const {
36 DerivativePair ret0 = p0_.get_score_and_derivative(m, p, distance);
37 DerivativePair ret1 = p1_.get_score_and_derivative(m, p, distance);
38 return DerivativePair(ret0.first + ret1.first, ret0.second + ret1.second);
40 template <
unsigned int D>
41 bool get_is_trivially_zero(
Model *m,
43 double squared_distance)
const {
44 return p0_.get_is_trivially_zero(m, p, squared_distance) &&
45 p1_.get_is_trivially_zero(m, p, squared_distance);
48 template <
unsigned int D>
51 return std::max(p0_.get_maximum_range(m, p), p1_.get_maximum_range(m, p));
55 return p0_.get_inputs(m, pis) + p1_.get_inputs(m, pis);
57 void show(std::ostream &out)
const {
63 IMPSCOREFUNCTOR_END_NAMESPACE
A class to store an fixed array of same-typed values.
Class for storing model, its restraints, constraints, and particles.
Functions to deal with very common math operations.
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.
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.
double get_maximum_range(Model *m, const Array< D, ParticleIndex > &p) const
Return an upper bound on the distance at which the score can be non-zero.
A functor for computing a distance based score for two particles.