- edited description
log determinant of a matrix
Hi, getting the blaze::log(blaze::det(*)) of matrix A doesn’t work all the time, so I created my own function:
double log_det(sym_matrix &Q)
{
blaze::DynamicMatrix<double,blaze::rowMajor> L;
blaze::llh(Q,L);
double value = 0.0;
for(size_t i=0; i<L.rows();i++)
value += log(L(i,i));
value *= 2;
return value;
}
Is there a more efficient way to do this? I need to calculate the log det of matrix Ai for all i, such that Ai is a matrix where column i and row i are removed. Knowing that my matrix A is sparse.
Comments (5)
-
reporter -
Hi Esmail!
Thanks for raising the question. Unfortunately Blaze doesn’t (yet) provide a
det()
orllh()
function for sparse matrices. Therefore you have to take the detour via a dense matrix.You mention that “getting the log(det(*) of matrix A doesn’t work all the time“. Could you please elaborate on why you cannot use this approach within your
log_det()
function on theL
matrix?Best regards,
Klaus!
-
reporter It works fine in the function I wrote. blaze::det() didn’t work well with high dimension matrices.
Thanks for your reply.
-
Hi Esmail!
Glad I could help. I hope that your question has been answered.
Best regards,
Klaus!
-
- changed status to resolved
- Log in to comment