Relacs
0.9.8
|
#include <linearrange.h>
Public Types | |
typedef double | value_type |
typedef double * | pointer |
typedef double & | reference |
typedef const double & | const_reference |
typedef long | size_type |
typedef LinearRangeIterator | const_iterator |
Public Member Functions | |
LinearRange (void) | |
LinearRange (int n) | |
LinearRange (long n) | |
LinearRange (int n, double stepsize) | |
LinearRange (long n, double stepsize) | |
LinearRange (int n, double offset, double stepsize) | |
LinearRange (long n, double offset, double stepsize) | |
LinearRange (double r, double stepsize) | |
LinearRange (double l, double r, double stepsize) | |
LinearRange (const LinearRange &r) | |
virtual | ~LinearRange (void) |
const LinearRange & | operator= (const LinearRange &r) |
const LinearRange & | assign (const LinearRange &r) |
const LinearRange & | assign (const LinearRange &r, long first, long last=-1) |
const LinearRange & | assign (int n, double stepsize) |
const LinearRange & | assign (long n, double stepsize) |
const LinearRange & | assign (int n, double offset, double stepsize) |
const LinearRange & | assign (long n, double offset, double stepsize) |
const LinearRange & | assign (double r, double stepsize) |
const LinearRange & | assign (double l, double r, double stepsize) |
const LinearRange & | copy (LinearRange &r) const |
const LinearRange & | copy (LinearRange &r, long first, long last=-1) const |
const LinearRange & | append (long n) |
long | size (void) const |
bool | empty (void) const |
void | resize (long n) |
void | clear (void) |
double | offset (void) const |
void | setOffset (double offset) |
double | stepsize (void) const |
void | setStepsize (double stepsize) |
void | scaleStepsize (double scale) |
void | setRange (double offset, double stepsize) |
double | length (void) const |
void | setLength (double l) |
double | front (void) const |
void | setFront (double front) |
double | back (void) const |
void | setBack (double back) |
double | operator[] (long i) const |
double | at (long i) const |
double | pos (long i) const |
double | interval (int indices) const |
long | index (double pos) const |
long | indices (double iv) const |
bool | contains (double pos) const |
void | push (void) |
void | pop (void) |
const_iterator | begin (void) const |
const_iterator | end (void) const |
const LinearRange & | operator= (double val) |
const LinearRange & | operator+= (double val) |
const LinearRange & | operator-= (double val) |
const LinearRange & | operator*= (double val) |
const LinearRange & | operator/= (double val) |
double | min (long first=0, long last=-1) const |
long | minIndex (long first=0, long last=-1) const |
long | minIndex (double &min, long first=0, long last=-1) const |
double | max (long first=0, long last=-1) const |
long | maxIndex (long first=0, long last=-1) const |
long | maxIndex (double &max, long first=0, long last=-1) const |
void | minMax (double &min, double &max, long first=0, long last=-1) const |
void | minMaxIndex (long &minindex, long &maxindex, long first=0, long last=-1) const |
void | minMaxIndex (double &min, long &minindex, double &max, long &maxindex, long first=0, long last=-1) const |
Friends | |
bool | operator== (const LinearRange &r, const LinearRange &b) |
bool | operator< (const LinearRange &r, const LinearRange &b) |
LinearRange | operator+ (const LinearRange &r, double val) |
LinearRange | operator+ (double val, const LinearRange &r) |
LinearRange | operator- (const LinearRange &r, double val) |
LinearRange | operator- (double val, const LinearRange &r) |
LinearRange | operator* (const LinearRange &r, double val) |
LinearRange | operator* (double val, const LinearRange &r) |
LinearRange | operator/ (const LinearRange &r, double val) |
ostream & | operator<< (ostream &str, const LinearRange &r) |
A linear range of discretized numbers.
typedef double value_type |
The type of an element of the range (double).
typedef double* pointer |
Pointer to the type of an element of the range (double).
typedef double& reference |
Reference to the type of an element of the range (double).
typedef const double& const_reference |
Const reference to the type of an element of the range (double).
typedef long size_type |
The type used for sizes and indices.
typedef LinearRangeIterator const_iterator |
Const iterator used to iterate through a range.
LinearRange | ( | void | ) |
Creates an empty range.
LinearRange | ( | int | n | ) |
Creates a range with n data elements starting at 0 and incremented by 1.
LinearRange | ( | long | n | ) |
Creates a range with n data elements starting at 0 and incremented by 1.
LinearRange | ( | int | n, |
double | stepsize | ||
) |
Creates a range with n data elements starting at 0 and incremented by stepsize.
LinearRange | ( | long | n, |
double | stepsize | ||
) |
Creates a range with n data elements starting at 0 and incremented by stepsize.
LinearRange | ( | int | n, |
double | offset, | ||
double | stepsize | ||
) |
Creates a range with n data elements starting at offset and incremented by stepsize.
LinearRange | ( | long | n, |
double | offset, | ||
double | stepsize | ||
) |
Creates a range with n data elements starting at offset and incremented by stepsize.
LinearRange | ( | double | r, |
double | stepsize | ||
) |
Creates a range starting at 0, ending at r, with increments stepsize. If stepsize equals zero it is set to r.
References LinearRange::index().
LinearRange | ( | double | l, |
double | r, | ||
double | stepsize | ||
) |
Creates a range starting at l, ending at r, with increments stepsize. If stepsize equals zero it is set to r - l.
References LinearRange::index().
LinearRange | ( | const LinearRange & | r | ) |
Copy constructor. Creates a range with the same offset, stepsize and size as range r.
|
virtual |
The destructor.
|
inline |
Set the offset, stepsize and size to the values of range r.
const LinearRange & assign | ( | const LinearRange & | r | ) |
Set the offset, stepsize and size to the values of range r.
References LinearRange::offset(), LinearRange::size(), and LinearRange::stepsize().
Referenced by LinearRange::copy().
const LinearRange & assign | ( | const LinearRange & | r, |
long | first, | ||
long | last = -1 |
||
) |
Set the offset, stepsize and size to the values of range r from index first (inclusively) to last (exclusively).
References LinearRange::pos(), LinearRange::size(), and LinearRange::stepsize().
const LinearRange & assign | ( | int | n, |
double | stepsize | ||
) |
Creates a range with n data elements, stepsize stepsize, and offset 0.
References LinearRange::stepsize().
const LinearRange & assign | ( | long | n, |
double | stepsize | ||
) |
Creates a range with n data elements, stepsize stepsize, and offset 0.
References LinearRange::stepsize().
const LinearRange & assign | ( | int | n, |
double | offset, | ||
double | stepsize | ||
) |
Creates a range with n data elements starting at offset and incremented by stepsize.
References LinearRange::offset(), and LinearRange::stepsize().
const LinearRange & assign | ( | long | n, |
double | offset, | ||
double | stepsize | ||
) |
References LinearRange::offset(), and LinearRange::stepsize().
const LinearRange & assign | ( | double | r, |
double | stepsize | ||
) |
Creates a range starting at 0, ending at r, with increments stepsize. If stepsize equals zero it is set to r.
References LinearRange::index(), and LinearRange::stepsize().
const LinearRange & assign | ( | double | l, |
double | r, | ||
double | stepsize | ||
) |
Creates a range starting at l, ending at r, with increments stepsize. If stepsize equals zero it is set to r - l.
References LinearRange::index(), and LinearRange::stepsize().
const LinearRange & copy | ( | LinearRange & | r | ) | const |
Make r a copy of the range.
References LinearRange::assign().
const LinearRange & copy | ( | LinearRange & | r, |
long | first, | ||
long | last = -1 |
||
) | const |
Make r a copy of the range from index first (inclusively) to last (exclusively).
References LinearRange::assign().
const LinearRange & append | ( | long | n | ) |
Append n elements to the range.
|
inline |
The size of the range, i.e. the number of data elements.
Referenced by LinearRange::assign(), Array< T >::assign(), LinearRange::contains(), LinearRange::end(), LinearRange::max(), LinearRange::maxIndex(), LinearRange::min(), LinearRange::minIndex(), LinearRange::minMax(), LinearRange::minMaxIndex(), relacs::operator<(), relacs::operator<<(), relacs::operator==(), SampleData< T >::SampleData(), and LinearRange::setFront().
|
inline |
True if the range does not contain any data elements.
|
inline |
Resize the range to n elements without changing the offset() and the stepsize().
Referenced by relacs::operator<(), SampleData< relacs::SampleData >::range(), SampleData< T >::SampleData(), LinearRange::setBack(), and LinearRange::setFront().
|
inline |
Resize the range to zero length.
|
inline |
The offset of the range.
Referenced by EventData::append(), LinearRange::assign(), LinearRange::contains(), LinearRange::front(), EventData::insert(), EventData::offset(), relacs::operator<(), relacs::operator==(), and EventData::push().
|
inline |
Set the offset of the range to offset.
Referenced by EventData::append(), EventData::assign(), EventData::insert(), EventData::push(), and EventData::setOffset().
|
inline |
The stepsize of the range.
Referenced by LinearRange::assign(), LinearRange::contains(), relacs::operator<(), relacs::operator==(), and EventData::stepsize().
|
inline |
Set the stepsize of the range to stepsize. This also changes length() and rangeBack().
Referenced by EventData::setStepsize().
void scaleStepsize | ( | double | scale | ) |
Multiply the stepsize of the range by scale and adjust the size of the range appropriately. This does not change offset(), length(), and rangeBack().
References LinearRange::back(), and LinearRange::setBack().
|
inline |
Set the offset and the stepsize of the range to offset and stepsize, respectively.
|
inline |
The length of the range, i.e. abs( stepsize() * size() )
Referenced by EventData::length(), and relacs::sweep().
|
inline |
Set the size of the range such that it has the length l.
References relacs::ceil().
Referenced by EventData::append(), EventData::assign(), and EventData::setLength().
double front | ( | void | ) | const |
Returns the first range element. Same as offset().
References LinearRange::offset().
Referenced by EventData::insert(), EventData::push(), EventData::rangeFront(), and LinearRange::setBack().
void setFront | ( | double | front | ) |
Set the offset of the range to front without changing the last range element.
References LinearRange::back(), LinearRange::indices(), LinearRange::pos(), LinearRange::resize(), and LinearRange::size().
Referenced by EventData::insert(), EventData::push(), and EventData::setRangeFront().
double back | ( | void | ) | const |
Returns the last range element.
References LinearRange::pos().
Referenced by EventData::frequency(), EventData::interval(), EventData::push(), EventData::rangeBack(), EventData::rate(), LinearRange::scaleStepsize(), EventData::set(), and LinearRange::setFront().
void setBack | ( | double | back | ) |
Resize the range such that the last range element equals back.
References LinearRange::front(), LinearRange::index(), and LinearRange::resize().
Referenced by EventData::push(), LinearRange::scaleStepsize(), EventData::set(), and EventData::setRangeBack().
|
inline |
Returns the range element at index i.
|
inline |
Returns the range element at index i.
|
inline |
Returns the range element at index i.
Referenced by LinearRange::assign(), LinearRange::back(), LinearRange::contains(), LinearRange::max(), LinearRange::maxIndex(), LinearRange::min(), LinearRange::minIndex(), LinearRange::minMax(), LinearRange::minMaxIndex(), relacs::operator<<(), and LinearRange::setFront().
|
inline |
Returns the interval covered by indices indices.
|
inline |
The index of the range corresponding to pos.
References relacs::floor().
Referenced by LinearRange::assign(), LinearRange::LinearRange(), and LinearRange::setBack().
|
inline |
The number of indices corresponding to an interval iv.
References relacs::floor().
Referenced by LinearRange::setFront().
bool contains | ( | double | pos | ) | const |
True if pos is within the range.
References LinearRange::offset(), LinearRange::pos(), LinearRange::size(), and LinearRange::stepsize().
|
inline |
Add an element to the range.
void pop | ( | void | ) |
Remove an element from the range.
LinearRange::const_iterator begin | ( | void | ) | const |
Returns an const_iterator pointing to the first element of the range.
Referenced by relacs::alpha(), relacs::cos(), relacs::gauss(), relacs::line(), relacs::rectangle(), relacs::sawDown(), relacs::sawUp(), relacs::sin(), relacs::sweep(), and relacs::triangle().
LinearRange::const_iterator end | ( | void | ) | const |
Returns an const_iterator pointing behind the last element of the range.
References LinearRange::size().
const LinearRange & operator= | ( | double | val | ) |
Set the stepsize to zero and the offset to val.
const LinearRange & operator+= | ( | double | val | ) |
Add val to the offset, i.e. shift the range by val.
const LinearRange & operator-= | ( | double | val | ) |
Subtract val from the offset, i.e. shift the range by -val.
const LinearRange & operator*= | ( | double | val | ) |
Multiply the offset and the stepsize with val, i.e. rescale the range by val.
const LinearRange & operator/= | ( | double | val | ) |
Divide the offset and the stepsize by val, i.e. rescale the range by 1/val.
double min | ( | long | first = 0 , |
long | last = -1 |
||
) | const |
The minimum value of the range between indices first (inclusively) and last (exclusively). If last is negative it is set to size().
References LinearRange::pos(), and LinearRange::size().
long minIndex | ( | long | first = 0 , |
long | last = -1 |
||
) | const |
The index of the element with the minimum value of the range between indices first (inclusively) and last (exclusively), i.e. either first or last are returned. If last is negative it is set to size().
References LinearRange::pos(), and LinearRange::size().
long minIndex | ( | double & | min, |
long | first = 0 , |
||
long | last = -1 |
||
) | const |
The index of the element with the minimum value of the range between indices first (inclusively) and last (exclusively), i.e. either first or last are returned. If last is negative it is set to size(). The value of the minimum element is returned in min.
References LinearRange::pos(), and LinearRange::size().
double max | ( | long | first = 0 , |
long | last = -1 |
||
) | const |
The maximum value of the range between indices first (inclusively) and last (exclusively). If last is negative it is set to size().
References LinearRange::pos(), and LinearRange::size().
long maxIndex | ( | long | first = 0 , |
long | last = -1 |
||
) | const |
The index of the element with the maximum value of the range between indices first (inclusively) and last (exclusively), i.e. either first or last are returned. If last is negative it is set to size().
References LinearRange::pos(), and LinearRange::size().
long maxIndex | ( | double & | max, |
long | first = 0 , |
||
long | last = -1 |
||
) | const |
The index of the element with the maximum value of the range between indices first (inclusively) and last (exclusively), i.e. either first or last are returned. If last is negative it is set to size(). The value of the maximum element is returned in max.
References LinearRange::pos(), and LinearRange::size().
void minMax | ( | double & | min, |
double & | max, | ||
long | first = 0 , |
||
long | last = -1 |
||
) | const |
The minimum value min and maximum value max of the range between indices first (inclusively) and last (exclusively). If last is negative it is set to size().
References LinearRange::pos(), and LinearRange::size().
void minMaxIndex | ( | long & | minindex, |
long & | maxindex, | ||
long | first = 0 , |
||
long | last = -1 |
||
) | const |
The indices minindex and maxindex of the elements with the minimum and the maximum value of the range between indices first (inclusively) and last (exclusively), i.e. first or last. If last is negative it is set to size().
References LinearRange::pos(), and LinearRange::size().
void minMaxIndex | ( | double & | min, |
long & | minindex, | ||
double & | max, | ||
long & | maxindex, | ||
long | first = 0 , |
||
long | last = -1 |
||
) | const |
The indices minindex and maxindex of the elements with the minimum value min and the maximum value max of the range between indices first (inclusively) and last (exclusively), i.e. first or last. If last is negative it is set to size().
References LinearRange::pos(), and LinearRange::size().
|
friend |
True if range a and b are equal.
|
friend |
True if range a is smaller than b, i.e. either is smaller in size than b or the offset of is smaller or the stepsize of is smaller.
|
friend |
Add val to the offset of the range r, i.e. shift the range by val.
|
friend |
Add val to the offset of the range r, i.e. shift the range by val.
|
friend |
Subtract val from the offset of the range r, i.e. shift the range by -val.
|
friend |
Subtract the offset of the range r from val and multiply the stepsize by -1.
|
friend |
Multiply the offset and the stepsize of the range r with val, i.e. rescale the range by val.
|
friend |
Multiply the offset and the stepsize of the range r with val, i.e. rescale the range by val.
|
friend |
Divide the offset and the stepsize of the range r by val, i.e. rescale the range by 1/val.
|
friend |