VF_ismonotonVD_ismonotonVE_ismonoton
FunctionTest if the elements of a vector are monotonously increasing or decreasing
Syntax C/C++#include <VFstd.h>
int VF_ismonoton( fVector X, ui size );
C++ VecObj#include <OptiVec.h>
int vector<T>::ismonoton( const vector<T>& X );
Pascal/Delphiuses VFstd;
function VF_ismonoton( X:fVector; size:UIntSize ): Integer;
DescriptionThe vector X is analyzed. If the elements are in strict descending order, -1 is returned; if they are either constant or in strict ascending order, +1 is returned. Otherwise the return value is 0. If X contains passages that are increasing as well as passages that remain at a constant value, X is regarded as monotonous only if the increasing passage follows the constant passage, but not the other way round. Thus, the series 0, 0, 0, 1, 2, 3 will be accepted as monotonous (return value +1), whereas the series 1, 2, 3, 4, 4, 4 will not (return value 0). Also the initially constant, then falling series 0, 0, 0, -1, -2, -3 will not be regarded as monotonous.
Error handlingnone
Return value+1 in case of monotonous rise, or if all elements are identical, -1 in case of monotonously falling values, 0 if neither of these conditions is fulfilled.
See alsoVF_sort

VectorLib Table of Contents  OptiVec home