Skip to content
Prev 75951 / 398502 Next

diagonal matrices

On Sat, 20 Aug 2005, Afshartous, David wrote:

            
It is probably best to pre-create a matrix and fill in the blocks.  As in

V <- matrix(0, N, N)
# let n be a vector of what you called n.i
n0 <- c(0, cumsum(n))
for(i in 1:J) {
    ind <- (n0[i]+1):n0[i+1]
    V[ind, ind] <- V.i
}
Please set that as your reply address to ease the lot of your helpers.