Notes on Cholesky Factorization



Similar documents
6. Cholesky factorization

Retargeting PLAPACK to Clusters with Hardware Accelerators

SOLVING LINEAR SYSTEMS

Solution of Linear Systems

7. LU factorization. factor-solve method. LU factorization. solving Ax = b with A nonsingular. the inverse of a nonsingular matrix

7 Gaussian Elimination and LU Factorization

Solving Systems of Linear Equations

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

Factorization Theorems

Trading Off Performance for Power-Energy in Dense Linear Algebra Operations

High Performance Matrix Inversion with Several GPUs

CS3220 Lecture Notes: QR factorization and orthogonal transformations

Direct Methods for Solving Linear Systems. Matrix Factorization

Matrix Differentiation

Field G. Van Zee. Pursue research and development activities in high-performance computing.

Operation Count; Numerical Linear Algebra

MATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1.

A Direct Numerical Method for Observability Analysis

Math 115A HW4 Solutions University of California, Los Angeles. 5 2i 6 + 4i. (5 2i)7i (6 + 4i)( 3 + i) = 35i + 14 ( 22 6i) = i.

Matrix Multiplication

8 Square matrices continued: Determinants

December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B. KITCHENS

MATH 304 Linear Algebra Lecture 18: Rank and nullity of a matrix.

General Framework for an Iterative Solution of Ax b. Jacobi s Method

AMS526: Numerical Analysis I (Numerical Linear Algebra)

Notes on Determinant

NOTES ON LINEAR TRANSFORMATIONS

by the matrix A results in a vector which is a reflection of the given

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

DATA ANALYSIS II. Matrix Algorithms

Similarity and Diagonalization. Similar Matrices

LU Factoring of Non-Invertible Matrices

The Characteristic Polynomial

Math 312 Homework 1 Solutions

MATH 423 Linear Algebra II Lecture 38: Generalized eigenvectors. Jordan canonical form (continued).

α = u v. In other words, Orthogonal Projection

Solving Linear Systems, Continued and The Inverse of a Matrix

HSL and its out-of-core solver

( ) which must be a vector

Mathematics Course 111: Algebra I Part IV: Vector Spaces

FUZZY CLUSTERING ANALYSIS OF DATA MINING: APPLICATION TO AN ACCIDENT MINING SYSTEM

Solving Linear Systems of Equations. Gerald Recktenwald Portland State University Mechanical Engineering Department

Fault Tolerant Matrix-Matrix Multiplication: Correcting Soft Errors On-Line.

Systems of Linear Equations

MATH 304 Linear Algebra Lecture 9: Subspaces of vector spaces (continued). Span. Spanning set.

APPM4720/5720: Fast algorithms for big data. Gunnar Martinsson The University of Colorado at Boulder

Solution to Homework 2

Row Echelon Form and Reduced Row Echelon Form

Lecture 3: Finding integer solutions to systems of linear equations

UNCOUPLING THE PERRON EIGENVECTOR PROBLEM

Inner Product Spaces and Orthogonality

Inner products on R n, and more

