Function sprs::binop::csvec_binop

source ยท
pub fn csvec_binop<Lhs, Rhs, Res, I, F>(
    lhs: CsVecViewI<'_, Lhs, I>,
    rhs: CsVecViewI<'_, Rhs, I>,
    binop: F,
) -> Result<CsVecI<Res, I>, StructureError>
where Lhs: Zero, Rhs: Zero, F: Fn(&Lhs, &Rhs) -> Res, I: SpIndex,
Expand description

Binary operations for CsVec

This function iterates the non-zero locations of lhs and rhs and applies the function binop to the matching elements (defaulting to zero when e.g. only lhs has a non-zero at a given location).

The function thus has a correct behavior iff binop(0, 0) == 0.