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.821
and I'd like to be able to do
julia> a[i]
Particles{Float64,2000}
0.995411 ± 1.29
My 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)])
end
This 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
Hi @baggepinnen ,
For some Soss work, I have something like (simplified example)
and I'd like to be able to do
My current approach is
This works fine, but maybe I have 2, 3, or 4 indices instead of just one. And for
nindices we might have some particles and someInts, 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