Declared as immutable, PDMat is not supposed to be updated. However, I understand that there are cases where efficiency is important and you want to do the inplace updating anyways. For such situation, I think you can just directly modify p.mat and p.chol, and wrap these operations into a function.
Dahua On Monday, May 26, 2014 11:18:33 AM UTC-5, Thomas Covert wrote: > > 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 > >
