49#include "clipper_types.h"
56 template<
class T = ftype>
class Range
60 inline Range() { lmin = 999999999; lmax = -999999999; }
63 inline const T&
min()
const {
return lmin; }
64 inline const T&
max()
const {
return lmax; }
65 inline T
range()
const {
return lmax-lmin; }
68 { lmin = (datum<lmin)?datum:lmin; lmax = (datum>lmax)?datum:lmax; }
71 {
return ( datum >= lmin && datum <= lmax ); }
108 inline int size()
const {
return n_; }
134 inline const ftype&
y(
const int& i )
const {
return data[i]; }
145 std::vector<ftype> data;
170 {
init( range, n ); }
174 void init(
const std::vector<ftype>& values,
const int num_ranges = 1000 );
188 void init(
const int num_ranges = 1000 );
Generic ordinal gernerator.
Definition: clipper_stats.h:164
void accumulate(const ftype &value)
accumulate values to build the distribution
Definition: clipper_stats.cpp:102
void add_pass_1(const ftype &value)
DEPRECATED: add a value to the distribution (pass 1 of 2)
Definition: clipper_stats.cpp:156
Range< ftype > range_
resolution range of data
Definition: clipper_stats.h:195
ftype nranges
number of ranges
Definition: clipper_stats.h:194
void prep_ordinal()
generate the ordinal histogram
Definition: clipper_stats.cpp:118
void invert()
invert distribution to get value from ordinal
Definition: clipper_stats.cpp:126
std::vector< ftype > hist
histogram of reflections vs resolution
Definition: clipper_stats.h:196
Generic_ordinal(const Range< ftype > &range, const int &n)
constructor: from range and sampling
Definition: clipper_stats.h:169
void init(const Range< ftype > &range, const int num_ranges=1000)
initialiser: takes the source range and sampling
Definition: clipper_stats.cpp:76
ftype ordinal(const ftype &value) const
return reflection ordinal
Definition: clipper_stats.cpp:93
Generic_ordinal()
null constructor
Definition: clipper_stats.h:167
void add_pass_2(const ftype &value)
DEPRECATED: add a value to the distribution (pass 2 of 2)
Definition: clipper_stats.cpp:161
General histogram class.
Definition: clipper_stats.h:118
const ftype & y(const int &i) const
return value at index in histogram (Note: no bound check on i)
Definition: clipper_stats.h:134
void accumulate(const ftype &x, const ftype &w)
add specified value to histogram (if it is in range)
Definition: clipper_stats.h:129
const Histogram & operator+=(const Histogram &h)
add the contents of two histograms (size must match)
Definition: clipper_stats.cpp:66
ftype sum() const
return sum of whole histogram
Definition: clipper_stats.cpp:49
Histogram()
null constructor
Definition: clipper_stats.h:121
void accumulate(const ftype &x)
add value to histogram (if it is in range)
Definition: clipper_stats.h:126
Histogram(const Range< ftype > &range, const int &n)
constructor: from range and sampling
Definition: clipper_stats.h:123
Range sampling: discrete sampling of a real range.
Definition: clipper_stats.h:81
ftype x(const int &i) const
return x-value corresponding to centre of i'th range
Definition: clipper_stats.h:102
Range_sampling()
null constructor
Definition: clipper_stats.h:84
int index_bounded(const ftype &x) const
return nearest index to particular x-value (bounded 0...n-1)
Definition: clipper_stats.h:99
ftype x_max(const int &i) const
return x-value corresponding to top of i'th range
Definition: clipper_stats.h:106
int index(const ftype &x) const
return nearest index to particular x-value
Definition: clipper_stats.h:97
ftype x(const ftype &i) const
return x-value (0..n) from fractional posn in counting range
Definition: clipper_stats.h:94
int size() const
return number of samplings in range
Definition: clipper_stats.h:108
ftype x_min(const int &i) const
return x-value corresponding to bottom of i'th range
Definition: clipper_stats.h:104
Range_sampling(const int &n)
constructor: from number of samplings
Definition: clipper_stats.h:86
Range_sampling(const Range< ftype > &range, const int &n)
constructor: from range and number of samplings
Definition: clipper_stats.h:88
ftype indexf(const ftype &x) const
return fractional posn in counting range from x-value (0..n)
Definition: clipper_stats.h:91
Range - upper and lower bounds of some type.
Definition: clipper_stats.h:57
Range(const T &min, const T &max)
constructor
Definition: clipper_stats.h:62
const T & max() const
maximum value
Definition: clipper_stats.h:64
Range()
null constructor
Definition: clipper_stats.h:60
T range() const
range = max - min
Definition: clipper_stats.h:65
void include(const T &datum)
update limits to include a new datum
Definition: clipper_stats.h:67
bool contains(const T &datum) const
test if data is within limits ( min <= datum <= max )
Definition: clipper_stats.h:70
T truncate(const T &datum) const
truncate data to be within range
Definition: clipper_stats.h:73
const T & min() const
minimum value
Definition: clipper_stats.h:63
static int intf(const ftype &a)
Truncate-to-integer: int(floor(a))
Definition: clipper_util.h:129
static T bound(const T &min, const T &val, const T &max)
bound a value by limits
Definition: clipper_util.h:148
ftype64 ftype
ftype definition for floating point representation
Definition: clipper_precision.h:58