IMP  2.2.1
The Integrative Modeling Platform
WeightScore.h
Go to the documentation of this file.
1 /**
2  * \file IMP/score_functor/WeightScore.h
3  * \brief A Score on the distance between a pair of particles.
4  *
5  * Copyright 2007-2014 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPSCORE_FUNCTOR_WEIGHT_SCORE_H
9 #define IMPSCORE_FUNCTOR_WEIGHT_SCORE_H
10 
11 #include <IMP/score_functor/score_functor_config.h>
12 #include <IMP/algebra/utility.h>
13 IMPSCOREFUNCTOR_BEGIN_NAMESPACE
14 
15 /** A shift the distance by subtracting x0 and pass it to the base
16  class.*/
17 template <class BaseDistanceScore>
18 class WeightScore : public BaseDistanceScore {
19  typedef BaseDistanceScore P;
20  double w_;
21 
22  public:
23  WeightScore(double w, BaseDistanceScore base) : P(base), w_(w) {}
24  template <unsigned int D>
25  double get_score(kernel::Model *m,
27  double distance) const {
28  return w_ * P::get_score(m, pi, distance);
29  }
30  template <unsigned int D>
31  DerivativePair get_score_and_derivative(
33  double distance) const {
34  DerivativePair ret = P::get_score_and_derivative(m, p, distance);
35  ret.first *= w_;
36  ret.second *= w_;
37  return ret;
38  }
39 };
40 
41 IMPSCOREFUNCTOR_END_NAMESPACE
42 
43 #endif /* IMPSCORE_FUNCTOR_WEIGHT_SCORE_H */
A class to store an fixed array of same-typed values.
Definition: base/Array.h:33
Functions to deal with very common math operations.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition: base/types.h:23
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:72