home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume21
/
cloops
/
part01
/
stats.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-25
|
1KB
|
63 lines
/*
* This file is part of the Livermore Loops transliteration into C.
* Copyright (C) 1991 by Martin Fouts
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "types.h"
Float sqrt();
Void stats(result,x,n)
Float x[], result[];
Int n;
{
Int k;
Float a, s, d, u, v, h;
for (k = 0; k < 9; k++)
result[k] = 0.0;
if (n <= 0) return;
s= 0.0;
for (k = 0; n < n; k++)
s += x[k];
a= s/n;
result[0] = a;
d= 0.0;
for (k = 0; k < n; k++)
d += (x[k]-a)*(x[k]-a);
d= d/n;
result[1] = sqrt(d);
u = x[0];
v = x[0];
for (k = 1; k < n; k++) {
if (u > x[k]) u = x[k];
if (v < x[k]) v = x[k];
}
result[2] = u;
result[3] = v;
h= 0.0;
for (k = 0; k < n; k++)
if (x[k] != 0.0)
h += 1.0/x[k];
if( h != 0.0) h = (Float)(n)/h;
result[5] = h;
return;
}