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>
44 void init(
Float bin_size) {
47 one_over_bin_size_ = 1.0/bin_size_;
49 std::vector< ValueT >::reserve(dist2index(max_distance_) + 1);
51 unsigned int dist2index(
Float dist)
const {
54 Float index2dist(
unsigned int index)
const {
return index * bin_size_; }
56 Float bin_size_, one_over_bin_size_;
61 %
template(FloatDistribution) Distribution<Float>;
62 %
template(VectorDistribution) Distribution<algebra::Vector3D>;
87 void show(std::ostream &out=std::cout)
const;
91 const std::string& file_name =
"")
const;
98 const std::string& file_name =
"")
const;
105 void add_to_distribution(
Float dist,
Float value) {
106 unsigned int index = dist2index(dist);
107 if(index >= size()) {
108 if(capacity() <= index)
110 resize(index + 1, 0);
111 max_distance_ = index2dist(index + 1);
113 (*this)[index] += value;
117 void read_pr_file(
const std::string& file_name);
121 Float c = 1.0,
const std::string& file_name =
"")
const;
138 Float max_distance = 0.0,
139 Float bin_size = pr_resolution);
145 void show(std::ostream &out=std::cout, std::string prefix=
"")
const;
149 unsigned int index = dist2index(dist);
150 if(index >= size()) {
151 if(capacity() <= index)
154 max_distance_ = index2dist(index + 1);
156 (*this)[index] += value;
161 insert(begin(), dist2index(max_distance_) + 1,
166 std::vector<algebra::Vector3D> coordinates_;
170 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.
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.