The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



MinMax


Unit:SDL_vector
Class: TVector, TIntVector
Declaration: [1] procedure MinMax (LowElem, HighElem: integer; var Minimum, Maximum: double); { class TVector }
[2]
procedure MinMax (LowElem, HighElem: integer; var Minimum, Maximum: double; var MinIx, MaxIx: integer); { class TVector }

[1] procedure MinMax (LowElem, HighElem: integer; var Minimum, Maximum: integer); { class TIntVector }
[2] procedure MinMax (LowElem, HighElem: integer; var Minimum, Maximum: integer; var MinIx, MaxIx: integer); { class TIntVector }

The method MinMax calculates the minimum and the maximum value of the vector elements within a specified range. The range of the vector elements which are used for the calculation is determined by the parameters LowElem and HighElem. If any of these parameters receives an invalid value, this value is automatically adjusted to the most appropriate boundary (either 1 or NrOfElems). Setting both the LowElem and HighElem parameter to zero forces the method to process the entire range of vector elements.

Note, that in the case of the method MinMax the vector is not considered as a vector in its usual sense but merely as a collection of numbers.

The lowest and the highest value of the selected data are returned in the variable parameters Minimum and Maximum. Version [2] returns in addition to the extreme values also the indices MinIx and MaxIx of the extreme values.

Hint: Setting both LowElem and HighElem to zero values forces the method to scan the entire vector for the extreme values.

Example: The statement Vec1.MinMax (10,20,Rmin,Rmax); calculates the lowest and the highest value of the elements with the index 10 to 20 of vector Vec1 and returns them in the variables RMin and RMax.

Example: This method is used in the following example program (see http://www.lohninger.com/examples.html for downloading the code): testvec



Last Update: 2023-Feb-06