def _smw_logdet(s, A, AtA, BI, di, B_logdet):
 p = A.shape[0]
 ld = (p * np.log(s))
 qmat = (AtA / s)
 m = BI.shape[0]
 qmat[0:m, 0:m] += BI
 ix = np.arange(m, A.shape[1])
 qmat[(ix, ix)] += di
 if sparse.issparse(qmat):
  qmat = qmat.todense()
 (_, ld1) = np.linalg.slogdet(qmat)
 return ((B_logdet + ld) + ld1)

def _smw_logdet ( s , A , AtA , BI , di , B_logdet ) : p = A . shape [ 0 ] ld = ( p * np . log ( s ) ) qmat = ( AtA / s ) m = BI . shape [ 0 ] qmat [ 0 : m , 0 : m ] += BI ix = np . arange ( m , A . shape [ 1 ] ) qmat [ ( ix , ix ) ] += di if sparse . issparse ( qmat ) : qmat = qmat . todense ( ) ( _ , ld1 ) = np . linalg . slogdet ( qmat ) return ( ( B_logdet + ld ) + ld1 )
returns the log determinant of s*i + a*b*a .