/* nag_robust_corr_estim(g02hkc) Example Program. * * Copyright 1996 Numerical Algorithms Group. * * Mark 4, 1996. * */ #include #include #include #include #define NMAX 20 #define MMAX 10 int main(void) { Integer i, j, k, m, n; double x[NMAX][MMAX], theta[MMAX]; Integer tdx=MMAX; Integer max_iter, l1, l2; Integer print_iter; double eps, cov[15]; Integer iter; double tol; Vprintf("g02hkc Example Program Results\n\n"); /* Skip heading in data file */ Vscanf("%*[^\n]\n"); /* Read in the dimensions of X */ Vscanf("%ld %ld %*[^\n]\n", &n, &m); if (n <= NMAX && m <= MMAX) { /* Read in the x matrix */ for (i = 1; i <= n; ++i) { for (j = 1; j <= m; ++j) Vscanf("%lf", &x[i-1][j-1]); Vscanf("%*[^\n]\n"); } /* Read in value of eps */ Vscanf("%lf%*[^\n]\n", &eps); /* Set up remaining parameters */ max_iter = 100; tol = 5e-5; /* Set print_iter to positive value for iteration moiteroring */ print_iter = 1; g02hkc(n, m, &x[0][0], tdx, eps, cov, theta, max_iter, print_iter, "", tol, &iter, NAGERR_DEFAULT); Vprintf("\n\ng02hkc required %ld iterations to converge\n\n", iter); Vprintf("Covariance matrix\n"); l2 = 0; for (j = 1; j <= m; ++j) { l1 = l2 + 1; l2 += j; for (k = l1; k <= l2; ++k) Vprintf("%10.3f", cov[k - 1]); Vprintf("\n"); } Vprintf("\n\ntheta\n"); for (j = 1; j <= m; ++j) Vprintf("%10.3f\n", theta[j - 1]); } return EXIT_SUCCESS; }