stan-dev / stan-dev/stanc3

Delegate ternary operator to Math `if_else()`

Open
#1,086 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
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:

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.