Return-Path: Delivered-To: apmail-incubator-hama-commits-archive@minotaur.apache.org Received: (qmail 5831 invoked from network); 10 Jul 2009 03:38:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Jul 2009 03:38:36 -0000 Received: (qmail 1776 invoked by uid 500); 10 Jul 2009 03:38:46 -0000 Delivered-To: apmail-incubator-hama-commits-archive@incubator.apache.org Received: (qmail 1748 invoked by uid 500); 10 Jul 2009 03:38:46 -0000 Mailing-List: contact hama-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hama-dev@ Delivered-To: mailing list hama-commits@incubator.apache.org Received: (qmail 1738 invoked by uid 99); 10 Jul 2009 03:38:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Jul 2009 03:38:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.130] (HELO eos.apache.org) (140.211.11.130) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Jul 2009 03:38:35 +0000 Received: from eos.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id 883681112E for ; Fri, 10 Jul 2009 03:38:13 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Apache Wiki To: hama-commits@incubator.apache.org Date: Fri, 10 Jul 2009 03:38:13 -0000 Message-ID: <20090710033813.4562.88195@eos.apache.org> Subject: [Hama Wiki] Update of "EigenValuesAndEigenVectors" by SamuelGuo X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Hama Wiki" for change notification. The following page has been changed by SamuelGuo: http://wiki.apache.org/hama/EigenValuesAndEigenVectors ------------------------------------------------------------------------------ - Describe EigenValuesAndEigenVectors here. + In Hama, we use [http://en.wikipedia.org/wiki/Jacobi_eigenvalue_algorithm|Jacobi eigenvalue algorithm] to calculate all eigenvalues and eigenvectors of a real symmetric matrix. + = Description = + + Let A be a symmetric matrix, and G = G(i,j,θ) be a Givens rotation matrix. Then: + + A'=G^T A G , + + is symmetric and similar to A. + + As they are similar, A and A′ have the same Frobenius norm ||·||F (the sum of squares of all components), however we can choose θ such that A′(ij) = 0, in which case A′ has a larger sum of squares on the diagonal: + + A'(ij) = cos(2 * θ) * A(ij) + (1/2) * sin(2 * θ) * (A(ii) - A(jj)) + + Set this equal to 0, and rearrange: + + tan(2 * θ) = (2 * A(ij)) / (A(jj) - A(ii)) + + In order to optimize this effect, A(ij) should be the largest off-diagonal component, called the pivot. + + The Jacobi eigenvalue method repeatedly finds the pivot and performs rotations until the matrix becomes almost diagonal. Then the elements in the diagonal are approximations of the (real) eigenvalues of A. + + = Methods = + The implementation of Jacobi eigenvalue method in Hama are described as below: + + 1. Find the pivot: Get the largest off-diagonal element of the matrix. + + We use a M/R job to find the pivot p and its index in the matrix(pivot_row, pivot_col). These are all done in PivotMapper and PivotReducer. + + 1.#2 Compute the rotation parameters. + + 1. Rotate the matrix using the rotation matrix. + + As the rotation matrix is a 2X2 matrix, each rotation just effects 4 elements of the + matrix. The rotations can not effect each other, so we can do the rotations parallely. + + The Pseudocode described as below: + + i. for i := 1 to k−1 do rotate(i,k,i,l) endfor + + i. for i := k+1 to l−1 do rotate(k,i,i,l) endfor + + i. for i := l+1 to n do rotate(k,i,l,i) endfor + + Rotate(k,l,i,j):(''S'' is the matrix, ''c & s'' is the parameters of the rotation matrix computed in step 2) + + S(kl) = c * S(kl) - s * S(ij) + + S(ij) = s * S(kl) + c * S(ij) + + The Implementation of M/R job to rotate the matrix is a tricky. We do not rotate the matrix + actually in Mapper & Reducer. We do this rotation during we scan over the matrix table. Plz check the code in RotationInputFormat. + + 1.#4 Rotate the eigenvectors matrix. + + 1. Repeats until the matrix becomes almost diagonal, or the loops reach the limit specified by the user. +