From pbruneau at gmail.com  Sat Dec 20 22:06:57 2014
From: pbruneau at gmail.com (Pierrick Bruneau)
Date: Sat, 20 Dec 2014 22:06:57 +0100
Subject: [Rd] Unexplained difference between results of dppsv and dpotri
	LAPACK routines
Message-ID: <CAF_q7hVNBL6j3QUHeyUJ1wWSA6vS9RQQPB2s2-xV2msd4+291w@mail.gmail.com>

Dear R contributors,

Considering the following sample C code, that illustrates two possible
uses of a Cholesky decomp for inverting a matrix, equally valid at
least in theory:

SEXP test() {

int d = 2;
int info = 0;
double mat[4] = {2.5, 0.4, 0.4, 1.7};
double id[4] = {1.0, 0.0, 0.0, 1.0};
double lmat[3];
F77_CALL(dpotrf)("L", &d, mat, &d, &info);
lmat[0] = mat[0];
lmat[1] = mat[1];
lmat[2] = mat[3];
F77_CALL(dppsv)("L", &d, &d, lmat, id, &d, &info);
// id now contains L^(-T)
F77_CALL(dpotri)("L", &d, mat, &d, &info);
// mat contains mat^(-1)

Rprintf("%f\n", id[0] * id[0]);
// owing to that id is lower triangular
Rprintf("%f\n", mat[0]);

return(R_NilValue);

}

I expected both printed values to be identical, or almost so. But
issuing .Call("test") prints:
0.426571
0.415648

Difference is thus many degrees of magnitude above numerical
precision. What am I missing that explains it?

Thanks by advance for the kind answers,
Pierrick



[Rd] Unexplained difference between results of dppsv and dpotri LAPACK routines
Pierrick Bruneau