Computational Physics - Department of Physics

(Axel Boer) #1

Chapter 6


Linear Algebra


AbstractThis chapter introduces several matrix related topics, from the solution of linear
equations, computing determinants, conjugate-gradient methods, spline interpolation to effi-
cient handling of matrices


6.1 Introduction


In this chapter we deal with basic matrix operations, such asthe solution of linear equations,
calculate the inverse of a matrix, its determinant etc. The solution of linear equations is an
important part of numerical mathematics and arises in many applications in the sciences.
Here we focus in particular on so-called direct or elimination methods, which are in principle
determined through a finite number of arithmetic operations. Iterative methods will also be
discussed.
This chapter serves also the purpose of introducing important programming details such
as handling memory allocation for matrices and the usage of the libraries which follow these
lectures.
The algorithms we describe and their original source codes are taken from the widely used
software package LAPACK [26], which follows two other popular packages developed in the
1970s, namely EISPACK and LINPACK. The latter was developedfor linear equations and
least square problems while the former was developed for solving symmetric, unsymmetric
and generalized eigenvalue problems. From LAPACK’s websitehttp://www.netlib.orgit is
possible to download for free all source codes from this library. Both C++ and Fortran ver-
sions are available. Another important library is BLAS [27], which stands for Basic Linear
Algebra Subprogram. It contains efficient codes for algebraic operations on vectors, matrices
and vectors and matrices. Basically all modern supercomputer include this library, with effi-
cient algorithms. Else, Matlab offers a very efficient programming environment for dealing
with matrices. The classic text from where we have taken mostof the formalism exposed here
is the book on matrix computations by Golub and Van Loan [28].Good recent introductory
texts are Kincaid and Cheney [23] and Datta [29]. For more advanced ones see Trefethen and
Bau III [30], Kress [24] and Demmel [31]. Ref. [28] contains an extensive list of textbooks
on eigenvalue problems and linear algebra. LAPACK [26] contains also extensive listings to
the research literature on matrix computations. For the introduction of the auxiliary library
Blitz++ [32], which allows for a very efficient way of handling arrays in C++ we refer to the
online manual athttp://www.oonumerics.org. A library we highly recommend is Armadillo,
seehttp://arma.sourceforge.org. Armadillo is an open-source C++ linear algebra library
aiming towards a good balance between speed and ease of use. Integer, floating point and
complex numbers are supported, as well as a subset of trigonometric and statistics functions.


153
Free download pdf