dip::Distribution::Sample class

One sample of a distribution.

A sample implicitly converts to dip::dfloat, evaluating to the value of y for the sample. For multi-valued samples, evaluates to the first y value.

Given a Sample s, s.X() accesses the x-value of the sample, s.Y() accesses the (first) y-value, s.Y(ii) accesses the (ii+1)-th y value, and s.Y(ii,jj) accesses the element at (ii,jj). s.Y(ii,jj) is equivalent to s.Y(ii+jj*nRows), where nRows is the number of rows in the matrix. None of these accessors test for out-of-bounds accesses.

Constructors, destructors, assignment and conversion operators

Sample() deleted
Not default constructable
Sample(dip::Distribution::Sample&& ) defaulted
Move constructor
Sample(dip::Distribution::Sample const& ) defaulted
Copy constructor, references the same data. Careful!
auto operator=(dip::Distribution::Sample&& other) -> dip::Distribution::Sample&
Move assignment actually copies value over to sample referenced
auto operator=(dip::Distribution::Sample const& other) -> dip::Distribution::Sample&
Copy assignment, data is copied to sample referenced

Functions

auto X() -> dip::Distribution::ValueType&
Returns reference to sample’s x value.
auto Y(dip::uint index = 0) -> dip::Distribution::ValueType&
Returns reference to sample’s (index+1)-th y value.
auto Y(dip::uint row, dip::uint col) -> dip::Distribution::ValueType&
Returns reference to sample’s y value at (row,col).
void swap(dip::Distribution::Sample& other)
Swaps two samples, copying the data from other to *this, and that from *this to other. Both must have the same number of values.

Operators

auto operator dfloat() const -> dip::dfloat
Implicitly casts to sample’s first y value.