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);
142 void calculate_derivative_distribution(
Particle* particle);
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