# Capability to offer a vector to value and free slots in MXMatrix objects

2 posts / 0 new
Offline
Joined: 07/31/2009 - 14:25
Capability to offer a vector to value and free slots in MXMatrix objects

This works

Chol    = mxMatrix(type="Full", 2,2, free=c(TRUE,TRUE,FALSE,TRUE), values=c(1,.2,0,1))


But this fails

Chol@free=c(TRUE,FALSE,FALSE,TRUE)
Chol@values=c(1,0,0,1)


It would be nice, given that we can create the free and values slots with vectors, if we could also update them iwth vectors, using the pre-existing nrow and ncol of the MxMatrix to do this:

vec2MatFormxMatrix <- function(oldMat, newVec) {
newMat = matrix(data=newVec, nrow=nrow(oldMat), ncol=ncol(oldMat) )
return(newMat)
}

newVec =c(TRUE,FALSE,FALSE,TRUE)
if(is.vector(newVec)){
newVec = vec2MatFormxMatrix(Chol, newVec)
}
Chol@free=newVec

Offline
Joined: 07/31/2009 - 15:24
This is a not a bug. You can

This is a not a bug. You can think of Chol@free and Chol@values as two variables. The only way to perform the kind of substitution you are suggesting is to overload the "<-" operator. And the "<-" operator can only be overloaded for S4 object types. Chol@free and Chol@values are not S4 objects, and we don't want to make them S4 object types because then they can't be used as argument to any function in R that expects plain matrices.