def _determinant(self):
     logging.warn(
         "Using (possibly slow) default implementation of determinant."
         "  Requires conversion to a dense matrix and O(N^3) operations.")
     if self._can_use_cholesky():
         return math_ops.exp(self.log_abs_determinant())
     return linalg_ops.matrix_determinant(self.to_dense())
 def _determinant(self):
     if all(op.is_positive_definite for op in self._diagonal_operators):
         return math_ops.exp(self._log_abs_determinant())
     result = self._diagonal_operators[0].determinant()
     for op in self._diagonal_operators[1:]:
         result *= op.determinant()
     return result
Esempio n. 3
0
 def _determinant(self):
     if self.is_positive_definite:
         return math_ops.exp(self.log_abs_determinant())
     # The matrix determinant lemma gives
     # https://en.wikipedia.org/wiki/Matrix_determinant_lemma
     #   det(L + UDV^H) = det(D^{-1} + V^H L^{-1} U) det(D) det(L)
     #                  = det(C) det(D) det(L)
     # where C is sometimes known as the capacitance matrix,
     #   C := D^{-1} + V^H L^{-1} U
     det_c = _linalg.det(self._make_capacitance())
     det_d = self.diag_operator.determinant()
     det_l = self.base_operator.determinant()
     return det_c * det_d * det_l