ARPDAS_QNX6 1.0
average.c
Go to the documentation of this file.
00001 /* average.c support for new cycle programs */
00002 #include "average.h"
00003 
00004 char rcsid_average_c[] = "$Header: /cvsroot/arp-das/QNX6/tmlib/src/average.c,v 1.2 2011/03/23 21:41:02 ntallen Exp $";
00005 
00006 double Average_Value( Average_Data *data ) {
00007   double avg = 0.;
00008   if ( data->count > 0 )
00009         avg = data->sum / data->count;
00010   data->sum = 0;
00011   data->count = 0;
00012   return avg;
00013 }
00014 
00015 void Average_Point( Average_Data *data, double pt ) {
00016   data->count++;
00017   data->sum += pt;
00018 }
00019 
00020 /*
00021 =Name Average_Value(): Return average of summed data
00022 =Subject Average Functions
00023 =Name Average_Point(): Added data point to sum for average
00024 =Subject Average Functions
00025 =Name Average_Data: Data type for =Average Functions=
00026 =Subject Average Functions
00027 
00028 =Synopsis
00029 #include "average.h"
00030 
00031 double Average_Value( Average_Data *data );
00032 void Average_Point( Average_Data *data, double pt );
00033 
00034 =Description
00035 
00036 Average_Point() and Average_Value() are used together to simplify
00037 realtime averaging. The Average_Data data structure holds the
00038 current sum and number of data points. Average_Value() resets the
00039 count and sum.
00040 
00041 =Returns
00042 
00043 Average_Value() returns the average of points previously passed
00044 to Average_Point().
00045 
00046 =SeeAlso
00047 
00048 =Average Functions=.
00049 
00050 =End
00051 */
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines