Advanced usage
Several non-exported functions that may facilitate working with structures that contain uncertain parameters (struct-of-arrays, SoA) exist. These are not to be considered part of the API and are subject to breakage at any time, but may nevertheless be of use in special situations.
MonteCarloMeasurements.mean_object — Functionmean_object(x)Returns an object similar to x, but where all internal instances of Particles are replaced with their mean. The generalization of this function is replace_particles.
MonteCarloMeasurements.replace_particles — Functionreplace_particles(x; condition=P->P isa AbstractParticles,replacer = P->vecindex(P, 1))This function recursively scans through the structure x, every time a field that matches condition is found, replacer is called on that field and the result is used instead of P. See function mean_object, which uses this function to replace all instances of Particles with their mean.
MonteCarloMeasurements.has_particles — Functionhas_particles(P)Determine whether or no the object P has some kind of particles inside it. This function examins fields of P recursively and looks inside arrays etc.
MonteCarloMeasurements.build_mutable_container — Functionbuild_mutable_container(P)Recursively visits all fields of P and replaces all instances of StaticParticles with Particles
MonteCarloMeasurements.build_container — Functionbuild_container(P)Recursively visits all fields of P and replaces all instances of AbstractParticles{T,N} with ::T
MonteCarloMeasurements.array_of_structs — Functionarray_of_structs(f, arg)Exectues f on each instance of arg represented by internal particles of arg. This is useful as a last resort if all other methods to propagate particles through f fails. The function returns an array (length = num. particles) of structs rather than particles, each struct is the result of f(replace_particles(arg, p->p[i])).