Relacs Numerics Library  0.9.8
Public Types | Public Member Functions | Friends | List of all members
LinearRange Class Reference

#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 LinearRangeoperator= (const LinearRange &r)
 
const LinearRangeassign (const LinearRange &r)
 
const LinearRangeassign (const LinearRange &r, long first, long last=-1)
 
const LinearRangeassign (int n, double stepsize)
 
const LinearRangeassign (long n, double stepsize)
 
const LinearRangeassign (int n, double offset, double stepsize)
 
const LinearRangeassign (long n, double offset, double stepsize)
 
const LinearRangeassign (double r, double stepsize)
 
const LinearRangeassign (double l, double r, double stepsize)
 
const LinearRangecopy (LinearRange &r) const
 
const LinearRangecopy (LinearRange &r, long first, long last=-1) const
 
const LinearRangeappend (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 LinearRangeoperator= (double val)
 
const LinearRangeoperator+= (double val)
 
const LinearRangeoperator-= (double val)
 
const LinearRangeoperator*= (double val)
 
const LinearRangeoperator/= (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)
 

Detailed Description

A linear range of discretized numbers.

Author
Jan Benda

Member Typedef Documentation

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.

Const iterator used to iterate through a range.

Constructor & Destructor Documentation

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.

~LinearRange ( void  )
virtual

The destructor.

Member Function Documentation

const LinearRange& operator= ( const LinearRange r)
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 
)
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.

long size ( void  ) const
inline
bool empty ( void  ) const
inline

True if the range does not contain any data elements.

void resize ( long  n)
inline

Resize the range to n elements without changing the offset() and the stepsize().

Referenced by relacs::operator<(), SampleData< T >::range(), SampleData< T >::SampleData(), LinearRange::setBack(), and LinearRange::setFront().

void clear ( void  )
inline

Resize the range to zero length.

double offset ( void  ) const
inline
void setOffset ( double  offset)
inline

Set the offset of the range to offset.

Referenced by EventData::append(), EventData::assign(), EventData::insert(), EventData::push(), and EventData::setOffset().

double stepsize ( void  ) const
inline
void setStepsize ( double  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().

void setRange ( double  offset,
double  stepsize 
)
inline

Set the offset and the stepsize of the range to offset and stepsize, respectively.

double length ( void  ) const
inline

The length of the range, i.e. abs( stepsize() * size() )

Referenced by EventData::length(), and relacs::sweep().

void setLength ( double  l)
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
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().

double operator[] ( long  i) const
inline

Returns the range element at index i.

double at ( long  i) const
inline

Returns the range element at index i.

double pos ( long  i) const
inline
double interval ( int  indices) const
inline

Returns the interval covered by indices indices.

long index ( double  pos) const
inline

The index of the range corresponding to pos.

References relacs::floor().

Referenced by LinearRange::assign(), LinearRange::LinearRange(), and LinearRange::setBack().

long indices ( double  iv) const
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().

void push ( void  )
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().

Friends And Related Function Documentation

bool operator== ( const LinearRange r,
const LinearRange b 
)
friend

True if range a and b are equal.

bool operator< ( const LinearRange r,
const LinearRange b 
)
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.

LinearRange operator+ ( const LinearRange r,
double  val 
)
friend

Add val to the offset of the range r, i.e. shift the range by val.

LinearRange operator+ ( double  val,
const LinearRange r 
)
friend

Add val to the offset of the range r, i.e. shift the range by val.

LinearRange operator- ( const LinearRange r,
double  val 
)
friend

Subtract val from the offset of the range r, i.e. shift the range by -val.

LinearRange operator- ( double  val,
const LinearRange r 
)
friend

Subtract the offset of the range r from val and multiply the stepsize by -1.

LinearRange operator* ( const LinearRange r,
double  val 
)
friend

Multiply the offset and the stepsize of the range r with val, i.e. rescale the range by val.

LinearRange operator* ( double  val,
const LinearRange r 
)
friend

Multiply the offset and the stepsize of the range r with val, i.e. rescale the range by val.

LinearRange operator/ ( const LinearRange r,
double  val 
)
friend

Divide the offset and the stepsize of the range r by val, i.e. rescale the range by 1/val.

ostream& operator<< ( ostream &  str,
const LinearRange r 
)
friend

The documentation for this class was generated from the following files: