cleaning covar

This commit is contained in:
Thomas Capricelli 2009-08-24 17:49:37 +02:00
parent 17905c7399
commit 4e62e29869
2 changed files with 3 additions and 6 deletions

View File

@ -25,10 +25,9 @@ void ei_covar(
for (j = 0; j <= k-1; ++j) { for (j = 0; j <= k-1; ++j) {
temp = r(k,k) * r(j,k); temp = r(k,k) * r(j,k);
r(j,k) = 0.; r(j,k) = 0.;
for (i = 0; i <= j; ++i) { for (i = 0; i <= j; ++i)
r(i,k) -= temp * r(i,j); r(i,k) -= temp * r(i,j);
} }
}
l = k; l = k;
} }
@ -50,12 +49,12 @@ void ei_covar(
/* in the strict lower triangle of r and in wa. */ /* in the strict lower triangle of r and in wa. */
for (j = 0; j < n; ++j) { for (j = 0; j < n; ++j) {
jj = ipvt[j]-1; jj = ipvt[j];
sing = j > l; sing = j > l;
for (i = 0; i <= j; ++i) { for (i = 0; i <= j; ++i) {
if (sing) if (sing)
r(i,j) = 0.; r(i,j) = 0.;
ii = ipvt[i]-1; ii = ipvt[i];
if (ii > jj) if (ii > jj)
r(ii,jj) = r(i,j); r(ii,jj) = r(i,j);
if (ii < jj) if (ii < jj)

View File

@ -193,7 +193,6 @@ void testLmder()
// check covariance // check covariance
covfac = fnorm*fnorm/(m-n); covfac = fnorm*fnorm/(m-n);
ipvt.cwise()+=1; // covar() expects the fortran convention (as qrfac provides)
ei_covar<double>(fjac, ipvt); ei_covar<double>(fjac, ipvt);
MatrixXd cov_ref(n,n); MatrixXd cov_ref(n,n);
@ -567,7 +566,6 @@ void testLmdif()
// check covariance // check covariance
covfac = fnorm*fnorm/(m-n); covfac = fnorm*fnorm/(m-n);
ipvt.cwise()+=1; // covar() expects the fortran convention (as qrfac provides)
ei_covar<double>(fjac, ipvt); ei_covar<double>(fjac, ipvt);
MatrixXd cov_ref(n,n); MatrixXd cov_ref(n,n);