GRASS Programmer's Manual  6.4.2(2012)
extreme.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <math.h>
00003 
00004 
00005 double *extreme(double *x, int n)
00006 {
00007     int i;
00008     static double y[2];
00009     double min, max, sum1 = 0.;
00010 
00011     min = max = x[0];
00012     for (i = 0; i < n; ++i) {
00013         sum1 += x[i];
00014         if (min > x[i])
00015             min = x[i];
00016 
00017         if (max < x[i])
00018             max = x[i];
00019     }
00020     sum1 /= n;
00021 
00022     y[0] = max - sum1;
00023     y[1] = min - sum1;
00024 
00025 #ifdef NOISY
00026     fprintf(stdout, "  TEST3  U(N)   =%10.4f   U(1)   =%10.4f\n", y[0], y[1]);
00027 #endif /* NOISY */
00028 
00029     return y;
00030 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines