IMP  2.1.0
The Integrative Modeling Platform
DerivativeCalculator.h
Go to the documentation of this file.
1 /**
2  * \file IMP/saxs/DerivativeCalculator.h
3  * \brief A class for computing SAXS derivatives
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPSAXS_DERIVATIVE_CALCULATOR_H
10 #define IMPSAXS_DERIVATIVE_CALCULATOR_H
11 
12 #include "Profile.h"
13 #include "ProfileFitter.h"
14 #include "Distribution.h"
15 #include <IMP/base/Object.h>
16 
17 IMPSAXS_BEGIN_NAMESPACE
18 
19 /**
20  A class for computing derivatives with respect to SAXS
21  Note: the calculation is expensive, make sure it helps if you use it!
22 */
23 class IMPSAXSEXPORT DerivativeCalculator : public base::Object {
24 public:
25  DerivativeCalculator(const Profile* exp_profile);
26 
27  /* compute the model-specific part of the derivative of the chi square
28  * e.g. -2 * c * w_tilda(q) * (Iexp(q)-c*Icalc(q) + o)
29  * for each q
30  */
31  std::vector<double> compute_gaussian_effect_size(const Profile* model_profile,
32  const ProfileFitter<ChiScore>* pf,
33  bool use_offset = false) const;
34 
35  /*
36  * loop over all particles and rigid bodies, and call
37  * compute_chisquare_derivative on them
38  */
39  void compute_all_derivatives(const kernel::Particles& particles,
40  const std::vector<kernel::Particles>& rigid_bodies,
41  const std::vector<core::RigidBody>& rigid_bodies_decorators,
42  const Profile* model_profile, const std::vector<double>& effect_size,
43  DerivativeAccumulator *acc) const;
44 
45 protected:
46  /*
47  * precompute sinc_cos function and derivative of distance distribution
48  */
49  DeltaDistributionFunction precompute_derivative_helpers(const Profile*
50  resampled_model_profile, const kernel::Particles& particles1,
51  const kernel::Particles& particles2,
52  std::vector<Floats>& sinc_cos_values)
53  const ;
54 
55  /* compute dI(q)/dx_k for given q and k
56  * dI(q)/dx_k = - 2 E^2(q) \sum_l (x_k-x_l)/d_{kl}^2 f_l f_k (sinc(q*d_{kl}) -
57  * * cos(q*d_{kl}))
58  */
59  void compute_intensity_derivatives(const DeltaDistributionFunction&
60  delta_dist, const std::vector<Floats>& sinc_cos_values,
61  unsigned int iq, algebra::Vector3D &dIdx) const;
62 
63  //! compute derivatives for particles1 with respect to particles2
64  /**
65  This method is needed for rigid bodies when particles1 and particles2
66  are particles of two rigid bodies. In this case the particles of the
67  same rigid body are ignored.
68  \param[in] model_profile The current profile of particles
69  \param[in] particles1 Derivative will be computed for each particle
70  \param[in] particles2 Derivative will be computed relative to this set
71  \param[in] derivatives Output vector
72  \param[in] effect_size Effect size
73  */
74  void compute_chisquare_derivative(const Profile* model_profile,
75  const kernel::Particles& particles1,
76  const kernel::Particles& particles2,
77  std::vector<algebra::Vector3D >& derivatives,
78  const std::vector<double>& effect_size) const;
79 
80  //! compute derivatives for particles
81  /**
82  \param[in] model_profile The current profile of particles
83  \param[in] particles Derivative will be computed for each particle
84  \param[in] derivatives Output vector
85  \param[in] effect_size Effect size
86  */
87  void compute_chisquare_derivative(const Profile* model_profile,
88  const kernel::Particles& particles,
89  std::vector<algebra::Vector3D >& derivatives,
90  const std::vector<double>& effect_size) const
91  {
92  return compute_chisquare_derivative(model_profile, particles, particles,
93  derivatives, effect_size);
94  }
95 
96 protected:
97  const Profile *exp_profile_; // experimental saxs profile
98 
99 private:
100  void compute_sinc_cos(Float pr_resolution, Float max_distance,
101  const Profile* model_profile,
102  std::vector<Floats>& output_values) const;
103 
104  void compute_profile_difference(const Profile* model_profile,
105  const Float c, const Float offset,
106  std::vector<double>& profile_diff) const;
107 
108 
109 };
110 
111 IMPSAXS_END_NAMESPACE
112 
113 #endif /* IMPSAXS_DERIVATIVE_CALCULATOR_H */
Class for adding derivatives from restraints to the model.
a class for fitting two profiles
void compute_chisquare_derivative(const Profile *model_profile, const kernel::Particles &particles, std::vector< algebra::Vector3D > &derivatives, const std::vector< double > &effect_size) const
compute derivatives for particles
computes distribution functions
Common base class for heavy weight IMP objects.
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
A shared base class to help in debugging and things.
A class for profile storing and computation.