45 #ifndef CLIPPER_HKL_DATATYPES
46 #define CLIPPER_HKL_DATATYPES
69 I_sigI(
const dtype& I,
const dtype& sigI ) : I_(I), sigI_(sigI) {}
71 static String type() {
return "I_sigI"; }
73 void shift_phase(
const ftype&) {}
75 static int data_size() {
return 2; }
76 static String data_names() {
return "I sigI"; }
77 void data_export(
xtype array[] )
const
78 { array[0] = I(); array[1] = sigI(); }
79 void data_import(
const xtype array[] )
80 { I() = array[0]; sigI() = array[1]; }
82 void scale(
const ftype& s) { I_ *= (s*s); sigI_ *= (s*s); }
84 const dtype& I()
const {
return I_; }
85 const dtype& sigI()
const {
return sigI_; }
86 dtype& I() {
return I_; }
87 dtype& sigI() {
return sigI_; }
89 const dtype& I_pl()
const {
return I_; }
90 const dtype& sigI_pl()
const {
return sigI_; }
91 const dtype& I_mi()
const {
return I_; }
92 const dtype& sigI_mi()
const {
return sigI_; }
93 dtype cov()
const {
return 1.0; }
106 static String type() {
return "I_sigI_ano"; }
107 void friedel() { dtype I=I_pl_; I_pl_=I_mi_; I_mi_=I;
108 I=sigI_pl_; sigI_pl_=sigI_mi_; sigI_mi_=I; }
109 void shift_phase(
const ftype&) {}
111 static int data_size() {
return 5; }
112 static String data_names() {
return "I+ sigI+ I- sigI- covI+-"; }
113 void data_export(
xtype a[] )
const { a[0] = I_pl(); a[1] = sigI_pl(); a[2] = I_mi(); a[3] = sigI_mi(); a[4] = cov(); }
114 void data_import(
const xtype a[] ) { I_pl() = a[0]; sigI_pl() = a[1]; I_mi() = a[2]; sigI_mi() = a[3]; cov() = a[4]; }
116 void scale(
const ftype& s) { I_pl_ *= (s*s); sigI_pl_ *= (s*s); I_mi_ *= (s*s); sigI_mi_ *= (s*s); cov_ *= (s*s); }
118 const dtype& I_pl()
const {
return I_pl_; }
119 const dtype& sigI_pl()
const {
return sigI_pl_; }
120 const dtype& I_mi()
const {
return I_mi_; }
121 const dtype& sigI_mi()
const {
return sigI_mi_; }
122 const dtype& cov()
const {
return cov_; }
123 dtype& I_pl() {
return I_pl_; }
124 dtype& sigI_pl() {
return sigI_pl_; }
125 dtype& I_mi() {
return I_mi_; }
126 dtype& sigI_mi() {
return sigI_mi_; }
127 dtype& cov() {
return cov_; }
129 dtype I()
const {
return Util::mean(I_pl_,I_mi_); }
130 dtype sigI()
const {
return Util::sig_mean(sigI_pl_,sigI_mi_,cov_); }
132 dtype I_pl_, I_mi_, sigI_pl_, sigI_mi_, cov_;
143 F_sigF(
const dtype& f,
const dtype& sigf ) : f_(f), sigf_(sigf) {}
145 static String type() {
return "F_sigF"; }
147 void shift_phase(
const ftype&) {}
149 static int data_size() {
return 2; }
150 static String data_names() {
return "F sigF"; }
151 void data_export(
xtype array[] )
const
152 { array[0] = f(); array[1] = sigf(); }
153 void data_import(
const xtype array[] )
154 { f() = array[0]; sigf() = array[1]; }
158 const dtype& f()
const {
return f_; }
159 const dtype& sigf()
const {
return sigf_; }
160 dtype& f() {
return f_; }
161 dtype& sigf() {
return sigf_; }
163 const dtype& f_pl()
const {
return f_; }
164 const dtype& sigf_pl()
const {
return sigf_; }
165 const dtype& f_mi()
const {
return f_; }
166 const dtype& sigf_mi()
const {
return sigf_; }
167 dtype cov()
const {
return 1.0; }
180 static String type() {
return "F_sigF_ano"; }
181 void friedel() { dtype f=f_pl_; f_pl_=f_mi_; f_mi_=f;
182 f=sigf_pl_; sigf_pl_=sigf_mi_; sigf_mi_=f; }
183 void shift_phase(
const ftype&) {}
185 static int data_size() {
return 5; }
186 static String data_names() {
return "F+ sigF+ F- sigF- covF+-"; }
187 void data_export(
xtype a[] )
const { a[0] = f_pl(); a[1] = sigf_pl(); a[2] = f_mi(); a[3] = sigf_mi(); a[4] = cov(); }
188 void data_import(
const xtype a[] ) { f_pl() = a[0]; sigf_pl() = a[1]; f_mi() = a[2]; sigf_mi() = a[3]; cov() = a[4]; }
190 void scale(
const ftype& s) { f_pl_ *= s; sigf_pl_ *= s; f_mi_ *= s; sigf_mi_ *= s; cov_ *= (s*s); }
192 const dtype& f_pl()
const {
return f_pl_; }
193 const dtype& sigf_pl()
const {
return sigf_pl_; }
194 const dtype& f_mi()
const {
return f_mi_; }
195 const dtype& sigf_mi()
const {
return sigf_mi_; }
196 const dtype& cov()
const {
return cov_; }
197 dtype& f_pl() {
return f_pl_; }
198 dtype& sigf_pl() {
return sigf_pl_; }
199 dtype& f_mi() {
return f_mi_; }
200 dtype& sigf_mi() {
return sigf_mi_; }
201 dtype& cov() {
return cov_; }
203 dtype f()
const {
return Util::mean(f_pl_,f_mi_); }
204 dtype sigf()
const {
return Util::sig_mean(sigf_pl_,sigf_mi_,cov_); }
206 dtype f_pl_, f_mi_, sigf_pl_, sigf_mi_, cov_;
226 E_sigE(
const dtype& E,
const dtype& sigE ) : E_(E), sigE_(sigE) {}
228 static String type() {
return "E_sigE"; }
230 void shift_phase(
const ftype&) {}
232 static int data_size() {
return 2; }
233 static String data_names() {
return "E sigE"; }
234 void data_export(
xtype array[] )
const
235 { array[0] = E(); array[1] = sigE(); }
236 void data_import(
const xtype array[] )
237 { E() = array[0]; sigE() = array[1]; }
241 const dtype& E()
const {
return E_; }
242 const dtype& sigE()
const {
return sigE_; }
243 dtype& E() {
return E_; }
244 dtype& sigE() {
return sigE_; }
246 const dtype& E_pl()
const {
return E_; }
247 const dtype& sigE_pl()
const {
return sigE_; }
248 const dtype& E_mi()
const {
return E_; }
249 const dtype& sigE_mi()
const {
return sigE_; }
250 dtype cov()
const {
return 1.0; }
261 static String type() {
return "E_sigE_ano"; }
262 void friedel() { dtype e=E_pl_; E_pl_=E_mi_; E_mi_=e;
263 e=sigE_pl_; sigE_pl_=sigE_mi_; sigE_mi_=e; }
264 void shift_phase(
const ftype&) {}
266 static int data_size() {
return 5; }
267 static String data_names() {
return "E+ sigE+ E- sigE- covE+-"; }
268 void data_export(
xtype a[] )
const { a[0] = E_pl(); a[1] = sigE_pl(); a[2] = E_mi(); a[3] = sigE_mi(); a[4] = cov(); }
269 void data_import(
const xtype a[] ) { E_pl() = a[0]; sigE_pl() = a[1]; E_mi() = a[2]; sigE_mi() = a[3]; cov() = a[4]; }
271 void scale(
const ftype& s) { E_pl_ *= s; sigE_pl_ *= s; E_mi_ *= s; sigE_mi_ *= s; cov_ *= (s*s); }
273 const dtype& E_pl()
const {
return E_pl_; }
274 const dtype& sigE_pl()
const {
return sigE_pl_; }
275 const dtype& E_mi()
const {
return E_mi_; }
276 const dtype& sigE_mi()
const {
return sigE_mi_; }
277 const dtype& cov()
const {
return cov_; }
278 dtype& E_pl() {
return E_pl_; }
279 dtype& sigE_pl() {
return sigE_pl_; }
280 dtype& E_mi() {
return E_mi_; }
281 dtype& sigE_mi() {
return sigE_mi_; }
282 dtype& cov() {
return cov_; }
284 dtype E()
const {
return Util::mean(E_pl_,E_mi_); }
285 dtype sigE()
const {
return Util::sig_mean(sigE_pl_,sigE_mi_,cov_); }
287 dtype E_pl_, E_mi_, sigE_pl_, sigE_mi_, cov_;
291 template<
class dtype>
class F_phi :
private Datatype_base
295 F_phi(
const dtype& f,
const dtype& phi ) : f_(f), phi_(phi) {}
297 static String type() {
return "F_phi"; }
300 void shift_phase(
const ftype& dphi)
304 static int data_size() {
return 2; }
305 static String data_names() {
return "F phi"; }
306 void data_export(
xtype array[] )
const
307 { array[0] = f(); array[1] = phi(); }
308 void data_import(
const xtype array[] )
309 { f() = array[0]; phi() = array[1]; }
313 const dtype& f()
const {
return f_; }
314 const dtype& phi()
const {
return phi_; }
315 dtype& f() {
return f_; }
316 dtype& phi() {
return phi_; }
318 dtype
a()
const {
return f_ * cos( phi_ ); }
320 dtype
b()
const {
return f_ * sin( phi_ ); }
322 F_phi(
const std::complex<dtype> c) { f_=std::abs(c); phi_=std::arg(c); }
324 operator std::complex<dtype>()
const {
return std::polar(f_, phi_); }
326 dtype
resolve(
const dtype phi) {
return f_ * cos( phi_ - phi ); }
338 Phi_fom(
const dtype& phi,
const dtype& fom ) : phi_(phi), fom_(fom) {}
340 static String type() {
return "Phi_fom"; }
343 void shift_phase(
const ftype& dphi)
347 static int data_size() {
return 2; }
348 static String data_names() {
return "phi fom"; }
349 void data_export(
xtype array[] )
const
350 { array[0] = phi(); array[1] = fom(); }
351 void data_import(
const xtype array[] )
352 { phi() = array[0]; fom() = array[1]; }
354 const dtype& phi()
const {
return phi_; }
355 const dtype& fom()
const {
return fom_; }
356 dtype& phi() {
return phi_; }
357 dtype& fom() {
return fom_; }
367 ABCD(
const dtype& a,
const dtype& b,
const dtype& c,
const dtype& d ) : a_(a), b_(b), c_(c), d_(d) {}
369 static String type() {
return "ABCD"; }
370 void friedel() {
if ( !missing() ) { b_=-b_; d_=-d_; } }
371 void shift_phase(
const ftype& dphi)
375 dtype a1, b1, c1, d1;
378 a1 = a_*cosd - b_*sind;
379 b1 = a_*sind + b_*cosd;
380 cosd = cos(2.0*dphi);
381 sind = sin(2.0*dphi);
382 c1 = c_*cosd - d_*sind;
383 d1 = c_*sind + d_*cosd;
384 a_ = a1; b_ = b1; c_ = c1; d_ = d1;
388 static int data_size() {
return 4; }
389 static String data_names() {
return "A B C D"; }
390 void data_export(
xtype array[] )
const
391 { array[0] = a(); array[1] = b(); array[2] = c(); array[3] = d(); }
392 void data_import(
const xtype array[] )
393 { a() = array[0]; b() = array[1]; c() = array[2]; d() = array[3]; }
395 const dtype& a()
const {
return a_; }
396 const dtype& b()
const {
return b_; }
397 const dtype& c()
const {
return c_; }
398 const dtype& d()
const {
return d_; }
399 dtype& a() {
return a_; }
400 dtype& b() {
return b_; }
401 dtype& c() {
return c_; }
402 dtype& d() {
return d_; }
411 Flag() { flag_ = -1; }
412 explicit Flag(
const int& flag ) : flag_(flag) {}
413 void set_null() { flag_ = -1; }
414 static String type() {
return "Flag"; }
416 void shift_phase(
const ftype&) {}
417 bool missing()
const {
return (flag_ < 0); }
418 static int data_size() {
return 1; }
419 static String data_names() {
return "flag"; }
420 void data_export(
xtype array[] )
const
421 { array[0] =
xtype(flag()); }
422 void data_import(
const xtype array[] )
423 { flag() = int(array[0]); }
425 const int& flag()
const {
return flag_; }
426 int& flag() {
return flag_; }
436 void set_null() { flag_ =
false; }
437 static String type() {
return "Flag_bool"; }
439 void shift_phase(
const ftype&) {}
440 bool missing()
const {
return (!flag_); }
441 static int data_size() {
return 1; }
442 static String data_names() {
return "flag"; }
443 void data_export(
xtype array[] )
const
444 { array[0] =
xtype(flag()); }
445 void data_import(
const xtype array[] )
446 { flag() = bool(array[0]); }
448 const bool& flag()
const {
return flag_; }
449 bool& flag() {
return flag_; }
460 D_sigD(
const dtype& d,
const dtype& sigd ) : d_(d), sigd_(sigd) {}
462 static String type() {
return "D_sigD"; }
463 void friedel() { d_ = -d_; }
464 void shift_phase(
const ftype&) {}
466 static int data_size() {
return 2; }
467 static String data_names() {
return "Dano sigDano"; }
468 void data_export(
xtype array[] )
const
469 { array[0] = d(); array[1] = sigd(); }
470 void data_import(
const xtype array[] )
471 { d() = array[0]; sigd() = array[1]; }
475 const dtype& d()
const {
return d_; }
476 const dtype& sigd()
const {
return sigd_; }
477 dtype& d() {
return d_; }
478 dtype& sigd() {
return sigd_; }
clipper::datatypes::F_phi< ftype32 > F_phi
datatype
Definition: hkl_datatypes.h:493
dtype a() const
read real part
Definition: hkl_datatypes.h:318
Reflection data type: Free-R flag.
Definition: hkl_datatypes.h:408
static ftype mod(const ftype &a, const ftype &b)
Corrected mod.
Definition: clipper_util.h:134
clipper::datatypes::D_sigD< ftype32 > D_sigD
datatype
Definition: hkl_datatypes.h:498
Reflection data type: E + sigE.
Definition: hkl_datatypes.h:222
Reflection data type: I + sigI.
Definition: hkl_datatypes.h:65
clipper::datatypes::F_sigF_ano< ftype32 > F_sigF_ano
datatype
Definition: hkl_datatypes.h:491
clipper::datatypes::I_sigI_ano< ftype32 > I_sigI_ano
datatype
Definition: hkl_datatypes.h:489
clipper::datatypes::I_sigI< ftype32 > I_sigI
datatype
Definition: hkl_datatypes.h:488
static const ftype & twopi()
2 pi
Definition: clipper_util.h:162
void scale(const ftype &s)
this type is scalable - apply magnitude scale factor
Definition: hkl_datatypes.h:156
clipper::datatypes::Phi_fom< ftype64 > Phi_fom
datatype
Definition: hkl_datatypes.h:509
clipper::datatypes::F_phi< ftype64 > F_phi
datatype
Definition: hkl_datatypes.h:508
Reflection data type: F + sigF.
Definition: hkl_datatypes.h:139
ftype64 ftype
ftype definition for floating point representation
Definition: clipper_precision.h:58
clipper::datatypes::E_sigE< ftype32 > E_sigE
datatype
Definition: hkl_datatypes.h:492
void scale(const ftype &s)
this type is scalable - apply magnitude scale factor
Definition: hkl_datatypes.h:271
Reflection data type: F(+) F(+) sigF(+) sigF(-) cov+-.
Definition: hkl_datatypes.h:176
dtype b() const
read imag part
Definition: hkl_datatypes.h:320
void scale(const ftype &s)
this type is scalable - apply magnitude scale factor
Definition: hkl_datatypes.h:239
Reflection data type: Hendrickson-Lattman coeff.
Definition: hkl_datatypes.h:363
clipper::datatypes::D_sigD< ftype64 > D_sigD
datatype
Definition: hkl_datatypes.h:513
clipper::datatypes::I_sigI< ftype64 > I_sigI
datatype
Definition: hkl_datatypes.h:503
void scale(const ftype &s)
this type is scalable - apply magnitude scale factor
Definition: hkl_datatypes.h:473
F_phi(const std::complex< dtype > c)
convert from complex
Definition: hkl_datatypes.h:322
String extension with simple parsing methods.
Definition: clipper_types.h:64
Reflection data type: boolean (false = missing)
Definition: hkl_datatypes.h:432
clipper::datatypes::Flag_bool Flag_bool
datatype
Definition: hkl_datatypes.h:512
static bool is_nan(const ftype32 f)
fast Util::nan() test
Definition: clipper_util.h:82
const F_phi< dtype > & norm()
tidy up so that real part is positive and phase 0...twopi
Definition: hkl_datatypes.h:328
clipper::datatypes::Flag Flag
datatype
Definition: hkl_datatypes.h:496
void scale(const ftype &s)
this type is scalable - apply magnitude scale factor
Definition: hkl_datatypes.h:190
dtype resolve(const dtype phi)
resolve along phase direction
Definition: hkl_datatypes.h:326
clipper::datatypes::F_sigF_ano< ftype64 > F_sigF_ano
datatype
Definition: hkl_datatypes.h:506
void scale(const ftype &s)
this type is scalable - apply magnitude scale factor
Definition: hkl_datatypes.h:82
static T mean(const T &pl, const T &mi)
Convert F+/F- to mean F, with NaN checks.
Definition: clipper_util.h:111
Reflection data type: F + phi model or map coeff (e.g. Fcalc, Fbest)
Definition: fftmap.h:61
clipper::datatypes::Flag Flag
datatype
Definition: hkl_datatypes.h:511
Definition: hkl_datatypes.h:456
clipper::datatypes::F_sigF< ftype64 > F_sigF
datatype
Definition: hkl_datatypes.h:505
static void set_null(ftype32 &f)
set null floating value - a specific value of NaN used for missings
Definition: clipper_util.h:73
ftype64 xtype
xtype definition for import/export of data
Definition: clipper_precision.h:61
Reflection data type: best phi + fom.
Definition: hkl_datatypes.h:334
static T sig_mean(const T &pl, const T &mi, const T &cov)
Convert sigF+/sigF-/cov to sig F, with NaN checks.
Definition: clipper_util.h:118
clipper::datatypes::ABCD< ftype64 > ABCD
datatype
Definition: hkl_datatypes.h:510
clipper::datatypes::E_sigE< ftype64 > E_sigE
datatype
Definition: hkl_datatypes.h:507
Reflection data type objects.
Definition: hkl_data.h:103
void scale(const ftype &s)
this type is scalable - apply magnitude scale factor
Definition: hkl_datatypes.h:311
static const ftype & pi()
pi
Definition: clipper_util.h:160
Reflection data type: E(+) E(+) sigE(+) sigE(-) cov+-.
Definition: hkl_datatypes.h:257
Reflection data type: I(+) I(+) sigI(+) sigI(-) cov+-.
Definition: hkl_datatypes.h:102
clipper::datatypes::Phi_fom< ftype32 > Phi_fom
datatype
Definition: hkl_datatypes.h:494
clipper::datatypes::ABCD< ftype32 > ABCD
datatype
Definition: hkl_datatypes.h:495
void scale(const ftype &s)
this type is scalable - apply magnitude scale factor
Definition: hkl_datatypes.h:116
clipper::datatypes::I_sigI_ano< ftype64 > I_sigI_ano
datatype
Definition: hkl_datatypes.h:504
clipper::datatypes::F_sigF< ftype32 > F_sigF
datatype
Definition: hkl_datatypes.h:490
clipper::datatypes::Flag_bool Flag_bool
datatype
Definition: hkl_datatypes.h:497