12 #ifndef IMPSAXS_DISTRIBUTION_H
13 #define IMPSAXS_DISTRIBUTION_H
15 #include <IMP/saxs/saxs_config.h>
22 IMPSAXS_BEGIN_NAMESPACE
25 static const Float pr_resolution = 0.5;
31 template <
class ValueT>
43 unsigned int get_index_from_distance(
Float dist)
const {
46 Float get_distance_from_index(
unsigned int index)
const {
47 return index * bin_size_;
51 void init(
Float bin_size) {
54 one_over_bin_size_ = 1.0 / bin_size_;
56 std::vector<ValueT>::reserve(get_index_from_distance(max_distance_) + 1);
60 Float bin_size_, one_over_bin_size_;
65 %
template(FloatDistribution) Distribution<Float>;
66 %
template(VectorDistribution) Distribution<algebra::Vector3D>;
89 void show(std::ostream& out = std::cout)
const;
93 const std::string& file_name =
"")
const;
100 const std::string& file_name =
"")
const;
105 void add_to_distribution(
Float dist,
Float value) {
106 unsigned int index = get_index_from_distance(dist);
107 if (index >= size()) {
108 if (capacity() <= index)
110 resize(index + 1, 0);
111 max_distance_ = get_distance_from_index(index + 1);
113 (*this)[index] += value;
118 void read_pr_file(
const std::string& file_name);
122 const std::string& file_name =
"")
const;
137 Float max_distance = 0.0,
138 Float bin_size = pr_resolution);
144 void show(std::ostream& out = std::cout, std::string prefix =
"")
const;
148 unsigned int index = get_index_from_distance(dist);
149 if (index >= size()) {
150 if (capacity() <= index)
153 max_distance_ = get_distance_from_index(index + 1);
155 (*this)[index] += value;
160 insert(begin(), get_index_from_distance(max_distance_) + 1,
165 std::vector<algebra::Vector3D> coordinates_;
169 IMPSAXS_END_NAMESPACE
Distribution(Float bin_size=pr_resolution)
Constructor.
Float get_max_distance() const
returns maximal distance value of distribution
Float get_bin_size() const
returns bin size
int get_rounded(const T &x)
Rounds a number to next integer.
Class to handle individual model particles.
Classes to handle individual model particles. (Note that implementation of inline functions in in int...
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
double Float
Basic floating-point value (could be float, double...)
A class for profile storing and computation.