Skip to content

add is_even and is_odd here and to Stan #3349

Description

@bob-carpenter

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions