Re: [R] triangular matrices input/output

2012-05-16 Thread Rui Barradas
Hello, I needed this once. upper.diag <- function(x, byrow=FALSE){ m <- sqrt(1 + 8*length(x)) if(abs(m - floor(m)) < .Machine$double.eps^0.5) m <- (m - 1)/2 else{ warning("length of 'x' is not a triangular number.") m <- flo

Re: [R] triangular matrices input/output

2012-05-16 Thread R. Michael Weylandt
gt; From: michael.weyla...@gmail.com > > Date: Wed, 16 May 2012 19:41:36 -0400 > > Subject: Re: [R] triangular matrices input/output > > To: caspe...@hotmail.co.uk > > CC: r-help@r-project.org > > > > The Matrix package provides good support for many special sorts of

Re: [R] triangular matrices input/output

2012-05-16 Thread R. Michael Weylandt
The Matrix package provides good support for many special sorts of matrices, but here it looks like you probably don't need that additional machinery for such small case: makeUpper <- function(vec, diag = FALSE){ n <- (-1 + sqrt(1 + 8*length(vec)))/2 stopifnot(isTRUE(all.equal(n, as.intege

[R] triangular matrices input/output

2012-05-16 Thread casperyc
Hi, Is there any package that deals with triangular matrices? Say ways of inputting an upper (lower) triangular matrix? Or convert a vector of length 6 to an upper (lower) triangular matrix (by row/column)? Thanks! - ## PhD candidate in Statistics Big R Fan Big LEGO Fan