- •1 Introduction
- •1.1 What makes eigenvalues interesting?
- •1.2 Example 1: The vibrating string
- •1.2.1 Problem setting
- •1.2.2 The method of separation of variables
- •1.3.3 Global functions
- •1.3.4 A numerical comparison
- •1.4 Example 2: The heat equation
- •1.5 Example 3: The wave equation
- •1.6 The 2D Laplace eigenvalue problem
- •1.6.3 A numerical example
- •1.7 Cavity resonances in particle accelerators
- •1.8 Spectral clustering
- •1.8.1 The graph Laplacian
- •1.8.2 Spectral clustering
- •1.8.3 Normalized graph Laplacians
- •1.9 Other sources of eigenvalue problems
- •Bibliography
- •2 Basics
- •2.1 Notation
- •2.2 Statement of the problem
- •2.3 Similarity transformations
- •2.4 Schur decomposition
- •2.5 The real Schur decomposition
- •2.6 Normal matrices
- •2.7 Hermitian matrices
- •2.8 Cholesky factorization
- •2.9 The singular value decomposition (SVD)
- •2.10 Projections
- •2.11 Angles between vectors and subspaces
- •Bibliography
- •3 The QR Algorithm
- •3.1 The basic QR algorithm
- •3.1.1 Numerical experiments
- •3.2 The Hessenberg QR algorithm
- •3.2.1 A numerical experiment
- •3.2.2 Complexity
- •3.3 The Householder reduction to Hessenberg form
- •3.3.2 Reduction to Hessenberg form
- •3.4 Improving the convergence of the QR algorithm
- •3.4.1 A numerical example
- •3.4.2 QR algorithm with shifts
- •3.4.3 A numerical example
- •3.5 The double shift QR algorithm
- •3.5.1 A numerical example
- •3.5.2 The complexity
- •3.6 The symmetric tridiagonal QR algorithm
- •3.6.1 Reduction to tridiagonal form
- •3.6.2 The tridiagonal QR algorithm
- •3.7 Research
- •3.8 Summary
- •Bibliography
- •4.1 The divide and conquer idea
- •4.2 Partitioning the tridiagonal matrix
- •4.3 Solving the small systems
- •4.4 Deflation
- •4.4.1 Numerical examples
- •4.6 Solving the secular equation
- •4.7 A first algorithm
- •4.7.1 A numerical example
- •4.8 The algorithm of Gu and Eisenstat
- •4.8.1 A numerical example [continued]
- •Bibliography
- •5 LAPACK and the BLAS
- •5.1 LAPACK
- •5.2 BLAS
- •5.2.1 Typical performance numbers for the BLAS
- •5.3 Blocking
- •5.4 LAPACK solvers for the symmetric eigenproblems
- •5.6 An example of a LAPACK routines
- •Bibliography
- •6 Vector iteration (power method)
- •6.1 Simple vector iteration
- •6.2 Convergence analysis
- •6.3 A numerical example
- •6.4 The symmetric case
- •6.5 Inverse vector iteration
- •6.6 The generalized eigenvalue problem
- •6.7 Computing higher eigenvalues
- •6.8 Rayleigh quotient iteration
- •6.8.1 A numerical example
- •Bibliography
- •7 Simultaneous vector or subspace iterations
- •7.1 Basic subspace iteration
- •7.2 Convergence of basic subspace iteration
- •7.3 Accelerating subspace iteration
- •7.4 Relation between subspace iteration and QR algorithm
- •7.5 Addendum
- •Bibliography
- •8 Krylov subspaces
- •8.1 Introduction
- •8.3 Polynomial representation of Krylov subspaces
- •8.4 Error bounds of Saad
- •Bibliography
- •9 Arnoldi and Lanczos algorithms
- •9.2 Arnoldi algorithm with explicit restarts
- •9.3 The Lanczos basis
- •9.4 The Lanczos process as an iterative method
- •9.6 Partial reorthogonalization
- •9.5 An error analysis of the unmodified Lanczos algorithm
- •9.7 Block Lanczos
- •9.8 External selective reorthogonalization
- •Bibliography
- •10 Restarting Arnoldi and Lanczos algorithms
- •10.2 Implicit restart
- •10.3 Convergence criterion
- •10.4 The generalized eigenvalue problem
- •10.5 A numerical example
- •10.6 Another numerical example
- •10.7 The Lanczos algorithm with thick restarts
- •10.8 Krylov–Schur algorithm
- •10.9 The rational Krylov space method
- •Bibliography
- •11 The Jacobi-Davidson Method
- •11.1 The Davidson algorithm
- •11.2 The Jacobi orthogonal component correction
- •11.2.1 Restarts
- •11.2.2 The computation of several eigenvalues
- •11.2.3 Spectral shifts
- •11.3 The generalized Hermitian eigenvalue problem
- •11.4 A numerical example
- •11.6 Harmonic Ritz values and vectors
- •11.7 Refined Ritz vectors
- •11.8 The generalized Schur decomposition
- •11.9.1 Restart
- •11.9.3 Algorithm
- •Bibliography
- •12 Rayleigh quotient and trace minimization
- •12.1 Introduction
- •12.2 The method of steepest descent
- •12.3 The conjugate gradient algorithm
- •12.4 Locally optimal PCG (LOPCG)
- •12.5 The block Rayleigh quotient minimization algorithm (BRQMIN)
- •12.7 A numerical example
- •12.8 Trace minimization
- •Bibliography
96 |
CHAPTER 5. LAPACK AND THE BLAS |
high-performance computers. The BLAS enable LAPACK routines to achieve high performance with portable code.
The BLAS are not strictly speaking part of LAPACK, but Fortran 77 code for the BLAS is distributed with LAPACK, or can be obtained separately from netlib where “model implementations” are found.
The model implementation is not expected to perform as well as a specially tuned implementation on most high-performance computers – on some machines it may give much worse performance – but it allows users to run LAPACK codes on machines that do not o er any other implementation of the BLAS.
The complete LAPACK package or individual routines from LAPACK are freely available from the World Wide Web or by anonymous ftp. The LAPACK homepage can be accessed via the URL http://www.netlib.org/lapack/.
5.2BLAS
By 1976 it was clear that some standardization of basic computer operations on vectors was needed [9]. By then it was already known that coding procedures that worked well on one machine might work very poorly on others. In consequence of these observations, Lawson, Hanson, Kincaid and Krogh proposed a limited set of Basic Linear Algebra Subprograms (BLAS) to be (hopefully) optimized by hardware vendors, implemented in assembly language if necessary, that would form the basis of comprehensive linear algebra packages [9]. These so-called Level 1 BLAS consisted of vector operations and some attendant co-routines. The first major package which used these BLAS kernels was LINPACK [3]. Soon afterward, other major software libraries such as the IMSL library and NAG rewrote portions of their existing codes and structured new routines to use these BLAS. Early in their development, vector computers saw significant optimizations using the BLAS. Soon, however, such machines were clustered together in tight networks and somewhat larger kernels for numerical linear algebra were developed [6, 7] to include matrix-vector operations (Level 2 BLAS). Additionally, FORTRAN compilers were by then optimizing vector operations as e ciently as hand coded Level 1 BLAS. Subsequently, in the late 1980s, distributed memory machines were in production and shared memory machines began to have significant numbers of processors. A further set of matrix-matrix operations was proposed [4] and soon standardized [5] to form a Level 3. The first major package for linear algebra which used the Level 3 BLAS was LAPACK [1] and subsequently a scalable (to large numbers of processors) version was released as ScaLAPACK [2]. Vendors focused on Level 1, Level 2, and Level 3 BLAS which provided an easy route to optimizing LINPACK, then LAPACK. LAPACK not only integrated pre-existing solvers and eigenvalue routines found in EISPACK [10] (which did not use the BLAS) and LINPACK (which used Level 1 BLAS), but incorporated the latest dense and banded linear algebra algorithms available. It also used the Level 3 BLAS which were optimized by much vendor e ort. Later, we will illustrate several BLAS routines. Conventions for di erent BLAS are indicated by
• A root operation. For example, axpy for the operation
(5.1) |
y := a·x + y |
•A prefix (or combination prefix) to indicate the datatype of the operands, for example saxpy for single precision axpy operation, or isamax for the index of the maximum absolute element in an array of type single.
5.2. BLAS |
97 |
•a su x if there is some qualifier, for example cdotc or cdotu for conjugated or unconjugated complex dot product, respectively:
|
n−1 |
|
Xi |
cdotc(n,x,1,y,1) = |
xiy¯i |
|
=0 |
|
n−1 |
|
Xi |
cdotu(n,x,1,y,1) = |
xiyi |
|
=0 |
where both x, y are vectors of complex elements.
Tables 5.1 and 5.2 give the prefix/su x and root combinations for the BLAS, respectively.
|
Prefixes: |
|
|
S |
REAL |
D |
DOUBLE PRECISION |
C |
COMPLEX |
Z |
DOUBLE COMPLEX |
|
|
|
Su xes: |
U |
transpose |
C |
Hermitian conjugate |
|
|
Table 5.1: Basic Linear Algebra Subprogram prefix/su x conventions.
5.2.1Typical performance numbers for the BLAS
Let us look at typical representations of all three levels of the BLAS, daxpy, ddot, dgemv, and dgemm, that perform some basic operations. Additionally, we look at the rank-1 update routine dger. An overview on the number of memory accesses and floating point operations is given in Table 5.3. The Level 1 BLAS comprise basic vector operations. A call of one of the Level 1 BLAS thus gives rise to O(n) floating point operations and O(n) memory accesses. Here, n is the vector length. The Level 2 BLAS comprise operations that involve matrices and vectors. If the involved matrix is n-by-n then both the memory accesses and the floating point operations are of O(n2). In contrast, the Level 3 BLAS have a higher order of floating point operations than memory accesses. The most prominent operation of the Level 3 BLAS, matrix-matrix multiplication costs O(n3) floating point operations while there are only O(n2) reads and writes. The last column in Table 5.3 shows the crucial di erence between the Level 3 BLAS and the rest.
Table 5.4 gives some performance numbers for the five BLAS of Table 5.3. Notice that the timer has a resolution of only 1 µsec! Therefore, the numbers in Table 5.4 have been obtained by timing a loop inside of which the respective function is called many times. The Mflop/s rates of the Level 1 BLAS ddot and daxpy quite precisely reflect the ratios of the memory accesses of the two routines, 2n vs. 3n. The high rates are for vectors that can be held in the on-chip cache of 512 MB. The low 240 and 440 Mflop/s with the very long vectors are related to the memory bandwidth of about 1900 MB/s.
The Level 2 BLAS dgemv has about the same performance as daxpy if the matrix can be held in cache (n = 100). Otherwise it is considerably reduced. dger has a high volume of read and write operations, while the number of floating point operations is limited.
98 |
CHAPTER 5. LAPACK AND THE BLAS |
Level 1 BLAS
rotg, rot rotmg, rotm swap
scal copy axpy dot nrm2 asum i amax
Level 2 BLAS
gemv, gbmv
hemv, hbmv, hpmv
semv, sbmv, spmv
trmv, tbmv, tpmv
trsv, tbsv, tpsv
ger, geru, gerc her, hpr, syr, spr
her2, hpr2, syr2, spr2
Level 3 BLAS
gemm, symm, hemm
syrk, herk
syr2k, her2k
trmm
trsm
Generate/apply plane rotation Generate/apply modified plane rotation Swap two vectors: x ↔ y
Scale a vector: x ← αx Copy a vector: x ← y
axpy operation: y ← y + αx Dot product: s ← x · y = x y 2-norm: s ← kxk2
1-norm: s ← kxk1
Index of largest vector element: first i such |xi| ≥ |xk| for all k
General (banded) matrix-vector multiply: y ← αAx + βy
Hermitian (banded, packed) matrix-vector multiply: y ← αAx + βy
Symmetric (banded, packed) matrix-vector multiply: y ← αAx + βy
Triangular (banded, packed) matrix-vector multiply: x ← Ax
Triangular (banded, packed) system solves (forward/backward substitution): x ← A−1x Rank-1 updates: A ← αxy + A Hermitian/symmetric (packed) rank-1 updates:
A ← αxx + A
Hermitian/symmetric (packed) rank-2 updates:
A ← αxy + α yx + A
General/symmetric/Hermitian matrix-matrix multiply: C ← αAB + βC Symmetric/Hermitian rank-k update:
C ← αAA + βC
Symmetric/Hermitian rank-k update:
C ← αAB + α BA + βC
Multiple triangular matrix-vector multiplies:
B ← αAB
Multiple triangular system solves: B ← αA−1B
Table 5.2: Summary of the Basic Linear Algebra Subroutines.
