pub fn zip_update2_into<D, A, OpD, OpA>(
dest: &mut StridedViewMut<'_, D>,
a: &StridedView<'_, A, OpA>,
f: impl Fn(D, A) -> D + Sync,
exec: Exec<'_>,
) -> Result<()>Expand description
Update in place from one input: dest[i] = f(OpD(dest[i]), OpA(a[i])).
§Errors
StridedError::ShapeMismatch for unequal shapes and
StridedError::NonInjectiveOutputLayout, both before any write.
§Examples
use strided_basic::{zip_update2_into, Exec, Identity, StridedArray};
let a = StridedArray::<f64>::from_fn_col_major(&[3], |i| i[0] as f64);
let mut d = StridedArray::<f64>::from_fn_col_major(&[3], |_| 10.0);
// d = 2 * a + 0.5 * d
zip_update2_into::<_, _, Identity, Identity>(
&mut d.view_mut(), &a.view(), |d, a| 2.0 * a + 0.5 * d, Exec::serial(),
)
.unwrap();
assert_eq!(d.get(&[2]), 9.0);