10 #include "AreaBelow.h"
13 * Return the area enclosed by all of the curves. The algorithm
14 * used is the same as the trapizoidal rule for integration.
30 maxima = (floatish *) xmalloc(nsamples * sizeof(floatish));
31 for (i = 0; i < nsamples; i++) {
35 for (i = 0; i < nidents; i++) {
36 for (ch = identtable[i]->chk; ch; ch = ch->next) {
37 for (j = 0; j < ch->nd; j++) {
38 bucket = ch->d[j].bucket;
39 value = ch->d[j].value;
40 if (bucket >= nsamples)
41 Disaster("bucket out of range");
42 maxima[ bucket ] += value;
49 for (i = 1; i < nsamples; i++) {
50 base = samplemap[i] - samplemap[i-1];
51 if (maxima[i] > maxima[i-1]) {
52 trap = base * maxima[i-1] + ((base * (maxima[i] - maxima[i-1]))/ 2.0);
54 trap = base * maxima[i] + ((base * (maxima[i-1] - maxima[i]))/ 2.0);