Broadcast update multiple vectors at once

weymouth
Sat, 27 May 2023 16:45:54 +0000
General Usage

Simple question. I have a few vectors which hold the states of a list of particles. I update these with broadcast (which is nice since the vectors are on the GPU). For example:

    position⁰ .= position
    position .+= integrate.(position⁰, ...)

I need to check the states and potentially reset them, but I don’t know how to reset them all at the same time. I can do this

position .= enforce_bounds(position,...)

But now I need to set position⁰ = position only for the positions that were reset. Is there something like:

(position⁰,position) .= enforce_bounds(position,...)

that will let me conditionally reset them both at once?

In this example, I could do the check in the other order, but in my code there are a bunch of other states and conditions so I’m looking for a general way to do this.

8 posts - 2 participants