-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
Hi @baggepinnen ,
For some Soss work, I have something like (simplified example)
julia> a = [Particles(), Particles()+1, Particles()+2]
3-element Array{Particles{Float64,2000},1}:
-5.33e-18 ± 1.0
1.0 ± 1.0
2.0 ± 1.0
julia> i = Particles(DiscreteUniform(1,3))
Particles{Int64,2000}
1.984 ± 0.821and I'd like to be able to do
julia> a[i]
Particles{Float64,2000}
0.995411 ± 1.29My current approach is
function Base.getindex(a::AbstractArray{P}, i::Particles) where P <: AbstractParticles
return Particles([a[i.particles[n]][n] for n in eachindex(i.particles)])
endThis works fine, but maybe I have 2, 3, or 4 indices instead of just one. And for n indices we might have some particles and some Ints, with 2^n possibilities.
Do you have a better way to set up this kind of dispatch? Ideally this would be in MCM, but I'm not sure how to even approach the general case
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels