Re: [R] symmetric matrix on both diagonals

2012-04-21 Thread David Winsemius
On Apr 21, 2012, at 1:13 AM, Petr Savicky wrote: On Fri, Apr 20, 2012 at 10:52:47AM -0400, David Winsemius wrote: On Apr 20, 2012, at 7:05 AM, Petr Savicky wrote: On Fri, Apr 20, 2012 at 03:03:40AM -0700, juliane0212 wrote: I'm having some problems computing a matrix being symmetric on

Re: [R] symmetric matrix on both diagonals

2012-04-20 Thread Petr Savicky
On Fri, Apr 20, 2012 at 10:52:47AM -0400, David Winsemius wrote: > > On Apr 20, 2012, at 7:05 AM, Petr Savicky wrote: > > >On Fri, Apr 20, 2012 at 03:03:40AM -0700, juliane0212 wrote: > >> > >>I'm having some problems computing a matrix being symmetric on both > >>diagonals. > >> > >>Does anyone

Re: [R] symmetric matrix on both diagonals

2012-04-20 Thread David Winsemius
On Apr 20, 2012, at 7:05 AM, Petr Savicky wrote: On Fri, Apr 20, 2012 at 03:03:40AM -0700, juliane0212 wrote: I'm having some problems computing a matrix being symmetric on both diagonals. Does anyone know a way to get from this matrix M <- matrix(c(1,0,0,0,2,7,0,0,3,4,0,0,6,0,0,0), ncol=

Re: [R] symmetric matrix on both diagonals

2012-04-20 Thread juliane0212
That is exactly what I was looking for. Thank you -- View this message in context: http://r.789695.n4.nabble.com/symmetric-matrix-on-both-diagonals-tp4573418p4573594.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.o

Re: [R] symmetric matrix on both diagonals

2012-04-20 Thread Petr Savicky
On Fri, Apr 20, 2012 at 03:03:40AM -0700, juliane0212 wrote: > > I'm having some problems computing a matrix being symmetric on both > diagonals. > > Does anyone know a way to get from this matrix > > > M <- matrix(c(1,0,0,0,2,7,0,0,3,4,0,0,6,0,0,0), ncol=4) > > to this one >

[R] symmetric matrix on both diagonals

2012-04-20 Thread juliane0212
I'm having some problems computing a matrix being symmetric on both diagonals. Does anyone know a way to get from this matrix M <- matrix(c(1,0,0,0,2,7,0,0,3,4,0,0,6,0,0,0), ncol=4) to this one M_final <- matrix(c(1,2,3,6,2,7,4,3,3,4,7,2,6,3,2,1)

Re: [R] symmetric matrix multiplication

2011-10-23 Thread statfan
Thank you Dan and Ted for these helpful comments. I will implement this simple force symmetry code you suggested and make sure I familiarize with this floating-point calculation problem so I can recognize such issues in the future. -- View this message in context: http://r.789695.n4.nabble.com/sy

Re: [R] symmetric matrix multiplication

2011-10-23 Thread Ted Harding
On 23-Oct-11 07:00:07, Daniel Nordlund wrote: >> -Original Message- >> From: r-help-boun...@r-project.org >> [mailto:r-help-boun...@r-project.org] >> On Behalf Of statfan >> Sent: Saturday, October 22, 2011 10:45 PM >> To: r-help@r-project.

Re: [R] symmetric matrix multiplication

2011-10-23 Thread Daniel Nordlund
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of statfan > Sent: Saturday, October 22, 2011 10:45 PM > To: r-help@r-project.org > Subject: [R] symmetric matrix multiplication > > I have a symmetric

[R] symmetric matrix multiplication

2011-10-22 Thread statfan
I have a symmetric matrix B (17x17), and a (17x17) square matrix A. If do the following matrix multiplication I SHOULD get a symmetric matrix, however i don't. The computation required is: C = t(A)%*%B%*%A here are some checks for symmetry > (max(abs(B - t(B [1] 0 > C = t(A)%*%B%*%A > (max(

Re: [R] Symmetric Matrix classes

2010-01-19 Thread Gad Abraham
On Wed, Jan 20, 2010 at 8:18 AM, Douglas Bates wrote: > On Tue, Jan 19, 2010 at 9:26 AM, Martin Maechler > wrote: >> Scanning for 'Matrix' in old R-help e-mail, I found >> >>> "GA" == Gad Abraham >>>     on Fri, 27 Nov 2009 13:45:00 +1100 writes: >> >>    GA> Hi, >>    GA> I'd like to st

Re: [R] Symmetric Matrix classes

2010-01-19 Thread Gad Abraham
On Wed, Jan 20, 2010 at 2:26 AM, Martin Maechler wrote: > Scanning for 'Matrix' in old R-help e-mail, I found > >> "GA" == Gad Abraham >>     on Fri, 27 Nov 2009 13:45:00 +1100 writes: > >    GA> Hi, >    GA> I'd like to store large covariance matrices using Matrix classes. > >    GA> dsy

