Skip to main content

remainder

Function remainder 

Source
pub fn remainder<F: Float>(
    a: impl IntoArray<F>,
    b: impl IntoArray<F>,
) -> Array<F>
Expand description

Equivalent of np.remainder(a, b) / np.mod(a, b): the remainder has the sign of the divisor (Python %).

mod is a Rust keyword, so there is no np::mod_ alias; use remainder.

use rustnum as np;
let r = np::remainder(np::array![-7.0, 7.0, 7.0], np::array![3.0, -3.0, 3.0]);
assert_eq!(r.to_vec(), [2.0, -2.0, 1.0]);