Advanced usage

Several non-exported functions that may facilitate working with structures that contain unertain 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_objectFunction
mean_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.

source
MonteCarloMeasurements.replace_particlesFunction
replace_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.

source
MonteCarloMeasurements.has_particlesFunction
has_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.

source
MonteCarloMeasurements.array_of_structsFunction
array_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])).

source