Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ block_matrix_sqrt()

template<typename WRootMat >
void stan::math::internal::block_matrix_sqrt ( WRootMat &  W_root,
const Eigen::SparseMatrix< double > &  W,
const Eigen::Index  block_size 
)
inline

Returns the principal square root of a symmetric positive semi-definite block diagonal matrix.

Each block is symmetrised and decomposed with a symmetric eigensolver. Eigenvalues that are negative only at rounding level, as the zero eigenvalues of a rank-deficient block are (for example the negative Hessian of a likelihood with more latent variables than observations), are clamped to zero. An eigenvalue below -block_size * epsilon * max(|eigenvalues|) means the block is not positive semi-definite.

Template Parameters
WRootMatA type inheriting from Eigen::EigenBase.
Parameters
W_rootThe output matrix to store the square root.
WThe input block diagonal matrix.
block_sizeThe size of each block in the block diagonal matrix.
Exceptions
std::domain_errorif a block has non-finite entries or is not positive semi-definite.

Definition at line 242 of file laplace_marginal_density_estimator.hpp.