ABSTRACT

Linear algebra is a fundamental building block of nearly every scientific software package: Adding vectors, calculating eigenvalues, and multiplying matrices underlie everything from molecular dynamics, to fluid mechanics, to finite element (FE) simulations. Due to the ubiquity of linear algebra in scientific computing, many new computational scientists may be tempted to write their own dot product routine, for example, when necessitated by their project. The purpose of this chapter is to show how to resist this temptation by providing an introduction to fast, free libraries for doing linear algebra that will save time and frustration. We discuss the Basic Linear Algebra Subprograms (BLAS), Linear Algebra Package (LAPACK), and Portable Extendable Toolkit for Scientific Computing (PETSc)

CONTENTS

15.1 Introduction ........................................................................................................................ 205 15.2 Choosing a Library ............................................................................................................ 206 15.3 BLAS .................................................................................................................................... 207

15.3.1 Vector Operations .................................................................................................. 208 15.3.2 Matrix-Vector Operations..................................................................................... 208 15.3.3 Matrix-Matrix Operations .................................................................................... 210

15.4 LAPACK .............................................................................................................................. 211 15.4.1 Other Storage Formats .......................................................................................... 212 15.4.2 Parallelism .............................................................................................................. 212

15.5 The PETSc Library for Parallel Linear Algebra ............................................................. 212 15.5.1 What Is in PETSc? .................................................................................................. 213 15.5.2 The PETSc Workflow ............................................................................................. 213 15.5.3 Parallelism .............................................................................................................. 214 15.5.4 Object Orientation ................................................................................................. 215 15.5.5 Worked-Out Examples .......................................................................................... 215

15.5.5.1 A Linear System Example ...................................................................... 215 15.5.5.2 A Finite Element Example ..................................................................... 216

15.5.6 PETSc Usage ........................................................................................................... 217 15.5.6.1 PETSc and Python ................................................................................... 217

15.5.7 Runtime Options .................................................................................................... 217 15.5.8 Profiling ................................................................................................................... 218 15.5.9 Debugging .............................................................................................................. 218

References ..................................................................................................................................... 218

linear algebra libraries, each of which provides capabilities for solving linear algebra problems of different sizes and structure.