Simplify normalization routine

We don't need to explicitly allocate scratch space.
This commit is contained in:
Aaron Fenyes 2025-02-03 18:17:32 -08:00
parent fa1e54f171
commit 544249ae26

View file

@ -381,23 +381,20 @@ impl Assembly {
match elt.column_index { match elt.column_index {
Some(column_index) => { Some(column_index) => {
// apply the deformation linearly // apply the deformation linearly
let rep_next = &*rep + motion_proj.column(column_index); *rep += motion_proj.column(column_index);
// project back onto the mass shell by contracting // project back onto the mass shell by contracting
// toward the last coordinate axis // toward the last coordinate axis
let q_sp = rep_next.fixed_rows::<3>(0).norm_squared(); let q_sp = rep.fixed_rows::<3>(0).norm_squared();
let half_q_lt = -2.0 * rep_next[3] * rep_next[4]; let half_q_lt = -2.0 * rep[3] * rep[4];
let half_q_lt_sq = half_q_lt * half_q_lt; let half_q_lt_sq = half_q_lt * half_q_lt;
let scaling = half_q_lt + (q_sp + half_q_lt_sq).sqrt(); let scaling = half_q_lt + (q_sp + half_q_lt_sq).sqrt();
rep.fixed_rows_mut::<4>(0).copy_from( rep.fixed_rows_mut::<4>(0).scale_mut(1.0 / scaling);
&(rep_next.fixed_rows::<4>(0) / scaling)
);
rep[4] = rep_next[4];
/* DEBUG */ /* DEBUG */
// report self-product before and after projection // report self-product before and after projection
console::log_1(&JsValue::from( console::log_1(&JsValue::from(
format!("Self-product of element representation\n After step: {}\n Scaling: {}\n After scaling: {}", rep_next.dot(&(&*Q * &rep_next)), scaling, rep.dot(&(&*Q * &*rep))) format!("After scaling by {}, self-product of element representation is {}", scaling, rep.dot(&(&*Q * &*rep)))
)); ));
}, },
None => { None => {