Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Barrett R.Templates for the solution of linear systems.Building blocks for iterative methods

.pdf
Скачиваний:
22
Добавлен:
23.08.2013
Размер:
824.85 Кб
Скачать

x

Contents

List of Symbols

 

 

 

 

 

 

 

 

 

iv

List of Figures

 

 

 

 

 

 

 

 

 

xiii

1

Introduction

 

 

 

 

 

 

 

 

 

1

 

1.1

Why Use Templates? : : : : :

:

:

:

: :

: : : : : : : : : : : : : : : : : :

2

 

1.2

What Methods Are Covered?

:

:

:

:

:

:

:

: : : : : : : : : : : : : : : :

3

2

Iterative Methods

 

 

 

 

 

 

 

 

 

5

 

2.1

Overview of the Methods :

:

:

:

:

:

:

:

:

: : : : : : : : : : : : : : : :

5

 

2.2

Stationary Iterative Methods

 

:

:

:

:

:

:

:

: : : : : : : : : : : : : : : :

7

 

 

2.2.1

The Jacobi Method

:

:

:

:

:

:

:

:

: : : : : : : : : : : : : : : :

8

 

 

2.2.2

The Gauss-Seidel Method

:

:

:

:

:

: : : : : : : : : : : : : : : :

9

2.2.3The Successive Overrelaxation Method : : : : : : : : : : : : : : 10

2.2.4The Symmetric Successive Overrelaxation Method : : : : : : : 12

2.2.5 Notes and References : : : : : : : : : : : : : : : : : : : : : : :

12

2.3Nonstationary Iterative Methods : : : : : : : : : : : : : : : : : : : : : 14

2.3.1Conjugate Gradient Method (CG) : : : : : : : : : : : : : : : : 14

2.3.2MINRES and SYMMLQ : : : : : : : : : : : : : : : : : : : : : : 17

2.3.3CG on the Normal Equations, CGNE and CGNR : : : : : : : : 18

2.3.4

Generalized Minimal Residual (GMRES)

 

: :

: : : :

: :

:

: : :

19

2.3.5

BiConjugate Gradient (BiCG)

: :

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

21

2.3.6

Quasi-Minimal Residual (QMR)

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

23

2.3.7Conjugate Gradient Squared Method (CGS) : : : : : : : : : : : 25

2.3.8BiConjugate Gradient Stabilized (Bi-CGSTAB) : : : : : : : : : 27

2.3.9Chebyshev Iteration : : : : : : : : : : : : : : : : : : : : : : : : 28

2.4 Computational Aspects of the Methods : : : : : : : : : : : : : : : : : 30

2.5A short history of Krylov methods : : : : : : : : : : : : : : : : : : : : 34

2.6

Survey of recent Krylov methods

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

35

3 Preconditioners

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

39

3.1

The why and how : : : : : : : : :

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

39

3.1.1Cost trade-o : : : : : : : : : : : : : : : : : : : : : : : : : : : : 39

3.1.2 Left and right preconditioning

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

40

3.2 Jacobi Preconditioning : : : : : : : :

: :

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

41

3.2.1Block Jacobi Methods : : : : : : : : : : : : : : : : : : : : : : : 41

xi

xii

CONTENTS

3.2.2

Discussion : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 42

3.3SSOR preconditioning : : : : : : : : : : : : : : : : : : : : : : : : : : : 42

3.4 Incomplete Factorization Preconditioners : : : : : : : : : : : : : : : :

43

3.4.1Creating an incomplete factorization : : : : : : : : : : : : : : : 43

3.4.2Point incomplete factorizations : : : : : : : : : : : : : : : : : : 44

3.4.3 Block factorization methods : : : : : : : : : : : : : : : : : : : : 49

3.4.4Blocking over systems of partial di erential equations : : : : : 52

3.4.5Incomplete LQ factorizations : : : : : : : : : : : : : : : : : : : 52

3.5

Polynomial preconditioners

:

: : : : : : : :

:

 

:

:

:

:

:

:

: : : : : : : :

52

3.6

Other preconditioners

:

:

: :

: : : : : : : :

:

 

:

:

:

:

:

:

: : : : : : : :

53

 

3.6.1 Preconditioning by the symmetric part :

:

:

:

:

:

: : : : : : : :

53

 

3.6.2

The use of fast solvers

: : : : : : : :

:

 

:

:

:

:

:

:

: : : : : : : :

54

 

3.6.3

Alternating Direction Implicit methods

 

:

:

:

:

:

: : : : : : : :

54

4 Related Issues

 

 

 

 

 

 

 

 

 

 

 

 

 

 

57

4.1

Complex Systems : : : : : : : : : : : : : : :

:

:

:

:

: :

: : : : : : : : :

57

4.2

Stopping Criteria : : : : : : : : : : : : : : :

:

:

:

:

: :

: : : : : : : : :

57

 

4.2.1 More Details about Stopping Criteria

 

 

:

:

:

:

:

:

: : : : : : : :

58

 

4.2.2

