IMP  2.0.0
The Integrative Modeling Platform
LogPairScore.h
Go to the documentation of this file.
1 /**
2  * \file IMP/misc/LogPairScore.h
3  * \brief Track the particles pairs passed to the pair score.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPMISC_LOG_PAIR_SCORE_H
9 #define IMPMISC_LOG_PAIR_SCORE_H
10 
11 #include <IMP/misc/misc_config.h>
12 #include <IMP/PairScore.h>
13 #include <IMP/generic.h>
14 #include <IMP/base/map.h>
15 
16 IMPMISC_BEGIN_NAMESPACE
17 
18 //! Track the pairs of particles passed.
19 /** Primarily for testing.
20  */
21 class LogPairScore : public PairScore
22 {
24  public:
25  //! create with an empty map
28 
29  //! Get a list of all pairs (without multiplicity)
33  it = map_.begin(); it != map_.end(); ++it) {
34  ret.push_back(it->first);
35  }
36  return ret;
37  }
38  //! Clear the lst of pairs
39  void clear() {
40  map_.clear();
41  }
42  //! Return true if the pair is in the list
43  bool get_contains(const ParticlePair &pp) const {
44  return map_.find(pp) != map_.end();
45  }
46 };
47 
48 // doxygen spits out warnings
49 #ifndef IMP_DOXYGEN
50 inline void LogPairScore::do_show(std::ostream &) const {
51 }
52 
53 inline Float LogPairScore::evaluate(const ParticlePair &pp,
54  DerivativeAccumulator *) const {
55  if (map_.find(pp) == map_.end()) {
56  map_[pp]=0;
57  }
58  ++map_[pp];
59  return 0.;
60 }
61 #endif
62 
63 
64 IMPMISC_END_NAMESPACE
65 
66 #endif /* IMPMISC_LOG_PAIR_SCORE_H */