Displaying 1 result from an estimated 1 matches for "csdim".
Did you mean:
claim
2005 Sep 01
1
More block diagonal matrix construction code
...verweight" to me (that's an American stock analyst's
term, btw), so I came up with a slightly cleaner version (with help from
Andy):
bdiag<-function(...){
mlist<-list(...)
## handle case in which list of matrices is given
if(length(mlist)==1)mlist<-unlist(mlist,rec=FALSE)
csdim<-rbind(c(0,0),apply(sapply(mlist,dim),1,cumsum ))
ret<-array(0,dim=csdim[length(mlist)+1,])
add1<-matrix(rep(1:0,2),nc=2)
for(i in seq(along=mlist)){
indx<-apply(csdim[i:(i+1),]+add1,2,function(x)x[1]:x[2])
## non-square matrix
if(is.null(dim(indx)))ret[indx[[1]],indx[[...