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)
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 inT1is used, where it is 0,T2These can be treated as two functions, or they could be both be called
whereand be overloads (this is what numpy does)