My function performs cholesky decomposition on a matrix V many many times, so I want to create a field Vchol in my model struct m to avoid repeated allocation. So my type looks like
struct m{T <:Real}
...
V::Matrix{T}
Vchol::CholeskyPivoted{T}
...
end
Now, inside my function, if I do
function f(m:m{T})
m.Vchol = cholesky(m.V)
end
then I would get the error immutable struct of type m cannot be changed. Sure.
So my question is, is there any workaround? Thank you.