Back to index

radiance  4R0+20100331
Functions | Variables
gcalc.c File Reference
#include <stdio.h>
#include <string.h>
#include "mgvars.h"

Go to the source code of this file.

Functions

static void gcheader (char *types)
static void calcpoint (int c, double x, double y)
static void gcvalue (int c, char *types)
void gcalc (char *types)
void gcheader (register char *types)
void gcvalue (int c, register char *types)

Variables

static const char RCSid [] = "$Id: gcalc.c,v 1.3 2003/11/15 02:13:37 schorsch Exp $"
static double xsum
static double xxsum
static double ysum
static double yysum
static double xysum
static double xmin
static double xmax
static double ymin
static double ymax
static double lastx
static double lasty
static double rsum
static int npts

Function Documentation

void calcpoint ( int  c,
double  x,
double  y 
) [static]

Definition at line 126 of file gcalc.c.

{
       if (x < xmin || x > xmax)
              return;

       xsum += x;
       xxsum += x*x;
       ysum += y;
       yysum += y*y;
       xysum += x*y;

       if (npts) {
              if (y < ymin)
                     ymin = y;
              else if (y > ymax)
                     ymax = y;
       } else
              ymin = ymax = y;

       if (npts)
              rsum += ( y + lasty )*( x - lastx )/2.0;
       lastx = x;
       lasty = y;

       npts++;
}

Here is the caller graph for this function:

void gcalc ( char *  types)

Definition at line 27 of file gcalc.c.

{
       int  i;

       if (strchr(types, 'h') == NULL)
              gcheader(types);
       
       xmin = gparam[XMIN].flags & DEFINED ?
                     varvalue(gparam[XMIN].name) :
                     -1e10;
       xmax = gparam[XMAX].flags & DEFINED ?
                     varvalue(gparam[XMAX].name) :
                     1e10;

       for (i = 0; i < MAXCUR; i++) {
              xsum = xxsum = ysum = yysum = xysum = 0.0;
              rsum = 0.0;
              npts = 0;
              mgcurve(i, calcpoint);
              gcvalue(i, types);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void gcheader ( char *  types) [static]

Here is the caller graph for this function:

void gcheader ( register char *  types)

Definition at line 54 of file gcalc.c.

{
       printf("__");
       while (*types)
              switch (*types++) {
              case 'n':
                     printf("|_Label___________");
                     break;
              case 'a':
                     printf("|____Mean______S.D._");
                     break;
              case 'm':
                     printf("|_____Min_______Max_");
                     break;
              case 'i':
                     printf("|___Integ_");
                     break;
              case 'l':
                     printf("|___Slope_____Intcp______Corr_");
                     break;
              default:
                     break;
              }
       printf("\n");
}
static void gcvalue ( int  c,
char *  types 
) [static]

Here is the caller graph for this function:

void gcvalue ( int  c,
register char *  types 
)

Definition at line 84 of file gcalc.c.

{
       double  d1, d2, d3, sqrt();

       if (npts < 1)
              return;

       printf("%c:", c+'A');
       while (*types)
              switch (*types++) {
              case 'n':
                     printf("  %-16s", cparam[c][CLABEL].flags & DEFINED ?
                                   cparam[c][CLABEL].v.s : "");
                     break;
              case 'a':
                     d1 = sqrt((yysum - ysum*ysum/npts)/(npts-1));
                     printf(" %9.2f %9.3f", ysum/npts, d1);
                     break;
              case 'm':
                     printf(" %9.2f %9.2f", ymin, ymax);
                     break;
              case 'i':
                     printf(" %9.2f", rsum);
                     break;
              case 'l':
                     d3 = xxsum - xsum*xsum/npts;
                     d1 = (xysum - xsum*ysum/npts)/d3;
                     d2 = (ysum - d1*xsum)/npts;
                     d3 = d1*sqrt(d3/(yysum - ysum*ysum/npts));
                     printf(" %9.5f %9.2f %9.5f", d1, d2, d3);
                     break;
              default:
                     break;
              }
       printf("\n");
}

Variable Documentation

double lastx [static]

Definition at line 19 of file gcalc.c.

double lasty [static]

Definition at line 19 of file gcalc.c.

int npts [static]

Definition at line 20 of file gcalc.c.

const char RCSid[] = "$Id: gcalc.c,v 1.3 2003/11/15 02:13:37 schorsch Exp $" [static]

Definition at line 2 of file gcalc.c.

double rsum [static]

Definition at line 19 of file gcalc.c.

double xmax [static]

Definition at line 18 of file gcalc.c.

double xmin [static]

Definition at line 18 of file gcalc.c.

double xsum [static]

Definition at line 17 of file gcalc.c.

double xxsum [static]

Definition at line 17 of file gcalc.c.

double xysum [static]

Definition at line 17 of file gcalc.c.

double ymax [static]

Definition at line 18 of file gcalc.c.

double ymin [static]

Definition at line 18 of file gcalc.c.

double ysum [static]

Definition at line 17 of file gcalc.c.

double yysum [static]

Definition at line 17 of file gcalc.c.