Currently, Spin and SpinMC are immutable, whereas many of the other composite types here are mutable, like Position and Magnetization, and BlochMatrix.
When using BlochSim to fit a signal model to data, one must create a new Spin for every candidate set of tissue parameters and then propagate that spin through the dynamics. The propagation part is low allocation, thanks to all the in-place operations. The Spin allocation becomes magnified when considering slice profile effects with multiple spins across a voxel.
Making Spin mutable could avoid that allocation.
Would there be any performance drawback?
Currently,
SpinandSpinMCare immutable, whereas many of the other composite types here are mutable, likePositionandMagnetization,andBlochMatrix.When using
BlochSimto fit a signal model to data, one must create a newSpinfor every candidate set of tissue parameters and then propagate that spin through the dynamics. The propagation part is low allocation, thanks to all the in-place operations. TheSpinallocation becomes magnified when considering slice profile effects with multiple spins across a voxel.Making
Spinmutable could avoid that allocation.Would there be any performance drawback?