diff --git a/arrayfire/arith.py b/arrayfire/arith.py index 70c2e5471..15b869898 100644 --- a/arrayfire/arith.py +++ b/arrayfire/arith.py @@ -188,6 +188,30 @@ def rem(lhs, rhs): """ return _arith_binary_func(lhs, rhs, backend.get().af_rem) +def mod(lhs, rhs): + """ + Find the modulus. + + Parameters + ---------- + lhs : af.Array or scalar + Multi dimensional arrayfire array or a scalar number. + + rhs : af.Array or scalar + Multi dimensional arrayfire array or a scalar number. + + Returns + -------- + out : af.Array + Contains the moduli after dividing each value of lhs` with those in `rhs`. + + Note + ------- + - Atleast one of `lhs` and `rhs` needs to be af.Array. + - If `lhs` and `rhs` are both af.Array, they must be of same size. + """ + return _arith_binary_func(lhs, rhs, backend.get().af_mod) + def abs(a): """ Find the absolute values. diff --git a/arrayfire/tests/simple/arith.py b/arrayfire/tests/simple/arith.py index 84c291aec..96217f3fb 100644 --- a/arrayfire/tests/simple/arith.py +++ b/arrayfire/tests/simple/arith.py @@ -139,6 +139,7 @@ def simple_arith(verbose = False): display_func(af.clamp(a, 0, b)) display_func(af.clamp(a, b, 1)) + display_func(af.mod(a,b)) display_func(af.rem(a,b)) a = af.randu(3,3) - 0.5