Hello, I'm attempting to access a specific number of sub diagonals in a MATRIX and have been accustomed to using spdiags in MATLAB or Octave. I've got a solution pieced together using for loops and it works though isn't vectorized and liable to run very slow for large matrices.
As an example: A = 1 2 3 4 5 9 8 7 6 5 4 5 6 7 8 5 4 3 2 1 8 7 6 0 1 The subdiagonals are: 9,5,3,0 4,4,6 5,7 and 8, I know about lower.tri and can fetch the data in a resulting vector which ,in this case, would be: 9,4,5,8,5,4,7,3,6,0 though I would have to manipulate this some more to extract the other diagonals (imagine this being done for say a 1000 x 1000 matrix). I looked at CRAN and didn't see anything corresponding to spdiags. The closest package appeared to be the one relating to sparse matrices and band symmetry. Would you have any suggestions about 1) how to emulate spdiags or 2) working with the lower.tri returned-data and extracting the remaining diags efficiently. I can live with what I have but imagine that there is something more direct. Thanks [[alternative HTML version deleted]] ______________________________________________ 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.