log determinant of a matrix

Issue #386 resolved
Esmail Abdul Fattah created an issue

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)

  1. Klaus Iglberger

    Hi Esmail!

    Thanks for raising the question. Unfortunately Blaze doesn’t (yet) provide a det() or llh() 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 the L matrix?

    Best regards,

    Klaus!

  2. Esmail Abdul Fattah reporter

    It works fine in the function I wrote. blaze::det() didn’t work well with high dimension matrices.

    Thanks for your reply.

  3. Klaus Iglberger

    Hi Esmail!

    Glad I could help. I hope that your question has been answered.

    Best regards,

    Klaus!

  4. Log in to comment