5#ifndef GEMMI_SCALING_HPP_
6#define GEMMI_SCALING_HPP_
13using Vec6 = std::array<double, 6>;
16 return a[0] * s.u11 + a[1] * s.u22 + a[2] * s.u33
17 + a[3] * s.u12 + a[4] * s.u13 + a[5] * s.u23;
25 auto constraints = [](
const std::initializer_list<int>&
l) {
26 constexpr double K2 = 0.70710678118654752440;
27 constexpr double K3 = 0.57735026918962576451;
28 static const Vec6 vv[10] = {
36 {2/3., 2/3., 0, 1/3., 0, 0},
52 return constraints({0, 1, 2, 3 +
'c' -
sg->monoclinic_unique_axis()});
68template<
typename Real>
112 fail(
"scale_data(): mask data not prepared");
118 fail(
"scale_data(): data arrays don't match");
137 std::vector<double>
ret;
160 b_star = {0, 0, 0, 0, 0, 0};
176 fail(
"prepare_points(): mask data not prepared");
177 std::complex<Real> fmask;
179 auto c =
calc.v.begin();
181 if (c->hkl !=
o.
hkl) {
184 if (c ==
calc.v.end())
193 fail(
"prepare_points(): unexpected data");
197 if (!std::isnan(
o.
value.value) && !std::isnan(
o.
value.sigma))
200 if (c ==
calc.v.end())
219 if (
p.fobs < 1 ||
p.fobs <
p.sigma)
224 double y = std::log(
static_cast<float>(
p.fobs /
fcalc));
234 double intercept = (
sy - slope *
sx) / n;
235 double b_iso = -slope;
248 std::vector<double> values;
249 values.reserve(
points.size());
260 std::vector<double>&
yy,
261 std::vector<double>&
dy_da)
const {
292 -0.25 *
yy[
i] * (
h.x *
h.x),
293 -0.25 *
yy[
i] * (
h.y *
h.y),
294 -0.25 *
yy[
i] * (
h.z *
h.z),
295 -0.5 *
yy[
i] * (
h.x *
h.y),
296 -0.5 *
yy[
i] * (
h.x *
h.z),
297 -0.5 *
yy[
i] * (
h.y *
h.z),
double vec6_dot(const Vec6 &a, const SMat33< double > &s)
std::array< double, 6 > Vec6
std::array< int, 3 > Miller
A synonym for convenient passing of hkl.
std::vector< Vec6 > adp_symmetry_constraints(const SpaceGroup *sg)
Symmetry constraints of ADP.
void fail(const std::string &msg)
SMat33< Real > transformed_by(const Mat33 &m) const
auto r_u_r(const Vec3_< VT > &r) const -> decltype(r.x+u11)
std::complex< Real > fmask
double get_weight() const
std::complex< Real > fcmol
Scaling(const UnitCell &cell_, const SpaceGroup *sg)
void set_b_overall(const SMat33< double > &b_overall)
void fit_isotropic_b_approximately()
double get_overall_scale_factor(const Miller &hkl) const
SMat33< double > get_b_overall() const
std::complex< Real > scale_value(const Miller &hkl, std::complex< Real > f_value, std::complex< Real > mask_value)
void scale_data(AsuData< std::complex< Real > > &asu_data, const AsuData< std::complex< Real > > *mask_data) const
std::vector< double > get_parameters() const
void prepare_points(const AsuData< std::complex< Real > > &calc, const AsuData< ValueSigma< Real > > &obs, const AsuData< std::complex< Real > > *mask_data)
std::vector< Vec6 > constraint_matrix
std::vector< double > compute_values() const
double get_solvent_scale(double stol2) const
std::vector< Point > points
void compute_values_and_derivatives(size_t tile_start, size_t tile_size, std::vector< double > &yy, std::vector< double > &dy_da) const
void set_parameters(const std::vector< double > &p)
set k_overall, k_sol, b_sol, b_star
double calculate_stol_sq(const Miller &hkl) const
Calculate (sin(theta)/lambda)^2 = d*^2/4.