Compute a field using regression coefficients and the field values. More...
#include <regress.h>
Go to the source code of this file.
Functions | |
void | apply_regression (double *buf, double *reg, double *cst, double *dist, double *sup_dist, int npts, int ntime, int nclust, int nreg) |
Compute a field using regression coefficients and the field values. |
Compute a field using regression coefficients and the field values.
Definition in file apply_regression.c.
void apply_regression | ( | double * | buf, | |
double * | reg, | |||
double * | cst, | |||
double * | dist, | |||
double * | sup_dist, | |||
int | npts, | |||
int | ntime, | |||
int | nclust, | |||
int | nreg | |||
) |
Compute a field using regression coefficients and the field values.
[out] | buf | 2D field |
[in] | reg | Regression coefficients |
[in] | cst | Regression constant |
[in] | dist | Values of input vector |
[in] | sup_dist | If there is one supplemental regression coefficient, use a supplemental vector |
[in] | npts | Points dimension |
[in] | ntime | Time dimension |
[in] | nclust | Cluster dimension |
[in] | nreg | Regression dimension |
Definition at line 59 of file apply_regression.c.
Referenced by wt_downscaling().
00060 { 00073 int nt; /* Time loop counter */ 00074 int pts; /* Points loop counter */ 00075 int clust; /* Cluster loop counter */ 00076 00077 /* Loop over all regression points */ 00078 for (pts=0; pts<npts; pts++) { 00079 /* Loop over all times */ 00080 for (nt=0; nt<ntime; nt++) { 00081 /* Initialize value */ 00082 buf[pts+nt*npts] = 0.0; 00083 /* Loop over all clusters and add each value after regression is applied */ 00084 for (clust=0; clust<nclust; clust++) { 00085 buf[pts+nt*npts] += (dist[nt+clust*ntime] * reg[pts+clust*npts]); 00086 00087 // if (pts == 0 && nt == (ntime-5)) 00088 // printf("%d %lf %lf %lf\n",clust,buf[pts+nt*npts],(dist[nt+clust*ntime]),(reg[pts+clust*npts])); 00089 } 00090 /* Extra regression coefficient with a second supplemental vector */ 00091 if (nclust == (nreg-1)) { 00092 buf[pts+nt*npts] += (sup_dist[nt] * reg[pts+(nreg-1)*npts]); 00093 } 00094 00095 /* Add regression constant */ 00096 buf[pts+nt*npts] += cst[pts]; 00097 00098 // if (pts == 0 && nt == (ntime-5)) 00099 // printf("%lf %lf\n",buf[pts+nt*npts],cst[pts]); 00100 } 00101 } 00102 // nt = ntime-1; 00103 // pts = 0; 00104 // for (clust=0; clust<nclust; clust++) 00105 // printf("REGRESS %d %lf %lf %lf %lf\n",clust,buf[pts+nt*npts],dist[nt+clust*ntime],reg[pts+clust*npts],cst[pts]); 00106 }