IMP logo
IMP Reference Guide  2.8.0
The Integrative Modeling Platform
Shift.h
Go to the documentation of this file.
1 /**
2  * \file IMP/score_functor/Shift.h
3  * \brief A Score on the distance between a pair of particles.
4  *
5  * Copyright 2007-2017 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPSCORE_FUNCTOR_SHIFT_H
9 #define IMPSCORE_FUNCTOR_SHIFT_H
10 
11 #include <IMP/score_functor/score_functor_config.h>
12 #include <IMP/algebra/utility.h>
13 #include <IMP/Model.h>
14 #include <IMP/particle_index.h>
15 IMPSCOREFUNCTOR_BEGIN_NAMESPACE
16 
17 /** A shift the distance by subtracting x0 and pass it to the base
18  class.*/
19 template <class BaseDistanceScore>
20 class Shift : public BaseDistanceScore {
21  typedef BaseDistanceScore P;
22  double x0_;
23 
24  public:
25  Shift(double x0, BaseDistanceScore base) : P(base), x0_(x0) {}
26  template <unsigned int D>
27  double get_score(Model *m,
28  const Array<D, ParticleIndex> &pi,
29  double distance) const {
30  return P::get_score(m, pi, distance - x0_);
31  }
32  template <unsigned int D>
33  DerivativePair get_score_and_derivative(
34  Model *m, const Array<D, ParticleIndex> &p,
35  double distance) const {
36  return P::get_score_and_derivative(m, p, distance - x0_);
37  }
38  template <unsigned int D>
39  double get_maximum_range(
40  Model *m, const Array<D, ParticleIndex> &pi) const {
41  return P::get_maximum_range(m, pi) - x0_;
42  }
43  bool get_is_trivially_zero(Model *m,
44  const ParticleIndexPair &pi,
45  double squared_distance) const {
46  return squared_distance >
47  algebra::get_squared(P::get_maximum_range(m, pi) + x0_);
48  }
49 };
50 
51 IMPSCOREFUNCTOR_END_NAMESPACE
52 
53 #endif /* IMPSCORE_FUNCTOR_SHIFT_H */
Various general useful functions for IMP.
A class to store an fixed array of same-typed values.
Definition: Array.h:33
Storage of a model, its restraints, constraints and particles.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
Functions to deal with very common math operations.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition: types.h:23