add is_even and is_odd here and to Stan
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 839
- Forks
- 220
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 14
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing Stan Math function implementations and the Stan language documentation entry points. Add is_even and is_odd for scalars and array inputs, then verify that each returns same-shaped 0/1 results and that both functions are documented and available in Stan.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend, documentation
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100