12 #ifndef IMPSAXS_DISTRIBUTION_H
13 #define IMPSAXS_DISTRIBUTION_H
15 #include <IMP/saxs/saxs_config.h>
21 IMPSAXS_BEGIN_NAMESPACE
24 static const double pr_resolution = 0.5;
30 template <
class ValueT>
42 unsigned int get_index_from_distance(
double dist)
const {
45 double get_distance_from_index(
unsigned int index)
const {
46 return index * bin_size_;
50 void init(
double bin_size) {
53 one_over_bin_size_ = 1.0 / bin_size_;
55 std::vector<ValueT>::reserve(get_index_from_distance(max_distance_) + 1);
59 double bin_size_, one_over_bin_size_;
64 %
template(FloatDistribution) Distribution<double>;
65 %
template(VectorDistribution) Distribution<algebra::Vector3D>;
73 mutable std::vector<double> sqrt_distances_;
87 if (sz > sqrt_distances_.size()) {
88 sqrt_distances_.reserve(sz);
89 for (
unsigned int r = sqrt_distances_.size(); r < sz; ++r) {
90 sqrt_distances_.push_back(sqrt(get_distance_from_index(r)));
93 return sqrt_distances_;
103 void show(std::ostream& out = std::cout)
const;
107 const std::string& file_name =
"")
const;
114 const std::string& file_name =
"")
const;
119 void add_to_distribution(
double dist,
double value) {
120 unsigned int index = get_index_from_distance(dist);
121 if (index >= size()) {
122 if (capacity() <= index)
124 resize(index + 1, 0);
125 max_distance_ = get_distance_from_index(index + 1);
127 (*this)[index] += value;
132 void read_pr_file(
const std::string& file_name);
135 void write_fit_file(
const RadialDistributionFunction& model_pr,
double c = 1.0,
136 const std::string& file_name =
"")
const;
151 double max_distance = 0.0,
152 double bin_size = pr_resolution);
155 void calculate_derivative_distribution(
Particle* particle);
158 void show(std::ostream& out = std::cout, std::string prefix =
"")
const;
162 unsigned int index = get_index_from_distance(dist);
163 if (index >= size()) {
164 if (capacity() <= index)
167 max_distance_ = get_distance_from_index(index + 1);
169 (*this)[index] += value;
174 insert(begin(), get_index_from_distance(max_distance_) + 1,
179 std::vector<algebra::Vector3D> coordinates_;
183 IMPSAXS_END_NAMESPACE
double get_max_distance() const
returns maximal distance value of distribution
const std::vector< double > & get_square_root_distances() const
Get square root of distance for each distribution point.
int get_rounded(const T &x)
Rounds a number to next integer.
double get_bin_size() const
returns bin size
Distribution(double bin_size=pr_resolution)
Constructor.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
Class to handle individual particles of a Model object.
A class for profile storing and computation.