When r(i) or

 

r(i)

k

is not readily available :

:

:

:

: : : : : : : :

61

 

4.2.3

 

k;1

: :

: : : : : : : :

:

 

:

:

:

:

:

:

: : : : : : : :

62

 

Estimating kA

k

 

 

4.2.4 Stopping when progress is no longer being made

 

: : : : : : : :

62

 

4.2.5 Accounting for oating point errors :

:

 

:

:

:

:

:

: : : : : : : : :

63

4.3

Data Structures : : : : : : : :

: : : : : : : :

:

 

:

:

:

:

:

:

: : : : : : : :

63

4.3.1Survey of Sparse Matrix Storage Formats : : : : : : : : : : : : 64

4.3.2 Matrix vector products : : : : : : : : : : : : : : : : : : : : : :

68

4.3.3Sparse Incomplete Factorizations : : : : : : : : : : : : : : : : : 71

4.4 Parallelism : : : : : :

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

76

4.4.1 Inner products

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

76

4.4.2Vector updates : : : : : : : : : : : : : : : : : : : : : : : : : : : 78

4.4.3 Matrix-vector products : : : : : : : : : : : : : : : : : : : : : :

78

4.4.4Preconditioning : : : : : : : : : : : : : : : : : : : : : : : : : : : 79

4.4.5Wavefronts in the Gauss-Seidel and Conjugate Gradient methods 80

4.4.6 Blocked operations in the GMRES method : : : : : : : : : : :

80

5 Remaining topics

83

5.1The Lanczos Connection : : : : : : : : : : : : : : : : : : : : : : : : : : 83

5.2 Block and s-step Iterative Methods : : : : : : : : : : : : : : : : : : : : 84

5.3Reduced System Preconditioning : : : : : : : : : : : : : : : : : : : : : 85

5.4 Domain Decomposition Methods : : : : :

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

86

5.4.1 Overlapping Subdomain Methods :

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

87

5.4.2Non-overlapping Subdomain Methods : : : : : : : : : : : : : : 88

 

5.4.3 Further Remarks

:

:

: :

:

: :

: :

: : :

: :

: : :

:

:

: :

: :

: : :

90

5.5

Multigrid Methods : : :

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

91

5.6

Row Projection Methods :

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

:

92

A Obtaining the Software

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

95

B Overview of the BLAS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

97

CONTENTS

xiii

C Glossary

99

C.1 Notation : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

104

xiv

CONTENTS

List of Figures

2.1 The Jacobi Method : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

9

2.2The Gauss-Seidel Method : : : : : : : : : : : : : : : : : : : : : : : : : 10

2.3The SOR Method : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 11

2.4The SSOR Method : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 13

2.5The Preconditioned Conjugate Gradient Method : : : : : : : : : : : : 15

2.6 The Preconditioned GMRES(m) Method : : : : : : : : : : : : : : : : 20

2.7The Preconditioned BiConjugate Gradient Method : : : : : : : : : : : 22

2.8The Preconditioned Quasi Minimal Residual Method without Look-ahead 24

2.9The Preconditioned Conjugate Gradient Squared Method : : : : : : : 26

2.10The Preconditioned BiConjugate Gradient Stabilized Method : : : : : 27

2.11The Preconditioned Chebyshev Method : : : : : : : : : : : : : : : : : 30

3.1 Preconditioner solve of a system Mx = y, with M = LU : : : : : : : : 44

3.2Preconditioner solve of a system Mx = y, with M = (D + L)D;1(D +

U) = (D + L)(I + D;1U ). : : : : : : : : : : : : : : : : : : : : : : : : : 44

3.3Construction of a D-ILU incomplete factorization preconditioner, stor-

ing the inverses of the pivots : : : : : : : : : : : : : : : : : : : : : : :

46

3.4Wavefront solution of (D + L)x = u from a central di erence problem

 

n points. : : : : : : : : : : : : : : : : :

: : : : : :

48

 

(p)

M

;1

 

3.5 Preconditioning step algorithm for a Neumann expansion M

 

 

 

of an incomplete factorization M = (I + L)D(I + U). : : :

: : : : : :

49

3.6Block version of a D-ILU factorization : : : : : : : : : : : : : : : : : : 50

3.7 Algorithm for approximating the inverse of a banded matrix : : : : : :

50

3.8Incomplete block factorization of a block tridiagonal matrix : : : : : : 51

4.1 Pro le of a nonsymmetric skyline or variable-band matrix. : : : : : : :

69

4.2A rearrangement of Conjugate Gradient for parallelism : : : : : : : : : 77

xv

xvi

LIST OF FIGURES

Chapter 1

Introduction

Which of the following statements is true?

Users want \black box" software that they can use with complete con dence for general problem classes without having to understand the ne algorithmic details.

Users want to be able to tune data structures for a particular application, even if the software is not as reliable as that provided for general methods.

It turns out both are true, for di erent groups of users.

