IMP  2.0.1
The Integrative Modeling Platform
CoarseCCatIntervals.h
Go to the documentation of this file.
1 /**
2  * \file IMP/em/CoarseCCatIntervals.h
3  * \brief Cross correlation coefficient calculator.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPEM_COARSE_CCAT_INTERVALS_H
10 #define IMPEM_COARSE_CCAT_INTERVALS_H
11 
12 #include <IMP/em/em_config.h>
13 #include "CoarseCC.h"
14 #include <vector>
15 
16 IMPEM_BEGIN_NAMESPACE
17 
18 //! Cross correlation coefficient calculator.
19 /** Store CCC and derivative values and recompute then every X steps.
20  */
21 class IMPEMEXPORT CoarseCCatIntervals : public CoarseCC
22 {
23 
24 public:
25 
26  CoarseCCatIntervals(const int &ncd);
27 
29 
30  //! Evaluate the cross-correlation value only every X calls to the function.
31  /**
32  Evaluates the value of the cross correlation term
33  but only at given intervals to save computation time.
34  Otherwise, the same value is returned.
35  This function has an special behavior, as it
36  does not return the true cross correlation coefficient ccc,
37  but the value: scalefac*(1-ccc)
38 
39  The reason why is to use this term as part of an scoring
40  function that is better the lower the term.
41  If you want the cross correlation coefficient,
42  use cross_correlation_coefficient() instead.
43  \param[in] em_map exp EM map
44  \note correct RMSD and mean MUST be in the header!
45  \param[in] model_map an empty map that will contain the sampled
46 particles in the access_p
47  \param[in] scalefac scale factor to apply to the value of the cross
48 correlation term
49  \param[in] deriv input derivatives (only the size is used)
50  \param[in] lderiv if true, the derivatives of the term are computed
51  \param[in] eval_interval the number of times the function is going to return
52 the same value before computing the values again
53  \return the value of the cross correlation term: scalefac * (1-CCC)
54  and a vector of derivatives
55  */
56  std::pair<double,algebra::Vector3Ds> evaluate(
57  DensityMap *em_map, SampledDensityMap *model_map,
58  const algebra::Vector3Ds &deriv,
59  float scalefac, bool lderiv,
60  unsigned long eval_interval);
61 
63 
64 protected:
65  void allocate_derivatives_array(int ncd);
66  //! Number of times the evaluation has been called.
67  /** The evaluation is only performed the first time and when calls_counter
68  reaches eval_interval. Otherwise the stored_cc_ value is returned */
70  //! Stored correlation value
71  float stored_cc_ ;
72  //! Stored derivative terms
73  double *stored_dvx_,*stored_dvy_,*stored_dvz_;
74  // true when memory for the terms storing the derivatives has been assigned
75  bool dv_memory_allocated_;
76 };
77 
78 IMPEM_END_NAMESPACE
79 
80 #endif /* IMPEM_COARSE_CCAT_INTERVALS_H */