Skip to content

Add where/select functions #3253

@WardBrian

Description

@WardBrian

Another part of stan-dev/stan#3300 (comment)

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)

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