15 #ifndef PROBABILITY_MATRIX_H
16 #define PROBABILITY_MATRIX_H
23 #include <unordered_map>
31 #include <boost/functional/hash.hpp>
39 typedef std::map < int, int > ProbabilityKey;
41 class ProbabilityKeyHash {
43 std::size_t operator()(
const ProbabilityKey& k)
const;
47 typedef std::unordered_map< ProbabilityKey, SolutionSizeType, ProbabilityKeyHash> ProbabilityMap;
49 class ProbabilityMatrix {
56 SolutionSizeType operator[](ProbabilityKey& pk);
58 void put(ProbabilityKey& pk, SolutionSizeType nos);
60 SolutionSizeType mnos();
63 bool is_initialized() {
67 std::set< int > getArticulations() {
71 unsigned int getDimensions() {
72 return articulations.size();
77 std::pair<ProbabilityKey, ProbabilityFraction> sample(ProbabilityKey pk, R& rand);
80 std::pair<ProbabilityKey, ProbabilityFraction> sample(R& rand);
82 ProbabilityMatrix operator*(ProbabilityMatrix& y);
84 friend class ProbabilityKeyHash;
85 ~ProbabilityMatrix() =
default;
90 bool initialized =
false;
92 std::set< int > articulations = {};
96 class PermuteKeyFactory {
98 PermuteKeyFactory(ProbabilityKey pk);
99 ProbabilityKey* key();
100 bool next_permutation();
101 bool previous_permutation();
104 std::map<int, std::list<int> > storage;
105 std::map<int, std::list<int>::iterator> state;
106 bool make_next_step(std::map<
int, std::list<int>::iterator>::iterator state_it);
107 bool make_previous_step(std::map<
int, std::list<int>::iterator>::iterator state_it);
108 ProbabilityKey current;
109 inline void copy_current() {
110 for (
auto s : state) {
111 current[s.first] = *s.second;
117 ProbabilityMatrix make_internal(ProbabilityMatrix& pm,
int v);
120 std::ostream& operator<<(std::ostream& os, ProbabilityKey& m);
123 std::ostream& operator<<(std::ostream& os, ProbabilityMatrix& m);
This file holds all global includes, definitions and variables.
All classes and functions for the RNA design library are under the design namespace.
This file holds the class definitions for the PairingMatrix.