>>>>> "TL" == Thomas Lumley <tlum...@u.washington.edu> >>>>> on Fri, 20 Feb 2009 05:49:10 -0800 (PST) writes:
TL> On Fri, 20 Feb 2009, David Winsemius wrote: >> If you can tolerate the subdiagonal and superdiagonal zero elements being >> populated, then perhaps this is useful. If there is a subset function as you >> suggest, then perhaps further reduction would be feasible from this as a >> starting point. At least it would reduce the size from 10^5 x 10^5 to 10^5 x 3: >> >> library(Matrix) >> xxx <- data.frame(x1 =1:5, y1=c(0,6,0,7,0) ) >> M= Matrix(0,5,5) >> M[row(M) == col(M)] <- xxx$x1 >> M[row(M)-1 == col(M)] <- xxx$y1[1:(length(xxx$y1)-1)] >> M[row(M) == col(M)-1] <- xxx$y1[1:(length(xxx$y1)-1)] TL> That provides the right structure, but row(M) and col(M) are dense matrices with 10^10 elements, so it still uses too much memory. Yes, definitely, thank you, David, anyway. I'll work out a nice solution, (but am currently busy with something else, so will not be within the next hour). For a future version of Matrix, I'd really like a nice user interface, i.e., function, for constructing band matrices; this has been on my TODO list, at least mentally, for quite a while, and as I had never gotten close to use case, never gained enough priority. Maybe I can get some suggestions now on desired functionality of such a function, bandMatrix(.) say ? It probably should have an option for specifying symmetric vs. "general" band matrices, something that the "corresponding" Matlab function [ spdiags() ] does not. Martin Maechler, ETH Zurich TL> -thomas TL> Thomas Lumley Assoc. Professor, Biostatistics TL> tlum...@u.washington.edu University of Washington, Seattle TL> ______________________________________________ TL> R-help@r-project.org mailing list TL> https://stat.ethz.ch/mailman/listinfo/r-help TL> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html TL> and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.