Skip to content
Back to formatted view

Raw Message

Message-ID: <AD1E24EF37CF48E08C45E94B125018F3@Gandalf>
Date: 2011-10-23T07:00:07Z
From: Daniel Nordlund
Subject: symmetric matrix multiplication
In-Reply-To: <1319348682073-3929739.post@n4.nabble.com>

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of statfan
> Sent: Saturday, October 22, 2011 10:45 PM
> To: r-help at r-project.org
> Subject: [R] symmetric matrix multiplication
> 
> 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(abs(C - t(C))))
> [1] 3.552714e-15
> 
> Any help on the matter would be very much appreciated.
> 
> 

Welcome to the world of floating-point calculation on finite precision computers.  You need to read R FAQ 7.31.  Your maximum difference is for all intents and purposes equal to zero.  

Hope this is helpful,

Dan

Daniel Nordlund
Bothell, WA USA