Add coefficient-wise modulus operator (%) for Array

Summary

  • Add scalar_modulus_op functor in BinaryFunctors.h
  • Add operator% for array-array and array-scalar forms in ArrayCwiseBinaryOps.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) % c work correctly
  • Existing array_cwise test suite passes

Closes #2837

Merge request reports

Loading