Allows to conveniently handle (one-dimensional) grids consisting of time points. More...
#include <grid.hpp>
Public Member Functions | |
returnValue | addTime (double _time) |
returnValue | coarsenGrid (uint factor) |
returnValue | equalizeGrids (Grid &arg) |
int | findFirstTime (double _time, uint startIdx=0) const |
int | findLastTime (double _time, uint startIdx=0) const |
int | findTime (double _time, uint startIdx=0) const |
uint | getCeilIndex (double time) const |
double | getFirstTime () const |
uint | getFloorIndex (double time) const |
double | getIntervalLength () const |
double | getIntervalLength (uint pointIdx) const |
uint | getLastIndex () const |
double | getLastTime () const |
uint | getNumIntervals () const |
uint | getNumPoints () const |
returnValue | getSubGrid (double tStart, double tEnd, Grid &_subGrid) const |
double | getTime (uint pointIdx) const |
Grid () | |
Grid (uint nPoints_, double *times_=0) | |
Grid (const DVector ×_) | |
Grid (double _firstTime, double _lastTime, uint _nPoints=2) | |
Grid (const Grid &rhs) | |
BooleanType | hasTime (double _time) const |
returnValue | init (uint _nPoints=0, const double *const _times=0) |
returnValue | init (const DVector ×_) |
returnValue | init (double _firstTime, double _lastTime, uint _nPoints=2) |
returnValue | init (const Grid &rhs) |
BooleanType | isEmpty () const |
BooleanType | isEquidistant () const |
BooleanType | isInInterval (double _time) const |
BooleanType | isInInterval (uint pointIdx, double _time) const |
BooleanType | isInLowerHalfOpenInterval (uint pointIdx, double _time) const |
BooleanType | isInUpperHalfOpenInterval (uint pointIdx, double _time) const |
BooleanType | isLast (uint pointIdx) const |
returnValue | merge (const Grid &arg, MergeMethod _mergeMethod=MM_DUPLICATE, BooleanType keepOverlap=BT_TRUE) |
BooleanType | operator!= (const Grid &arg) const |
Grid & | operator& (const Grid &arg) |
BooleanType | operator< (const Grid &arg) const |
BooleanType | operator<= (const Grid &arg) const |
Grid & | operator= (const Grid &rhs) |
BooleanType | operator== (const Grid &arg) const |
BooleanType | operator> (const Grid &arg) const |
BooleanType | operator>= (const Grid &arg) const |
returnValue | print () const |
returnValue | refineGrid (uint factor) |
returnValue | scaleTimes (double scaling) |
returnValue | setTime (double _time) |
returnValue | setTime (uint pointIdx, double _time) |
Grid & | shiftTimes (double timeShift) |
~Grid () | |
Protected Member Functions | |
int | findNextIndex () const |
returnValue | setupEquidistant (double _firstTime, double _lastTime) |
Protected Attributes | |
uint | nPoints |
double * | times |
Allows to conveniently handle (one-dimensional) grids consisting of time points.
The class Grid allows to conveniently handle (one-dimensional) grids consisting of time points, as they usually occur when discretizing optimal control problems.
Grid::Grid | ( | uint | nPoints_, |
double * | times_ = 0 |
||
) |
Grid::Grid | ( | const DVector & | times_ | ) |
Grid::Grid | ( | double | _firstTime, |
double | _lastTime, | ||
uint | _nPoints = 2 |
||
) |
Constructor that takes the number of grid points as well as as the time of the first and the last grid point. All intermediate grid points are setup to form a equidistant grid of time points.
[in] | _firstTime | Time of first grid point. |
[in] | _lastTime | Time of last grid point. |
[in] | _nPoints | Number of grid points. |
Grid::Grid | ( | const Grid & | rhs | ) |
Grid::~Grid | ( | ) |
returnValue Grid::addTime | ( | double | _time | ) |
returnValue Grid::coarsenGrid | ( | uint | factor | ) |
returnValue Grid::equalizeGrids | ( | Grid & | arg | ) |
int Grid::findFirstTime | ( | double | _time, |
uint | startIdx = 0 |
||
) | const |
int Grid::findLastTime | ( | double | _time, |
uint | startIdx = 0 |
||
) | const |
int Grid::findNextIndex | ( | ) | const [protected] |
int Grid::findTime | ( | double | _time, |
uint | startIdx = 0 |
||
) | const |
uint Grid::getCeilIndex | ( | double | time | ) | const |
Returns index of grid point with smallest time greater or equal to given time.
[in] | _time | Time smaller or equal than that of the time point to be found. |
double Grid::getFirstTime | ( | ) | const [inline] |
Returns time of first grid point.
uint Grid::getFloorIndex | ( | double | time | ) | const |
Returns index of grid point with greatest time smaller or equal to given time.
[in] | _time | Time greater or equal than that of the time point to be found. |
double Grid::getIntervalLength | ( | ) | const [inline] |
Returns total interval length of grid.
double Grid::getIntervalLength | ( | uint | pointIdx | ) | const [inline] |
Returns interval length between given grid point and next one.
[in] | pointIdx | Index of grid point at beginning of interval. |
uint Grid::getLastIndex | ( | ) | const [inline] |
Returns largest index of grid (note the difference to getNumPoints()).
double Grid::getLastTime | ( | ) | const [inline] |
Returns time of last grid point.
uint Grid::getNumIntervals | ( | ) | const [inline] |
Returns number of grid intervals.
uint Grid::getNumPoints | ( | ) | const [inline] |
Returns number of grid points.
returnValue Grid::getSubGrid | ( | double | tStart, |
double | tEnd, | ||
Grid & | _subGrid | ||
) | const |
double Grid::getTime | ( | uint | pointIdx | ) | const [inline] |
Returns time of grid point with given index.
[in] | pointIdx | Index of grid point. |
BooleanType Grid::hasTime | ( | double | _time | ) | const |
returnValue Grid::init | ( | uint | _nPoints = 0 , |
const double *const | _times = 0 |
||
) |
returnValue Grid::init | ( | const DVector & | times_ | ) |
returnValue Grid::init | ( | double | _firstTime, |
double | _lastTime, | ||
uint | _nPoints = 2 |
||
) |
Initializes grid with given number of grid points and an equidistant grid of time points between given time of the first and last grid point.
[in] | _firstTime | Time of first grid point. |
[in] | _lastTime | Time of last grid point. |
[in] | _nPoints | Number of grid points. |
returnValue Grid::init | ( | const Grid & | rhs | ) |
BooleanType Grid::isEmpty | ( | ) | const [inline] |
Returns whether the grid is empty (i.e. no grid points) or not.
BooleanType Grid::isEquidistant | ( | ) | const [inline] |
Returns whether the grid has equally spaced grid points or not.
BooleanType Grid::isInInterval | ( | double | _time | ) | const [inline] |
Returns whether given time lies within the total interval of the grid.
[in] | _time | Time point to be checked. |
BooleanType Grid::isInInterval | ( | uint | pointIdx, |
double | _time | ||
) | const [inline] |
Returns whether given time lies within the interval between given grid point and next one.
[in] | pointIdx | Index of grid point at beginning of interval. |
[in] | _time | Time point to be checked. |
BooleanType Grid::isInLowerHalfOpenInterval | ( | uint | pointIdx, |
double | _time | ||
) | const [inline] |
Returns whether given time lies within the half-open interval between given grid point (given grid point not included) and next one.
[in] | pointIdx | Index of grid point at beginning of interval. |
[in] | _time | Time point to be checked. |
BooleanType Grid::isInUpperHalfOpenInterval | ( | uint | pointIdx, |
double | _time | ||
) | const [inline] |
Returns whether given time lies within the half-open interval between given grid point and next one (next one not included).
[in] | pointIdx | Index of grid point at beginning of interval. |
[in] | _time | Time point to be checked. |
BooleanType Grid::isLast | ( | uint | pointIdx | ) | const [inline] |
Returns whether given index is the last one of the grid.
[in] | pointIdx | Index of grid point. |
returnValue Grid::merge | ( | const Grid & | arg, |
MergeMethod | _mergeMethod = MM_DUPLICATE , |
||
BooleanType | keepOverlap = BT_TRUE |
||
) |
Constructs the set union in time of current and given grid. A merge method defines the way duplicate entries are handled. Moreover, it can be specified whether an overlap in time of both grids shall be kept or if only the entries of one of them shall be kept according to the merge method.
[in] | arg | Grid to append. |
[in] | _mergeMethod | Merge method, see documentation of MergeMethod for details. |
[in] | keepOverlap | Flag indicating whether overlap shall be kept. |
BooleanType Grid::operator!= | ( | const Grid & | arg | ) | const [inline] |
Tests for non-equality.
[in] | rhs | Object of comparison. |
BooleanType Grid::operator< | ( | const Grid & | arg | ) | const [inline] |
Tests if left-hand side grid is a strict subset of the right-hand side one, i.e. if each the rhs grid contains all time points of the lhs (but is not equal).
[in] | rhs | Object of comparison. |
BooleanType Grid::operator<= | ( | const Grid & | arg | ) | const [inline] |
Tests if left-hand side grid is a subset of the right-hand side one, i.e. if each the rhs grid contains all time points of the lhs.
[in] | rhs | Object of comparison. |
BooleanType Grid::operator== | ( | const Grid & | arg | ) | const [inline] |
Tests for equality, i.e. if number of grid points AND time values at all grid points are equal.
[in] | rhs | Object of comparison. |
BooleanType Grid::operator> | ( | const Grid & | arg | ) | const [inline] |
Tests if right-hand side grid is a strict subset of the left-hand side one, i.e. if each the lhs grid contains all time points of the rhs (but is not equal).
[in] | rhs | Object of comparison. |
BooleanType Grid::operator>= | ( | const Grid & | arg | ) | const [inline] |
Tests if right-hand side grid is a subset of the left-hand side one, i.e. if each the lhs grid contains all time points of the rhs.
[in] | rhs | Object of comparison. |
returnValue Grid::print | ( | ) | const |
returnValue Grid::refineGrid | ( | uint | factor | ) |
returnValue Grid::scaleTimes | ( | double | scaling | ) |
returnValue Grid::setTime | ( | double | _time | ) |
returnValue Grid::setTime | ( | uint | pointIdx, |
double | _time | ||
) |
returnValue Grid::setupEquidistant | ( | double | _firstTime, |
double | _lastTime | ||
) | [protected] |
Grid & Grid::shiftTimes | ( | double | timeShift | ) |
Shifts times at all grid points by a given offset.
[in] | timeShift | Time offset for shifting. |
Reimplemented in MatrixVariablesGrid, and VariablesGrid.
uint Grid::nPoints [protected] |
double* Grid::times [protected] |