What is the correct way to update the contents of an immutable composite 
type, when those contents are themselves composite types?

For example, suppose I have

immutable X
p::PDMat
q::PDMat
end

x = X(PDMat(eye(10)),PDMat(eye(15)))

What is the best way to do in-place updates of x.p and x.q?  Since a PDMat 
contains a matrix and its Cholesky factorization, I've been doing something 
like this:
x.p.mat[:,:] = [new matrix that is the same size as x.p]
x.p.chol.UL[:] = [chol() called on the above matrix]

However, this seems like it can't possibly be the smartest thing to do. 
 Ideally I'd just have:
x.p = PDMat([new matrix])

but since the type X is immutable, that's not allowed.

Any suggestions? 

Thanks.

-Thom

Reply via email to