Add coefficient-wise modulus operator (%) for Array
Summary
- Add
scalar_modulus_opfunctor inBinaryFunctors.h - Add
operator%for array-array and array-scalar forms inArrayCwiseBinaryOps.inc - Integer types only (enforced by compiler since
%is undefined for floats) - No SIMD vectorization (integer modulus has no standard packet op)
Example usage:
Array3i a(7, 8, 9), b(2, 3, 4);
Array3i c = a % b; // [1, 2, 1]
Array3i d = a % 2; // [1, 0, 1]
Test plan
- Array % Array works correctly
- Array % scalar works correctly
- 2D ArrayXXi % scalar works correctly
-
Compound expressions
(a + b) % cwork correctly -
Existing
array_cwisetest suite passes
Closes #2837