Re: [R] Symmetric Matrix classes

2010-01-19 Thread Douglas Bates
On Tue, Jan 19, 2010 at 9:26 AM, Martin Maechler wrote: > Scanning for 'Matrix' in old R-help e-mail, I found > >> "GA" == Gad Abraham >>     on Fri, 27 Nov 2009 13:45:00 +1100 writes: > >    GA> Hi, >    GA> I'd like to store large covariance matrices using Matrix classes. > >    GA> dsy

Re: [R] Symmetric Matrix classes

2010-01-19 Thread Martin Maechler
Scanning for 'Matrix' in old R-help e-mail, I found > "GA" == Gad Abraham > on Fri, 27 Nov 2009 13:45:00 +1100 writes: GA> Hi, GA> I'd like to store large covariance matrices using Matrix classes. GA> dsyMatrix seems like the right one, but I want to specify just the

Re: [R] Symmetric Matrix classes

2009-11-26 Thread Gad Abraham
On Fri, Nov 27, 2009 at 2:22 PM, David Winsemius wrote: > > On Nov 26, 2009, at 9:45 PM, Gad Abraham wrote: > >> Hi, >> >> I'd like to store large covariance matrices using Matrix classes. >> >> dsyMatrix seems like the right one, but I want to specify just the >> upper/lower triangle and diagonal

Re: [R] Symmetric Matrix classes

2009-11-26 Thread David Winsemius
On Nov 26, 2009, at 11:00 PM, Gad Abraham wrote: On Fri, Nov 27, 2009 at 2:22 PM, David Winsemius > wrote: On Nov 26, 2009, at 9:45 PM, Gad Abraham wrote: Hi, I'd like to store large covariance matrices using Matrix classes. dsyMatrix seems like the right one, but I want to specify just th

Re: [R] Symmetric Matrix classes

2009-11-26 Thread David Winsemius
On Nov 26, 2009, at 9:45 PM, Gad Abraham wrote: Hi, I'd like to store large covariance matrices using Matrix classes. dsyMatrix seems like the right one, but I want to specify just the upper/lower triangle and diagonal and not have to instantiate a huge n^2 vector just for the sake of having

[R] Symmetric Matrix classes

2009-11-26 Thread Gad Abraham
Hi, I'd like to store large covariance matrices using Matrix classes. dsyMatrix seems like the right one, but I want to specify just the upper/lower triangle and diagonal and not have to instantiate a huge n^2 vector just for the sake of having half of it ignored: Dumb example: M <- new("dsyMatr

Re: [R] Symmetric matrix

2008-09-22 Thread Martin Maechler
> "DR" == Dimitris Rizopoulos <[EMAIL PROTECTED]> > on Sun, 21 Sep 2008 19:58:44 +0200 writes: DR> try the following DR> a <- matrix(rnorm(36), 6) DR> ind <- lower.tri(a) DR> a[ind] <- t(a)[ind] DR> a Yes, indeed, it needs the t(.) trick. Note that 'Matrix' packag

Re: [R] Symmetric matrix

2008-09-21 Thread Peter Dalgaard
Jorge Ivan Velez wrote: Dear Megh, Try this: a = matrix(rnorm(36), 6) a[upper.tri(a)]<-a[lower.tri(a)] a HTH, If you look carefully, you'll see that it doesn't work! Dimitris had the better idea. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept.

Re: [R] Symmetric matrix

2008-09-21 Thread Dimitris Rizopoulos
try the following a <- matrix(rnorm(36), 6) ind <- lower.tri(a) a[ind] <- t(a)[ind] a I hope it helps. Best, Dimitris Megh Dal wrote: I have following matrix : a = matrix(rnorm(36), 6) Now I want to replace the lower-triangular elements with it's upper-triangular elements. That is I want

Re: [R] Symmetric matrix

2008-09-21 Thread Jorge Ivan Velez
Dear Megh, Try this: a = matrix(rnorm(36), 6) a[upper.tri(a)]<-a[lower.tri(a)] a HTH, Jorge On Sun, Sep 21, 2008 at 1:47 PM, Megh Dal <[EMAIL PROTECTED]> wrote: > I have following matrix : > > a = matrix(rnorm(36), 6) > > Now I want to replace the lower-triangular elements with it's > upper

[R] Symmetric matrix

2008-09-21 Thread Megh Dal
I have following matrix : a = matrix(rnorm(36), 6) Now I want to replace the lower-triangular elements with it's upper-triangular elements. That is I want to make a symmetric matrix from a. I have tried with lower.tri() and upper.tri() function, but got desired result. Can anyone please tell m