Meschach: Matrix Computations in C


Most of numerical analysis relies on algorithms for perfoming calculations on matrices and vectors. The operations most needed are ones which solve systems of linear equations, numerically computing the maximum or minimum of a function, or solving differential equations.

The Meschach library contains routines to address all of the basic operations for dealing with matrices and vectors, and a number of other issues as well. I do not claim that it contains every useful algorithm in numerical linear algebra, but it does provide a basis on which to build more advanced algorithms. The library is intended for people who know something of the 'C' programming language, something of how to solve the numerical problem they are faced with (which involves matrices and/or vectors) but don't want to have the hassle of building all the necessary operations from the ground up. I hope that researchers, mathematicians, engineers and programmers will find this library makes the task of developing and producing code for their numerical problems easier, and easier to maintain than would otherwise be possible.

To this end the source code is available to be perused, used and passed on without cost, while ensuring that the quality of the software is not compromised. The software is copyrighted; however, the copyright agreement follows in the footsteps of the Free Software Foundation in preventing abuse that occurs with totally "public domain" software.

This is not the first or only library of numerical routines in C. However, there are still a number of niches which have not been filled. Some of the currently available libraries are essentially translations of Fortran routines into C. Those that attempt to make use of C's features usually address a relatively small class of problems. There is a commercial package of C++ routines (and classes) for performing matrix computations, and NAG and IMSL are producing C versions of their libraries. None of these is "public domain".

The Meschach library makes extensive use of C's special features (pointers, memory allocation/deallocation, structures/records, low level operations) to ease use and ensure good performance. In addition, Meschach addresses the need for both dense and sparse matrix operations within a single framework.

There is another issue which needs to be addressed by a matrix library like this. At one end, libraries that are essentially translations from Fortran will make little use of memory allocation. At the other end, interactive matrix "calculators" such as MATLAB and MATCALC use memory allocation and garbage collection as a matter of course and have to interpret your "program". This latter approach is very flexible, but resource hungry. These matrix calculator programs were not designed to deal with large problems.

This matrix library is intended to provide a "middle ground" between efficient but inflexible Fortran-style programs, and flexible but resource hungry calculator/interpreter programs. When and how memory is allocated in Meschach can be controlled by using the allocation/deallocation and resizing routines; result matrices and vectors can be created dynamically when needed, or allocated once, and then used as a static array. Unnecessary memory allocation is avoided where necessary. This means that prototyping can often be done on MATLAB or MATCALC, and final code can be written that is efficient and can be incorporated into other C programs and routines without having to re-write all the basic routines from scratch.

This documentation describes Meschach 1.2 which has a number of improvements over previous versions of Meschach. Amongst these improvements are:

  • easier installation (at least on Unix machines).
  • complex numbers, vectors and matrices, including complex matrix factorisation.
  • band matrix structures, and band factorise and solve routines.
  • better control of static workspace arrays.
  • more iterative methods for large, sparse or structured matrices, and a comprehensive "iteration" data structure.
  • more consistent naming schemes.
  • matrix polynomials and exponentials.
  • extensible error handling.

Finally, we would like to thank all those at the University of Queensland Mathematics Department, at Opcom, and at the Australian National University for their interest in and comments on this matrix library. In particular, we would like to thank Martin Sharry, Michael Forbes, Phil Kilby, John Holt, Phil Pollett and Tony Watts at the University of Queensland, and Mike Osborne, Teresa Leyk at the Australian National University and Karen George from the University of Canberra. Email has become a significant part of work, and many people have pointed out bugs, inconsistencies and improvements to Meschach by email. These people include Ajay Shah of the University of Southern California, Dov Grobgeld of the Weizmann Institute, John Edstrom of the Universtiy of Calgary, Eric Grosse, one of the netlib organisers, Ole Saether of somewhere in Norway, Alfred Thiele and Pierre Asselin of Carnegie-Mellon University, Daniel Polani of the University of Mainz, Marian Slodicka of Slovakia, Kaifu Wu of Pomona, Hidetoshi Shimodaira of the University of Tokyo, Eng Siong of Edinburgh, Hirokawa Rui of the University of Tokyo, Marko Slyz of the University of Michigan, and Brook Milligan of the University of Texas. This list is only partial, and there are many others who have corresponded with me on details about Meschach and the like. Finally my thanks go to all those that have had to struggle with compilers and other things to get Meschach to work.


David E. Stewart and Zbigniew Leyk


Chapter Page no
1 - Meschach: Matrix Computations in C (PDF, 28672KB)
David E. Stewart and Zbigniew Leyk

Printed copy

Price: $33.00 Buy now


Volume 32


1 Jan 1993


The Australian National University (Canberra)

Updated:  23 March 2017/Responsible Officer:  Director/Page Contact:  School Manager