00001
00002
00003
00004
00005
00006
00007
00008 #ifndef IMPMISC_LOG_PAIR_SCORE_H
00009 #define IMPMISC_LOG_PAIR_SCORE_H
00010
00011 #include "misc_config.h"
00012 #include <IMP/PairScore.h>
00013 #include <map>
00014
00015 IMPMISC_BEGIN_NAMESPACE
00016
00017
00018
00019
00020 class LogPairScore : public PairScore
00021 {
00022 mutable std::map<ParticlePair, unsigned int> map_;
00023 public:
00024
00025 LogPairScore(){}
00026 IMP_SIMPLE_PAIR_SCORE(LogPairScore);
00027
00028
00029 ParticlePairs get_particle_pairs() const {
00030 ParticlePairs ret;
00031 for (std::map<ParticlePair, unsigned int>::const_iterator
00032 it = map_.begin(); it != map_.end(); ++it) {
00033 ret.push_back(it->first);
00034 }
00035 return ret;
00036 }
00037
00038 void clear() {
00039 map_.clear();
00040 }
00041
00042 bool get_contains(const ParticlePair &pp) const {
00043 return map_.find(pp) != map_.end();
00044 }
00045 };
00046
00047
00048 #ifndef IMP_DOXYGEN
00049 inline void LogPairScore::do_show(std::ostream &out) const {
00050 }
00051
00052 inline Float LogPairScore::evaluate(const ParticlePair &pp,
00053 DerivativeAccumulator *) const {
00054 if (map_.find(pp) == map_.end()) {
00055 map_[pp]=0;
00056 }
00057 ++map_[pp];
00058 return 0.;
00059 }
00060 #endif
00061
00062
00063 IMPMISC_END_NAMESPACE
00064
00065 #endif