stan-dev / stan-dev/math

Add `where`/`select` functions

Open
#3,253 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

new function
Dominant language
C++
Stars
839
Forks
220
Avg merge
2d 4h
Merged PRs (30d)
14

Description

Another part of https://github.com/stan-dev/stan/issues/3300#issuecomment-3188755711

Two useful functions:

  • select(ints, T) takes in a container container of integers in {0, 1} and a same-sized other container and returns a new container with those elements picked out (size is sum(first arg))
  • where(ints, T1, T2) takes in two containers and essentially does an element wise version of the ternary operator. Where ints is 1, the corresponding index in T1 is used, where it is 0, T2

These can be treated as two functions, or they could be both be called where and be overloads (this is what numpy does)

Contributor guide

Open the contributing guide

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 with the linked Stan issue comment and the two proposed operations in this issue. Determine whether select and where should be separate functions or overloads, then verify that the implementation supports the stated integer-mask and container-selection behavior across the relevant container types.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.