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; }
|
if state.loss < tol { break; }
|
||||||
|
|
||||||
// compute the Newton step
|
// compute the Newton step
|
||||||
|
/* TO DO */
|
||||||
/*
|
/*
|
||||||
we need to either handle or eliminate the case where the minimum
|
we should change our regularization to ensure that the Hessian is
|
||||||
eigenvalue of the Hessian is zero, so the regularized Hessian is
|
is positive-definite, rather than just positive-semidefinite. ideally,
|
||||||
singular. right now, this causes the Cholesky decomposition to return
|
that would guarantee the success of the Cholesky decomposition---
|
||||||
`None`, leading to a panic when we unrap
|
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));
|
let base_step = base_step_stacked.reshape_generic(Dyn(element_dim), Dyn(assembly_dim));
|
||||||
history.base_step.push(base_step.clone());
|
history.base_step.push(base_step.clone());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue