Let the Cholesky decomposition fail gracefully
This commit is contained in:
parent
b54a8a92e7
commit
992b41108f
1 changed files with 14 additions and 5 deletions
|
@ -490,13 +490,22 @@ pub fn realize_gram(
|
|||
if state.loss < tol { break; }
|
||||
|
||||
// compute the Newton step
|
||||
/* TO DO */
|
||||
/*
|
||||
we need to either handle or eliminate the case where the minimum
|
||||
eigenvalue of the Hessian is zero, so the regularized Hessian is
|
||||
singular. right now, this causes the Cholesky decomposition to return
|
||||
`None`, leading to a panic when we unrap
|
||||
we should change our regularization to ensure that the Hessian is
|
||||
is positive-definite, rather than just positive-semidefinite. ideally,
|
||||
that would guarantee the success of the Cholesky decomposition---
|
||||
although we'd still need the error-handling routine in case of
|
||||
numerical hiccups
|
||||
*/
|
||||
let base_step_stacked = hess.clone().cholesky().unwrap().solve(&neg_grad_stacked);
|
||||
let hess_cholesky = match hess.clone().cholesky() {
|
||||
Some(cholesky) => cholesky,
|
||||
None => return RealizationResult {
|
||||
result: Err("Cholesky decomposition failed".to_string()),
|
||||
history
|
||||
}
|
||||
};
|
||||
let base_step_stacked = hess_cholesky.solve(&neg_grad_stacked);
|
||||
let base_step = base_step_stacked.reshape_generic(Dyn(element_dim), Dyn(assembly_dim));
|
||||
history.base_step.push(base_step.clone());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue