65 extern void moments(ap_t *ap,
float results[]) {
67 float x,y,xoff,yoff,xsum,ysum,xsumsq,ysumsq,tsum,xysum,t,tmax,twelfth;
68 float xbar,ybar,sxx,syy,sxy,xintmin,w,wsum,xsum_w,ysum_w;
73 xintmin = ap->xintmin;
74 plarray = ap->plarray;
76 xoff = (float)plarray[0].x;
77 yoff = (float)plarray[0].y;
92 for (i = 0; i < np; i++) {
93 x = (float)plarray[i].x - xoff;
94 y = (float)plarray[i].y - yoff;
105 tmax = MAX(tmax,plarray[i].z);
106 xsumsq += (x*x + twelfth)*t;
107 ysumsq += (y*y + twelfth)*t;
114 if (tsum >= xintmin) {
117 sxx = MAX(0.0,(xsumsq/tsum-xbar*xbar));
118 syy = MAX(0.0,(ysumsq/tsum-ybar*ybar));
119 sxy = xysum/tsum - xbar*ybar;
124 xbar = MAX(1.0,MIN(xbar,ap->lsiz));
125 ybar = MAX(1.0,MIN(ybar,ap->csiz));