Chapter 7. Matrices. Definition. An m n matrix is an array of numbers set out in m rows and n columns. Examples. (

MAT188H1S Lec0101 Burbulla

Solving Simultaneous Equations and Matrices

Data Mining: Algorithms and Applications Matrix Math Review

Abstract: We describe the beautiful LU factorization of a square matrix (or how to write Gaussian elimination in terms of matrix multiplication).

Integer Factorization using the Quadratic Sieve

Nonlinear Iterative Partial Least Squares Method

1 Sets and Set Notation.

Section Inner Products and Norms

Lecture 1: Systems of Linear Equations

13 MATH FACTS a = The elements of a vector have a graphical interpretation, which is particularly easy to see in two or three dimensions.

Similar matrices and Jordan form

1 VECTOR SPACES AND SUBSPACES

Continued Fractions and the Euclidean Algorithm

Linear Codes. Chapter Basics

SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison

1.2 Solving a System of Linear Equations

Lecture notes on linear algebra

A Dynamic Programming Approach for Generating N-ary Reflected Gray Code List

Matrix-vector multiplication in terms of dot-products

AN OUT-OF-CORE SPARSE SYMMETRIC INDEFINITE FACTORIZATION METHOD

The Singular Value Decomposition in Symmetric (Löwdin) Orthogonalization and Data Compression

By choosing to view this document, you agree to all provisions of the copyright laws protecting it.

Analysis of a Production/Inventory System with Multiple Retailers

Yousef Saad University of Minnesota Computer Science and Engineering. CRM Montreal - April 30, 2008

1 Introduction to Matrices

Elementary Matrices and The LU Factorization

SECOND DERIVATIVE TEST FOR CONSTRAINED EXTREMA

Math 1050 Khan Academy Extra Credit Algebra Assignment

1 Solving LPs: The Simplex Algorithm of George Dantzig

THE FUNDAMENTAL THEOREM OF ALGEBRA VIA PROPER MAPS

Lecture Notes 2: Matrices as Systems of Linear Equations

Orthogonal Bases and the QR Algorithm

The van Hoeij Algorithm for Factoring Polynomials

Two classes of ternary codes and their weight distributions

Trading Off Performance for Energy in Linear Algebra Operations with Applications in Control Theory

9.2 Summation Notation

MATRICES WITH DISPLACEMENT STRUCTURE A SURVEY

Arithmetic and Algebra of Matrices

Applied Linear Algebra I Review page 1

A Simultaneous Solution for General Linear Equations on a Ring or Hierarchical Cluster

ECE 842 Report Implementation of Elliptic Curve Cryptography

SHARP BOUNDS FOR THE SUM OF THE SQUARES OF THE DEGREES OF A GRAPH

Using row reduction to calculate the inverse and the determinant of a square matrix

Linear Algebra Notes for Marsden and Tromba Vector Calculus

Lecture 15 An Arithmetic Circuit Lowerbound and Flows in Graphs

8 Divisibility and prime numbers

Transcription:

Notes on Cholesky Factorization Robert A. van de Geijn Department of Computer Science Institute for Computational Engineering and Sciences The University of Texas at Austin Austin, TX 78712 rvdg@cs.utexas.edu March 11, 2011 1 Definition and Existence The Cholesky factorization is only defined for symmetric or Hermitian positive definite matrices. In this note, we will restrict ourselves to the case where A is real and symmetric positive definite (SPD). Definition 1. A matrix A R m m is symmetric positive definite (SPD) if and only if it is symmetric (A T A) and for all nonzero vectors x R m it is the case that x T Ax > 0. Exercise 2. First some exercises: Let B R m n have linearly independent columns. Prove that A B T B is SPD. Exercise 3. Let A R m m be SPD. Show that its diagonal elements are positive. We will prove the following theorem in Section 4: Theorem 4. Cholesky Factorization Theorem Given a SPD matrix A there exists a lower triangular matrix L such that A LL T. The lower triangular matrix L is known as the Cholesky factor and LL T is known as the Cholesky factorization of A. It is unique if the diagonal elements of L are restricted to be positive. The operation that overwrites the lower triangular part of matrix A with its Cholesky factor will be denoted by A : Chol(A), which should be read as A becomes its Cholesky factor. Typically, only the lower (or upper) triangular part of A is stored, and it is that 1

for j 1 : n α j,j : α j,j for i j + 1 : n α i,j : α i,j /α j,j endfor for k j + 1 : n for i k : n α i,k : α i,k α i,j α k,j endfor endfor endfor for j 1 : n α j,j : α j,j α j+1:n,j : α j+1:n,j /α j,j α j+1:n,j+1:n : α j+1:n,j+1:n tril(α j+1:n,j α T j+1:n,j ) endfor Figure 1: Formulations of the Cholesky factorization that expose indices using Matlab-like notation. part that is then overwritten with the result. In this discussion, we will assume that the lower triangular part of A is stored and overwritten. 2 Application The Cholesky factorization is used to solve the linear system Ax y when A is SPD: Substituting the factors into the equation yields LL T x y. Letting z L T x, Ax L (L T x) } {{ } z Lz y. Thus, z can be computed by solving the triangular system of equations Lz y and subsequently the desired solution x can be computed by solving the triangular linear system L T x z. 3 An Algorithm (Variant 3) The most common algorithm for computing A : Chol(A) can be derived as follows: Consider A LL T. Partition α 11 λ 11 0 A and L. (1) a 21 A 22 l 21 L 22 2

Remark 5. We adopt the commonly used notation where Greek lower case letters refer to scalars, lower case letters refer to (column) vectors, and upper case letters refer to matrices. The refers to a part of A that is neither stored nor updated. By substituting these partitioned matrices into A LL T we find that ( α 11 a 21 A 22 ) ( λ 11 0 l 21 L 22 ) ( λ 11 0 l 21 L 22 ) T ( λ 2 11 λ 11 l 21 l 21 l T 21 + L 22 L T 22 ), so that α 11 λ 2 11 and hence These equalities motivate the algorithm α 11 1. Partition A. a 21 A 22 a 21 λ 11 l 21 A 22 l 21 l 21 + L 22 L T 22 λ 11 α 11 l 21 a 21 /λ 11 L 22 Chol(A 22 l 21 l21). T 2. Overwrite α 11 : λ 11 α 11. (Picking λ 11 α 11 makes it positive ensures uniqueness.) 3. Overwrite a 21 : l 21 a 21 /λ 11. 4. Overwrite A 22 : A 22 l 21 l T 21 (updating only the lower triangular part of A 22 ). 5. Continue with A A 22. (Back to Step 1.) The algorithm is typically presented in a text using Matlab-like notation as illustrated in Fig. 1. Remark 6. Similar to the tril function in Matlab, we use tril(b) to denote the lower triangular part of matrix B. 4 Proof of the Cholesky Factorization Theorem In this section, we partition A as in (4). The following lemmas, which can be found in any standard text, are key to the proof: Lemma 7. Let A R n n be SPD. Then α 11 is real and positive. Proof: This is special case of Exercise 1. 3

Lemma 8. Let A R m m be SPD and l 21 a 21 / α 11. Then A 22 l 21 l T 21 is SPD. Proof: Since A is symmetric ( so are ) A 22 and A 22 l 21 l21. T Let x 1 0 be an arbitrary vector of length n 1. Define x 0 < x T Ax ( ( χ 0 x 1 χ 0 x 1 χ 0 x 1 ) T ( ) T ( where χ 0 a T 21x 1 /α 11. Then, since x 0, α 11 a T 21 a 21 A 22 ) ( α 11 χ 0 + a T 21x 1 a 21 χ 0 + A 22 x 1 χ 0 x 1 α 11 χ 2 0 + χ 0 a T 21x 1 + x T 1 a 21 χ 0 + x T 1 A 22 x 1 α 11 a T 21x 1 α 11 x T 1 a 21 α 11 xt 1 a 21 α 11 a T 21x 1 x T 1 a 21 a T 21x 1 α 11 + x T 1 A 22 x 1 x T 1 (A 22 a 21a T 21 α 11 )x 1 x T 1 (A 22 l 21 l T 21)x 1. We conclude that A 22 l 21 l T 21 is SPD. Proof: of Cholesky Factorization Theorem Proof by induction. Base case: n 1. Clearly the result is true for a 1 1 matrix A α 11 : In this case, the fact that A is SPD means that α 11 is real and positive and a Cholesky factor is then given by λ 11 α 11, with uniqueness if we insist that λ 11 is positive. Inductive step: Assume the result is true for SPD matrix A R (n 1) (n 1). We will show that it holds for A R n n. Let A R n n be SPD. Partition A and L as in (4) and let λ 11 α 11 (which is well-defined by Lemma 4), l 21 a 21 /λ 11, and L 22 Chol(A 22 l 21 l T 21) (which exists as a consequence of the Inductive Hypothesis and Lemma 4). Then L is the desired Cholesky factor of A. By the principle of mathematical induction, the theorem holds. 5 Blocked Algorithm (Variant 3) In order to attain high performance, the computation is cast in terms of matrix-matrix multiplication by so-called blocked algorithms. For the Cholesky factorization a blocked version of the algorithm can be derived by partitioning A 11 L 11 0 A and L, A 21 A 22 L 21 L 22 4 ) )

for j 1 : n in steps of n b b : min(n j + 1, n b ) A j:j+b 1,j:j+b 1 : Chol(A j:j+b 1,j:j+b 1 ) A j+b:n,j:j+b 1 : A j+b:n,j:j+b 1 A T j:j+b 1,j:j+b 1 A j+b:n,j+b:n : A j+b:n,j+b:n tril(a j+b:n,j:j+b 1 A T j+b:n,j:j+b 1 ) endfor Figure 2: Blocked algorithm for computing the Cholesky factorization. Here n b is the block size used by the algorithm. where A 11 and L 11 are b b. By substituting these partitioned matrices into A LL T we find that T ( ) A 11 L 11 0 L 11 0 L 11 L T 11. A 21 A 22 L 21 L 22 L 21 L 22 L 21 L T 11 L 21 L T 21 + L 22 L T 22 From this we conclude that L 11 Chol(A 11 ) L 21 A 21 L T 11 L 22 Chol(A 22 L 21 L T 21). An algorithm is then described by the steps A 11 1. Partition A, where A 11 is b b. A 21 A 22 2. Overwrite A 11 : L 11 Chol(A 11 ). 3. Overwrite A 21 : L 21 A 21 L T 11. 4. Overwrite A 22 : A 22 L 21 L T 21 (updating only the lower triangular part). 5. Continue with A A 22. (Back to Step 1.) An algorithm that explicitly indexes into the array that stores A is given in Fig. 2. Remark 9. The Cholesky factorization A 11 : L 11 Chol(A 11 ) can be computed with the unblocked algorithm or by calling the blocked Cholesky factorization algorithm recursively. Operations like L 21 A 21 L T 11 are computed by solving the equivalent linear system with multiple right-hand sides L 11 L T 21 A T 21. 6 Alternative Representation When explaining the above algorithm in a classroom setting, invariably it is accompanied by a picture sequence like the one in Fig. 3(left) and the (verbal) explanation: 5

done done A T L done partially updated Beginning of iteration A BL A BR A 00 Repartition a T 10 α 11 A 20 a 21 A 22 UPD. UPD. UPD. Update α11 a 21 α 11 A 22 a 21 a T 21 done done done partially updated End of iteration A T L A BL A BR Figure 3: Left: Progression of pictures that explain Cholesky factorization algorithm. Right: Same pictures, annotated with labels and updates. Beginning of iteration: At some stage of the algorithm (Top of the loop), the computation has moved through the matrix to the point indicated by the thick lines. Notice that we have finished with the parts of the matrix that are in the top-left, top-right (which is not to be touched), and bottom-left quadrants. The bottom-right quadrant has been updated to the point where we only need to perform a Cholesky factorization of it. Repartition: We now repartition the bottom-right submatrix to expose α 11, a 21, and A 22. 6

Algorithm: A : Chol unb(a) AT L Partition A where A T L is 0 0 while m(a T L ) < m(a) do Repartition A 00 AT L a T 10 α 11 A 20 a 21 A 22 where α 11 is 1 1 α 11 : α 11 a 21 : a 21 /α 11 A 22 : A 22 tril(a 21 a T 21) Continue with A 00 AT L a T 10 α 11 A 20 a 21 A 22 endwhile Algorithm: A : Chol blk(a) AT L Partition A where A T L is 0 0 while m(a T L ) < m(a) do Determine block size b Repartition A 00 AT L A 10 A 11 A 20 A 21 A 22 where A 11 is b b A 11 : Chol(A 11 ) A 21 : A 21 tril(a 11 ) T A 22 : A 22 tril(a 21 A T 21) Continue with A 00 AT L A 10 A 11 A 20 A 21 A 22 endwhile Figure 4: Unblocked and blocked algorithms for computing the Cholesky factorization. Update: α 11, a 21, and A 22 are updated as discussed before. End of iteration: The thick lines are moved, since we now have completed more of the computation, and only a factorization of A 22 (which becomes the new bottom-right quadrant) remains to be performed. Continue: The above steps are repeated until the submatrix A BR is empty. To motivate our notation, we annotate this progression of pictures as in Fig. 3 (right). In those pictures, T, B, L, and R stand for Top, Bottom, Left, and Right, respectively. This then motivates the format of the algorithm in Fig. 4 (left). A similar explanation can be given for the blocked algorithm, which is given in Fig. 4 (right). In the algorithms, m(a) indicates the number of rows of matrix A. Remark 10. The indices in our more stylized presentation of the algorithms are subscripts rather than indices in the conventional sense. 7

Remark 11. Clearly Fig. 4 does not present the algorithm as concisely as the algorithms given in Figs. 1 and 2. However, it does capture to a large degree the verbal description of the algorithm mentioned above and therefore, in our opinion, reduces both the effort required to interpret the algorithm and the need for additional explanations. The notation also mirrors that used for the proof in Section 4. Remark 12. The notation in Figs. 3 and 4 allows the contents of matrix A at the beginning of the iteration to be formally stated: AT L LT L A L BL Â BR tril(l BL L T BL ), A BL A BR T where L T L Chol(ÂT L), L BL ÂBLLT L, and ÂT L, ÂBL and ÂBR denote the original contents of the quadrants A T L, A BL and A BR, respectively. Exercise 13. Implement the Cholesky factorization with M-script. 7 Cost The cost of the Cholesky factorization of A R m m can be analyzed as follows: In Fig. 4 (left) during the kth iteration (starting k at zero) A 00 is k k. Thus, the operations in that iteration cost α 11 : α 11 : negligible when k is large. a 21 : a 21 /α 11 : approximately (m k 1) flops. A 22 : A 22 tril(a 21 a T 21): approximately (m k 1) 2 flops. (A rank-1 update of all of A 22 would have cost 2(m k 1) 2 flops. Approximately half the entries of A 22 are updated.) Thus, the total cost in flops is given by C Chol (m) m 1 (m k 1) 2 k0 } {{ } (Due to update of A 22 ) m 1 j0 j 2 + m 1 j0 + m 1 (m k 1) k0 j 1 3 m3 + 1 2 m2 1 3 m3 } {{ } (Due to update of a 21 ) which allows us to state that (obvious) most computation is in the update of A 22. 8

8 Other Algorithms The algorithms that were described in Sections 3 and 5 are sometimes called the unblocked and blocked right-looking algorithms. The idea is that relative to the current column or block, the bulk of data with which one computes is to the right. In some of our papers we also call these Variant 3. There are other algorithms for this operation, which we describe next. 8.1 Bordered algorithm (Variant 1) Another algorithm for computing A : Chol(A) can be derived as follows: Consider again A LL T. Partition A 00 L 00 0 A and L. a T 10 α 11 l10 T λ 11 By substituting these partitioned matrices into A LL T we find that T ( A 00 L 00 0 L 00 0 L 00 L T 00 a T 10 α 11 l10 T λ 11 l10 T λ 11 l10l T T 00 l10l T 10 + λ 2 11 ) from which we conclude that These equalities motivate the algorithm A 00 1. Partition A. a T 10 α 11 L 00 Chol(A) 00 l10 T a T 10L T 00 λ 11. α 11 l10l T 10 2. Assume that A 00 : L 00 Chol(A 00 ) has been computed by previous iterations of the loop-based algorithm. 3. Overwrite a T 10 : l T 10 a T 10L T 00. 4. Overwrite α 11 : α 11 l T 10l 10. This justifies the unblocked Variant 1 in Figure 5. A blocked algorithm can be similarly derived: Partition ( A 00 L 00 0 A and L A 10 A 11 L 10 L 11 ) (2) 9

Algorithm: A : Chol unb(a) AT L Partition A where A T L is 0 0 while m(a T L ) < m(a) do Repartition A 00 AT L a T 10 α 11 A 20 a 21 A 22 where α 11 is 1 1 Variant 1 (Bordered Algorithm) a T 10 : a T 10tril(A 00 ) T α 11 : α 11 a T 10a 10 α 11 : α 11 Variant 2 (Left-looking Algorithm) α 11 : α 11 a T 10a 10 α 11 : α 11 a 21 : a 21 A 20 a 10 a 21 : a 21 /α 11 Variant 3 (Right-looking Algorithm) α 11 : α 11 a 21 : a 21 /α 11 A 22 : A 22 tril(a 21 a T 21) Continue with A 00 AT L a T 10 α 11 A 20 a 21 A 22 endwhile Algorithm: A : Chol blk(a) AT L Partition A where A T L is 0 0 while m(a T L ) < m(a) do Determine block size b Repartition A 00 AT L A 10 A 11 A 20 A 21 A 22 where A 11 is b b Variant 1 (Bordered Algorithm) A 10 : A 10 tril(a 00 ) T A 11 : A 11 A 10 A T 10 A 11 : Chol(A 11 ) Variant 2 (Left-looking Algorithm) A 11 : A 11 A 10 A T 10 A 11 : Chol(A 11 ) A 21 : A 21 A 20 A T 10 A 21 : A 21 tril(a 11 ) T Variant 3 (Right-looking Algorithm) A 11 : Chol(A 11 ) A 21 : A 21 tril(a 11 ) T A 22 : A 22 tril(a 21 A T 21) Continue with A 00 AT L A 10 A 11 A 20 A 21 A 22 endwhile Figure 5: Multiple variants for computing the Cholesky factorization. 10

By substituting these partitioned matrices into A LL T we find that T ( A 00 L 00 0 L 00 0 L 00 L T 00 A 10 A 11 L 10 L 11 L 10 L 11 L 10 L T 00 L 10 L T 10 + L 11 L T 11 ) from which we conclude that These equalities motivate the algorithm A 00 1. Partition A. A 10 A 11 L 00 Chol(A) 00 L 10 A 10 L T 00 L 11 Chol(A 11 L 10 L 10 ). T 2. Assume that A 00 : L 00 Chol(A 00 ) has been computed by previous iterations of the loop-based algorithm. 3. Overwrite A 10 : L 10 A 10 L T 00. 4. Overwrite A 11 : A 11 L 10 L T 10. 5. Overwrite A 11 : L 11 Chol(A 11 ) (by calling, for example, the unblocked algorithm). This justifies the blocked Variant 1 in Figure 5. 8.2 Left-looking algorithm (Variant 2) Yet another algorithm for computing A : Chol(A) can be derived as follows: Consider again A LL T. This time partition A 00 A a T 10 α 11 and L l10 T λ 11 0 (3) A 20 a 21 A 22 L 20 l 21 L 22 By substituting these partitioned matrices into A LL T we find that A 00 a T 10 α 11 l T 10 λ 11 0 l10 T λ 11 0 T A 20 a 21 A 22 L 20 l 21 L 22 L 20 l 21 L 22 L 00 L T 00 l T 10L T 00 l T 10l 10 + λ 2 11 L 20 L T 00 L 20 l 10 + λ 11 l 21 L 20 L T 20 + l 21 l T 21 + L 22 L T 22 11

from which we conclude that A 00 L 00 L T 00 a T 10 l T 10L T 00 α 11 l T 10l 10 + λ 2 11. A 20 L 20 L T 00 a 21 L 20 l 10 + λ 11 l 21 A 22 L 20 L T 20 + l 21 l T 21 + L 22 L T 22 Now, let us assume that in previous iterations of the loop the computation has proceeded so that A contains l10 T α 11 0. L 20 a 21 A 22 The purpose of the current iteration is to make it so that A contains l10 T λ 11 0. The following algorithm accomplishes this: L 20 l 21 A 22 1. Partition A A 00 a T 10 α 11 A 20 a 21 A 22 and assume that due to computation from previous iterations it contains l10 T α 11 0. L 20 a 21 A 22 2. Overwrite α 11 : λ 11 α 11 l T 10l 10. 3. Overwrite a 21 : a 21 L 20 l 10. 4. Overwrite a 21 : l 21 a 21 /λ 11. This justifies the unblocked Variant 2 in Figure 5. A blocked algorithm can be similarly derived. Partition A A 00 A 10 A 11 and L L 10 L 11 0 (4) A 20 A 21 A 22 L 20 L 21 L 22 12

By substituting these partitioned matrices into A LL T we find that A 00 A 10 A 11 L 10 L 11 0 L 10 L 11 0 T A 20 A 21 A 22 L 20 L 21 L 22 L 20 L 21 L 22 L 00 L T 00 L 10 L T 00 L 10 L T 10 + L 11 L T 11 L 20 L T 00 L 20 L T 10 + L 11 L 21 L 20 L T 20 + L 21 L T 21 + L 22 L T 22 from which we conclude that A 00 L 00 L T 00 A 10 L 10 L T 00 A 11 L 10 L T 10 + L 2 11. A 20 L 20 L T 00 A 21 L 20 L T 10 + L 11 L 21 A 22 L 20 L T 20 + L 21 L T 21 + L 22 L T 22 Now, let us assume that in previous iterations of the loop the computation has proceeded so that A contains L 10 A 11 0. L 20 A 21 A 22 The purpose of the current iteration is to make it so that A contains L 10 L 11 0. The following algorithm accomplishes this: L 20 L 21 A 22 1. Partition A A 00 A 10 A 11 A 20 A 21 A 22 and assume that due to computation from previous iterations it contains L 10 A 11 0. L 20 A 21 A 22 2. Overwrite A 11 : L 11 Chol(A 11 L 10 L T 10). 13

3. Overwrite A 21 : A 21 A 21 L 20 L T 10. 4. Overwrite A 21 : L 21 A 21 L T 11. This justifies the blocked Variant 2 in Figure 5. 9 Coding the algorithms As part of the FLAME project at The University of Texas at Austin, Universidad Jaume I, Spain, and RWTH Aachen University, Germany, we have developed APIs for coding these algorithms that make it so that the code closely resembles the algorithms. The demonstrate how these codes are written, we created a video titled High-Performance Implementation of Cholesky Factorization that can be found at http://www.cs.utexas.edu/users/flame/movies.html#chol. Exercise 14. Implement all the algorithms in Figure 5 in M-script (the scripting language of Matlab and Octave). Exercise 15. in the video. Implement all the algorithms in Figure 5 using the FLAME/C API mentioned 10 Performance In Figure 6 we show the performance attained on a multicore architecture. All experiments were performed using double-precision floating-point arithmetic on a Dell/PowerEdge-1435 powered by a Intel Xeon X5355 (2.666 GHz) processor. This particular architecture has four cores, each of which has a clock rate of about 2.7GHz and each core can perform four floating point operations per clock cycle. Thus, the peak of this machine is 4 cores 4 FLOPS cycle 2.7 109 cycles core 43 10 9 F LOP S 43GF LOP S. What the graph shows is the problem size for which performance was measured along the x-axis and the rate at which the algorithm computed along the y-axis. The rate was computed by, for a given time, measuring the time required to complete the computation, t(n) (in seconds), and then dividing the number of floating point operations by this time. This gives the rate, in floating point operations per second (FLOPS), at which the computation executed. Since this is a number measured in billions, we then divide this number by a billion to get the rate in GFLOPS (GigaFLOPS, or billions of floating point operations per second): rate in GFLOPS n 3 t(n) 10 9. 14

25 libflame reference UnbVar1 UnbVar2 UnbVar3 BlkVar1 BlkVar2 BlkVar3 20 GFLOPS/sec. 15 10 5 0 0 500 1000 1500 2000 2500 3000 3500 4000 matrix dimension mn Figure 6: Performance of the various algorithms on a 16 core architecture. The peak of this architecture is around 40 GFLOPS. Thus, our implementations reach about 2/3 of the peak of the processor, which is very good for this operation. It would be worthwhile to play with the block size (which we chose to be 128) to see if changing it improves performance. In the graph we do not show the performance of the LAPACK routine for Cholesky factorization, DPOTRF. In other experiments we did compare against a version of that routine that we changed so that we could control the block size that it uses. It then attains exactly the same performance as our blocked Variant 2 (and hence less than our blocked Variant 3 and the libflame routine FLA Chol). 11 Additional Reading The interested reader may be interested in the following documents: 1. A paper that illustrates how different algorithmic variants for Cholesky factorization and related operations should be chosen for different kinds of architectures, ranging from sequential processors to multithreaded (multicore) architectures to distributed memory parallel computers. Paolo Bientinesi, Brian Gunter, and Robert A. van de Geijn. Families of 15

algorithms related to the inversion of a symmetric positive definite matrix. ACM Transactions on Mathematical Software, 35(1). 2. Two papers that show how matrix-matrix operations can achieve near-peak performance: and Kazushige Goto and Robert A. van de Geijn. Anatomy of high-performance matrix multiplication. ACM Trans. Math. Soft., 34(3: Article 12, 25 pages), May 2008. Kazushige Goto and Robert van de Geijn. High-performance implementation of the level-3 BLAS. ACM Trans. Math. Softw., 35(1):1 14, 2008. 3. A book that shows how to systematically derive all loop-based algorithms for a broad range of linear algebra operations, including Cholesky factorization: Robert A. van de Geijn and Enrique S. Quintana-Ortí. The Science of Programming Matrix Computations. http://www.lulu.com/content/1911788, 2008. 4. The User s Guide for the libflame library, a modern replacement for the LAPACK library that is coded using the APIs mentioned in the movie: Field G. Van Zee. libflame: The Complete Reference. www.lulu.com, 2009. 5. An overview of the FLAME project: Field G. Van Zee, Ernie Chan, Robert van de Geijn, Enrique S. Quintana- Ortí, and Gregorio Quintana-Ortí. Introducing: The libflame library for dense matrix computations. IEEE Computation in Science & Engineering, 11(6):56 62, 2009. 16