diff --git a/src/library/stats/src/loglin.c b/src/library/stats/src/loglin.c index 45dfb002b8..a6adcd317f 100644 --- a/src/library/stats/src/loglin.c +++ b/src/library/stats/src/loglin.c @@ -42,14 +42,14 @@ loglin(int nvar, int *dim, int ncon, int *config, int ntab, double x, y, xmax; /* Parameter adjustments */ - --dim; +// --dim; // --locmar; // config -= nvar + 1; - --fit; - --table; +// --fit; +// --table; // --marg; - --u; - --dev; +// --u; +// --dev; /* Function body */ @@ -68,7 +68,7 @@ loglin(int nvar, int *dim, int ncon, int *config, int ntab, L10: size = 1; - for (j = 1; j <= nvar; j++) { + for (j = 0; j < nvar; j++) { if (dim[j] <= 0) goto L5; size *= dim[j]; } @@ -79,7 +79,7 @@ loglin(int nvar, int *dim, int ncon, int *config, int ntab, L40: x = 0.; y = 0.; - for (i = 1; i <= size; i++) { + for (i = 0; i < size; i++) { if (table[i] < 0. || fit[i] < 0.) goto L5; x += table[i]; y += fit[i]; @@ -90,7 +90,7 @@ loglin(int nvar, int *dim, int ncon, int *config, int ntab, if (y == 0.) goto L5; x /= y; - for (i = 1; i <= size; i++) fit[i] = x * fit[i]; + for (i = 0; i < size; i++) fit[i] = x * fit[i]; if (ncon <= 0 || config[0] == 0) return; /* Allocate marginal tables */ @@ -119,7 +119,7 @@ loglin(int nvar, int *dim, int ncon, int *config, int ntab, if (check[k - 1]) goto L95; check[k - 1] = 1; /* Get size */ - size *= dim[k]; + size *= dim[k-1]; } /* Since U is used to store fitted marginals, size must not @@ -148,7 +148,7 @@ loglin(int nvar, int *dim, int ncon, int *config, int ntab, for (j = 1; j <= nvar; j++) { icon[j - 1] = config[j + i * nvar - (nvar+1)]; } - collap(nvar, &table[1], marg, locmar[i-1], &dim[1], icon); + collap(nvar, table, marg, locmar[i-1], dim, icon); } /* Perform iterations */ @@ -160,11 +160,11 @@ loglin(int nvar, int *dim, int ncon, int *config, int ntab, for (i = 1; i <= n; i++) { for (j = 1; j <= nvar; j++) icon[j - 1] = config[j + i * nvar - (nvar+1)]; - collap(nvar, &fit[1], &u[1], 1, &dim[1], icon); - adjust(nvar, &fit[1], &u[1], marg, &locmar[i-1], &dim[1], icon, &xmax); + collap(nvar, fit, u, 1, dim, icon); + adjust(nvar, fit, u, marg, &locmar[i-1], dim, icon, &xmax); } /* Test convergence */ - dev[k] = xmax; + dev[k-1] = xmax; if (xmax < maxdev) goto L240; } if (maxit > 1) goto L230;