valarray::min
Finds the smallest element in a valarray.
Type min( ) const;
Return Value
The minimum value of the elements in the operand valarray.
Remarks
The member function compares values by applying operator< or operator> between pairs of elements of class Type, for which operators must be provided for the element Type.
Example
// valarray_min.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>
int main( )
{
using namespace std;
int i, MinValue;
valarray<int> vaR ( 10 );
for ( i = 0 ; i < 10 ; i += 3 )
vaR [ i ] = -i;
for ( i = 1 ; i < 10 ; i += 3 )
vaR [ i ] = 2*i;
for ( i = 2 ; i < 10 ; i += 3 )
vaR [ i ] = 5 - i;
cout << "The operand valarray is: ( ";
for ( i = 0 ; i < 10 ; i++ )
cout << vaR [ i ] << " ";
cout << ")." << endl;
MinValue = vaR.min ( );
cout << "The smallest element in the valarray is: "
<< MinValue << "." << endl;
}
The operand valarray is: ( 0 2 3 -3 8 0 -6 14 -3 -9 ). The smallest element in the valarray is: -9.
Requirements
Header: <valarray>
Namespace: std