DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T a

⟦2c1dbf0f9⟧ TextFile

    Length: 813 (0x32d)
    Types: TextFile
    Names: »average.c«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/euug-87hel/sec1/graph/average.c« 

TextFile

/*
 * Copyright (C) 1986   Alan Kent
 *
 * Permission is granted to freely distribute part or
 * all of this code as long as it is not for profit
 * and this message is retained in the code.
 *
 * No resposibility is taken for any damage or incorect
 * results this program generates.
 * 
 */


#include <stdio.h>
#include "graph.h"


double
average_fun ( table , from , to )
table_st *table;
int from , to;
{
    int i;
    double val;

    if ( table == NULL )
	abort ( "AVERAGE requires at least a single column table" );
    if ( table->size < 1 ) {
	warn ( "AVERAGE requires at least one value in table " );
	return ( 0.0 );
    }
    if ( to >= table->size )
	to = table->size - 1;
    val = 0.0;
    for ( i = from; i <= to; i++ )
	val += table->data[i];
    return ( val / (double)( to - from + 1 ) );
}