STORMM Source Documentation
Loading...
Searching...
No Matches
tickcounter.h
1// -*-c++-*-
2#ifndef STORMM_TICKCOUNTER_H
3#define STORMM_TICKCOUNTER_H
4
5#include <string>
6#include <vector>
7#include "copyright.h"
8#include "DataTypes/stormm_vector_types.h"
9#include "Reporting/error_format.h"
10#include "Structure/local_arrangement.h"
11#include "Structure/structure_enumerators.h"
12#include "multiplication.h"
13#include "summation.h"
14
15namespace stormm {
16namespace stmath {
17
18using structure::imageValue;
19using structure::ImagingMethod;
20
26template <typename T> class TickCounter {
27public:
28
32 explicit TickCounter(const std::vector<int> &state_limits_in,
33 const std::vector<int> &settings_in = std::vector<int>());
34
35 explicit TickCounter(const std::vector<std::vector<T>> &state_values_in,
36 const std::vector<int> &settings_in = std::vector<int>());
38
41 TickCounter(const TickCounter &original) = default;
42 TickCounter(TickCounter &&original) = default;
43 TickCounter& operator=(const TickCounter &original) = default;
44 TickCounter& operator=(TickCounter &&original) = default;
46
48 int getVariableCount() const;
49
51 double getLogPermutations() const;
52
54 const std::vector<int>& getSettings() const;
55
64 int getStateLimits(int var_index) const;
65 const std::vector<int>& getStateLimits() const;
67
77 T getState(int var_index) const;
78 std::vector<T> getState() const;
80
85 std::vector<T> getPossibleStates(int var_index) const;
87
90
93
95 double getLogPermutationCount() const;
96
98 void advance(int steps = 1);
99
101 void reverse(int steps = 1);
102
115 template <typename Trng> void randomize(Trng *xrs);
116 template <typename Trng> void randomize(Trng *xrs, const std::vector<bool> &apply_rng);
117 template <typename Trng> void randomize(Trng *xrs, const std::vector<int> &apply_rng);
119
129 void set(const std::vector<int> &new_state);
130
131 void set(int new_state, int var_index);
133
135 void reset();
136
146 void loadStateValues(const std::vector<T> &state_values_in, int var_index);
147 void loadStateValues(const std::vector<std::vector<T>> &state_values_in);
149
150private:
151 int variable_count;
152 double log_permutations;
153 std::vector<int> settings;
156 std::vector<int> state_limits;
158 std::vector<T> state_values;
163
165 std::vector<int> state_value_bounds;
166
171 void variableBoundsCheck(const int var_index) const;
172
175 void validateSettings() const;
176};
177
193template <typename T, typename T2>
194void loadScalarStateValues(TickCounter<T> *tc, const std::vector<T2> &ranges,
195 const std::vector<T> &periodic_boundaries);
196
197template <typename T, typename T2>
198void loadScalarStateValues(TickCounter<T> *tc, const std::vector<T2> &ranges);
200
201} // namespace stmath
202} // namespace stormm
203
204#include "tickcounter.tpp"
205
206#endif
TickCounter(const std::vector< int > &state_limits_in, const std::vector< int > &settings_in=std::vector< int >())
The constructor takes a series of state counts for each "wheel" in the counter. The initial state can...
Make an array of integral settings and tick it forward (or backward). The analogy is a series of whee...
Definition tickcounter.h:26
int getVariableCount() const
Get the number of independent settings, the number of variables.
TickCounter(const TickCounter &original)=default
The copy and move constructors as well as assignment operators are all valid.
std::vector< T > getPossibleStates(int var_index) const
Get a vector of all possible states for one of the variables.
int getStateLimits(int var_index) const
Get the number of available states.
llint getExactPermutationCount() const
Get the exact number of permutations for this object.
void set(const std::vector< int > &new_state)
Set the object's state to an arbitrary series of values.
void reset()
Reset all states of the counter to zero.
double getLogPermutationCount() const
Get the natural logarithm of the number of permutations of this object.
T getState(int var_index) const
Get the state represented by a particular combination of settings, drawing on the internal representa...
void advance(int steps=1)
Advance the counter by a specified number of steps.
double getLogPermutations() const
Get the logarithm of the number of overall permutations.
const std::vector< int > & getSettings() const
Get a const reference to the vector of current settings.
void loadStateValues(const std::vector< T > &state_values_in, int var_index)
Load the available states for one or more independent variables.
void reverse(int steps=1)
Reverse the counter by a specified number of steps.
double getApproximatePermutationCount() const
Get the number of permutations count for this object as a floating-point number.
TickCounter(const std::vector< int > &state_limits_in, const std::vector< int > &settings_in=std::vector< int >())
The constructor takes a series of state counts for each "wheel" in the counter. The initial state can...
void randomize(Trng *xrs)
Randomize some or all variables of the object.