Delegate ternary operator to Math `if_else()`
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 160
- Forks
- 59
- Avg merge
- 21h 45m
- Merged PRs (30d)
- 26
Description
At the moment the ternary operator in stan directly transpiles to the C++ ternary operator. However, there have been requests in the past for a vectorised ternary operator:
- https://discourse.mc-stan.org/t/ternary-operator-for-vectors/23149
- https://discourse.mc-stan.org/t/elementwise-ternary-operator/1598
I'm currently working on a ternary vectorisation framework which could be used to vectorise the if_else() function in the Math library: https://github.com/stan-dev/math/issues/2638
If stanc3 were to transpile the ternary operator to if_else, then Stan would automatically support vectorised ternary statements once the if_else function is vectorised.
Contributor guide
No contributing guide indexed for this repository
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 tracing how stanc3 transpiles the ternary operator and review the linked Math issue 2638 for the planned vectorised if_else interface. The work is done when ternary expressions are emitted through if_else and coverage verifies the generated behavior, including the intended vectorisation path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, ocaml
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100