IMP  2.3.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-2014 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/kernel/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(kernel::Model *m,
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(
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(
41  return P::get_maximum_range(m, pi) - x0_;
42  }
43  bool get_is_trivially_zero(kernel::Model *m,
44  const kernel::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 */
Import IMP/kernel/particle_index.h in the namespace.
A class to store an fixed array of same-typed values.
Definition: Array.h:33
Functions to deal with very common math operations.
Storage of a model, its restraints, constraints and particles.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition: types.h:23
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73