search for: diaga

Displaying 3 results from an estimated 3 matches for "diaga".

Did you mean: diag
2015 May 05
3
Why is the diag function so slow (for extraction)?
Looks like the c(x)[...] bit used to be as.matrix(x)[...]. Not sure why the change was made many years ago, but this was before names were handled explicitly. It would definitely be better to not force the duplicate, at least in the case where we are sure c() and [ would not dispatch. Best, luke On Mon, 4 May 2015, peter dalgaard wrote: > >> On 04 May 2015, at 19:59 , franknarf
2015 May 07
0
Why is the diag function so slow (for extraction)?
...1L && nargs() == 1L) { n <- as.integer(x) x <- 1 } else n <- length(x) if (!missing(nrow)) n <- nrow if (missing(ncol)) ncol <- n } nc <- 10 set.seed(1) m <- matrix(sample(letters,nc^2,replace=TRUE), ncol = nc) runoff <- microbenchmark( diaga = diag(m), diagb = diag2(m) ) Regards, Steve Bronder Website: stevebronder.com Phone: 412-719-1282 Email: sbronder at stevebronder.com On Tue, May 5, 2015 at 9:46 AM, <luke-tierney at uiowa.edu> wrote: > Looks like the c(x)[...] bit used to be as.matrix(x)[...]. Not sure > why th...
2013 Oct 11
3
matrix values linked to vector index
Hi, In the example you showed: m1<- matrix(0,length(vec),max(vec)) 1*!upper.tri(m1) #or ?m1[!upper.tri(m1)] <-? rep(rep(1,length(vec)),vec) #But, in a case like below, perhaps: vec1<- c(3,4,5) ?m2<- matrix(0,length(vec1),max(vec1)) ?indx <- cbind(rep(seq_along(vec1),vec1),unlist(tapply(vec1,list(vec1),FUN=seq),use.names=FALSE)) m2[indx]<- 1 ?m2 #???? [,1] [,2] [,3] [,4] [,5]