GURLS_EXPORT void cholesky(const gMat2D<float>& A, gMat2D<float>& L, bool upper){ typedef float T; L = A; int LDA = A.rows(); int n = A.cols(); char UPLO = upper? 'U' : 'L'; int info; spotrf_(&UPLO,&n, L.getData(),&LDA,&info); // This is required because we adopted a column major order to store the // data into matrices gMat2D<T> tmp(L.rows(), L.cols()); if (!upper){ L.uppertriangular(tmp); } else { L.lowertriangular(tmp); } tmp.transpose(L); }