RWalib C Array Library User Guide > Min and Max > alibMinMax
  

alibMinMax
Locates the extrema in an array. The PV-WAVE API for this routine is the MIN Function or MAX Function.
Prototypes
void alibMinMaxb( wvlong n, UCHAR *p, wvlong *r, UCHAR *e )
void alibMinMaxs( wvlong n, short *p, wvlong *r, short *e )
void alibMinMaxi( wvlong n, int *p, wvlong *r, int *e )
void alibMinMaxl( wvlong n, wvlong *p, wvlong *r, wvlong *e )
void alibMinMaxf( wvlong n, float *p, wvlong *r, float *e )
void alibMinMaxd( wvlong n, double *p, wvlong *r, double *e )
Parameters
n — (Input) The number of elements in the source array.
*p — (Input) The n-element source array.
*r — (Input/Output) A 2-element array, where r[0] is the index of the first occurrence of the minimum value in array p, and where r[1] is the index of the first occurrence of the maximum value in array p.
*e — (Input/Output) A 2-element array, where e[0] and e[1] are the minimum and maximum values in array p, respectively.
Example
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "alib.h"
void main() {
   /* make up some data for the example */
   UCHAR  b0[8]={6,1,7,2,5,0,4,3}, b1[64], b[2];
   wvlong bj[2];
   alibinit( NULL, NULL, NULL, NULL );
   alibRepArrayb( 1, 8, 8, b0, b1 );
   printf( "\n\n show (8,8) array b1" );
      alibPrintArrayb( 1, 1, 8, 8, b1, NULL );
   printf( "\n\n show the minimum and maximum values in array b1, \n" );
   printf( " and show the indices where they first occur in the array" );
      alibMinMaxb( 64, b1, bj, b );
      alibPrintArrayb( 1, 1, 1, 2, b, NULL );
      alibPrintArrayl( 1, 1, 1, 2, bj, NULL );
}
 
Output:
 
 show (8,8) array b1
 
   6   6   6   6   6   6   6   6
   1   1   1   1   1   1   1   1
   7   7   7   7   7   7   7   7
   2   2   2   2   2   2   2   2
   5   5   5   5   5   5   5   5
   0   0   0   0   0   0   0   0
   4   4   4   4   4   4   4   4
   3   3   3   3   3   3   3   3
 
 show the minimum and maximum values in array b1, 
 and show the indices where they first occur in the array
 
   0   7
 
                   40                   16

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.