5#ifndef GEMMI_BINNER_HPP_
6#define GEMMI_BINNER_HPP_
10#include <unordered_map>
27 fail(
"Binner: nbins argument must be positive");
29 fail(
"Binner: no data");
33 fail(
"Binner: unknown unit cell");
78 limits.back() = std::numeric_limits<double>::infinity();
81 template<
typename DataProxy>
85 fail(
"wrong col_idx in Binner::setup()");
86 cell = cell_ ? *cell_ :
proxy.unit_cell();
87 std::vector<double>
inv_d2;
93 method, std::move(
inv_d2),
nullptr);
106 fail(
"Binner not set up");
141 template<
typename DataProxy>
155 for (
size_t i = 0;
i <
inv_d2.size(); ++
i)
161 return 1. / std::sqrt(
limits.at(n));
204 if (std::is_sorted(hkl, hkl +
hkl_size) &&
205 std::is_sorted(ref, ref +
ref_size)) {
211 pos[b++ - ref] =
static_cast<int>(a++ - hkl);
218 std::unordered_map<Miller, int, MillerHash>
hkl_index;
229 HklMatch(
const std::vector<Miller>& hkl,
const std::vector<Miller>& ref)
230 :
HklMatch(hkl.data(), hkl.size(), ref.data(), ref.size()) {}
232 template <
typename T> std::vector<T>
aligned(
const std::vector<T>& v,
T nan) {
234 fail(
"HklMatch.aligned(): wrong data, size differs");
236 for (
size_t i = 0;
i !=
pos.size(); ++
i)
Correlation combine_correlations(const std::vector< Correlation > &cors)
std::array< int, 3 > Miller
A synonym for convenient passing of hkl.
Correlation combine_two_correlations(const Correlation &a, const Correlation &b)
constexpr float sq(float x)
void fail(const std::string &msg)
int get_bin(const Miller &hkl)
std::vector< double > mids
std::vector< double > limits
double dmin_of_bin(int n) const
void ensure_limits_are_set() const
void setup_from_1_d2(int nbins, Method method, std::vector< double > &&inv_d2, const UnitCell *cell_)
int get_bin_hinted(const Miller &hkl, int &hint) const
std::vector< int > get_bins(const DataProxy &proxy) const
int get_bin_from_1_d2_hinted(double inv_d2, int &hint) const
std::vector< int > get_bins_from_1_d2(const std::vector< double > &inv_d2) const
void setup(int nbins, Method method, const DataProxy &proxy, const UnitCell *cell_=nullptr, bool with_mids=false, size_t col_idx=0)
int get_bin_from_1_d2(double inv_d2)
double dmax_of_bin(int n) const
std::vector< T > aligned(const std::vector< T > &v, T nan)
HklMatch(const Miller *hkl, size_t hkl_size_, const Miller *ref, size_t ref_size)
HklMatch(const std::vector< Miller > &hkl, const std::vector< Miller > &ref)
double calculate_1_d2(const Miller &hkl) const