Traditionally, users have asked for and been provided with black box software in the form of mathematical libraries such as LAPACK, LINPACK, NAG, and IMSL. More recently, the high-performance community has discovered that they must write custom software for their problem. Their reasons include inadequate functionality of existing software libraries, data structures that are not natural or convenient for a particular problem, and overly general software that sacri ces too much performance when applied to a special case of interest.

Can we meet the needs of both groups of users? We believe we can. Accordingly, in this book, we introduce the use of templates. A template is a description of a general algorithm rather than the executable object code or the source code more commonly found in a conventional software library. Nevertheless, although templates are general descriptions of key algorithms, they o er whatever degree of customization the user may desire. For example, they can be con gured for the speci c data structure of a problem or for the speci c computing system on which the problem is to run.

We focus on the use of iterative methods for solving large sparse systems of linear equations.

Many methods exist for solving such problems. The trick is to nd the most e ective method for the problem at hand. Unfortunately, a method that works well for one problem type may not work as well for another. Indeed, it may not work at all.

Thus, besides providing templates, we suggest how to choose and implement an e ective method, and how to specialize a method to speci c matrix types. We restrict ourselves to iterative methods, which work by repeatedly improving an approximate solution until it is accurate enough. These methods access the coe cient matrix A of

1

2

CHAPTER 1. INTRODUCTION

the linear system only via the matrix-vector product y = A x (and perhaps z = AT x). Thus the user need only supply a subroutine for computing y (and perhaps z) given x, which permits full exploitation of the sparsity or other special structure of A.

We believe that after reading this book, applications developers will be able to use templates to get their program running on a parallel machine quickly. Nonspecialists will know how to choose and implement an approach to solve a particular problem. Specialists will be able to assemble and modify their codes|without having to make the huge investment that has, up to now, been required to tune large-scale applications for each particular machine. Finally, we hope that all users will gain a better understanding of the algorithms employed. While education has not been one of the traditional goals of mathematical software, we believe that our approach will go a long way in providing such a valuable service.

1.1Why Use Templates?

Templates o er three signi cant advantages. First, templates are general and reusable. Thus, they can simplify ports to diverse machines. This feature is important given the diversity of parallel architectures.

Second, templates exploit the expertise of two distinct groups. The expert numerical analyst creates a template re ecting in-depth knowledge of a speci c numerical technique. The computational scientist then provides \value-added" capability to the general template description, customizing it for speci c contexts or applications needs.

And third, templates are not language speci c. Rather, they are displayed in an Algol-like structure, which is readily translatable into the target language such as FORTRAN (with the use of the Basic Linear Algebra Subprograms, or BLAS, whenever possible) and C. By using these familiar styles, we believe that the users will have trust in the algorithms. We also hope that users will gain a better understanding of numerical techniques and parallel programming.

For each template, we provide some or all of the following:

a mathematical description of the ow of the iteration

discussion of convergence and stopping criteria

suggestions for applying a method to special matrix types (e.g., banded systems)

advice for tuning (for example, which preconditioners are applicable and which are not)

tips on parallel implementations and

hints as to when to use a method, and why.

For each of the templates, the following can be obtained via electronic mail.

a MATLAB implementation based on dense matrices

a FORTRAN-77 program with calls to BLAS1

1For a discussion of BLAS as building blocks, see [69, 70, 71, 144] and LAPACK routines [3]. Also, see Appendix B.

1.2. WHAT METHODS ARE COVERED?

3

a C++ template implementation for matrix/vector classes. See Appendix A for details.

1.2What Methods Are Covered?

Many iterative methods have been developed and it is impossible to cover them all. We chose the methods below either because they illustrate the historical development of iterative methods, or because they represent the current state-of-the-art for solving large sparse linear systems. The methods we discuss are:

1.Jacobi

2.Gauss-Seidel

3.Successive Over-Relaxation (SOR)

4.Symmetric Successive Over-Relaxation (SSOR)

5.Conjugate Gradient (CG)

6.Minimal Residual (MINRES) and Symmetric LQ (SYMMLQ)

7.Conjugate Gradients on the Normal Equations (CGNE and CGNR)

8.Generalized Minimal Residual (GMRES)

9.Biconjugate Gradient (BiCG)

10.Quasi-Minimal Residual (QMR)

11.Conjugate Gradient Squared (CGS)

12.Biconjugate Gradient Stabilized (Bi-CGSTAB)

13.Chebyshev Iteration

For each method we present a general description, including a discussion of the history of the method and numerous references to the literature. We also give the mathematical conditions for selecting a given method.

We do not intend to write a \cookbook", and have deliberately avoided the words \numerical recipes", because these phrases imply that our algorithms can be used blindly without knowledge of the system of equations. The state of the art in iterative methods does not permit this: some knowledge about the linear system is needed to guarantee convergence of these algorithms, and generally the more that is known the more the algorithm can be tuned. Thus, we have chosen to present an algorithmic outline, with guidelines for choosing a method and implementing it on particular kinds of high-performance machines. We also discuss the use of preconditioners and relevant data storage issues.