I would rather write is_odd(n) than n % 2 == 1 or more obscure n % 2.. Same for is_even(n) vs. n % 2 == 0 or more obscurely !(n % 2).
This is about the simplest pair of functions to add because they don't need overloads for different scalar types and don't have derivatives.
It would be great if they could be vectorized over arrays of any shape to return an array of the same shape with 0/1 values based on whether each element is odd or not.
This should then be added to the Stan language and doc.
I would rather write
is_odd(n)thann % 2 == 1or more obscuren % 2.. Same foris_even(n)vs.n % 2 == 0or more obscurely!(n % 2).This is about the simplest pair of functions to add because they don't need overloads for different scalar types and don't have derivatives.
It would be great if they could be vectorized over arrays of any shape to return an array of the same shape with 0/1 values based on whether each element is odd or not.
This should then be added to the Stan language and doc.