You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lndet_LU_dstry.cc 541B

12345678910111213141516171819202122232425262728293031
  1. #include "ABACUS.h"
  2. using namespace std;
  3. complex<DP> ABACUS::lndet_LU_dstry (SQMat_DP& a)
  4. {
  5. // Returns the ln of determinant of matrix a, through LU decomposition
  6. // Does not preserve a, unlike lndet_LU
  7. Vect_INT indx(a.size());
  8. DP d;
  9. complex<DP> logdet = 0.0;
  10. try {
  11. ABACUS::ludcmp (a, indx, d);
  12. logdet = log(complex<DP>(d));
  13. for (int j = 0; j < a.size(); j++) {
  14. logdet += log(complex<DP>(a[j][j]));
  15. }
  16. }
  17. catch (Divide_by_zero) {
  18. logdet = log(-1.0); // reset to nan
  19. }
  20. return(logdet);
  21. }