mod#

swordfish.function.mod()#

Mod means modulus. It returns the element-by-element remainder of X divided by Y. When Y is a positive integer, the modulus is always non-negative, e.g., -10 % 3 is 2. When Y is a negative integer, the modulus is always non-positive, e.g., -10 % -3 is -1. mod is often used to group data. For example, [5,4,3,3,5,6]%3 is [2,1,0,0,2,0]; data can thereby be divided into three groups.

Parameters:
  • X (Constant) – A scalar/pair/vector/matrix.

  • Y (Constant) – A scalar/pair/vector/matrix. If X or Y is a pair/vector/matrix, the other is a scalar or a pair/vector/matrix of the same size.