ConicBundle
Matrix Classes (namespace CH_Matrix_Classes)

The package within the namespace CH_Matrix_Classes sets up a C++ linear algebra library consisting of several matrix classes and a few numerical routines. For historical reasons, it does not rely on any external linear algebra package but is completely self contained. For users, the most important classes are probably the various types of matrices

The external view and use of these matrices is roughly the same. Refer to the following subsections for the common concepts guiding the design of these classes.

Note, however, that not all concepts have yet been implemented in all matrix classes and some are in fact not realizable in all matrix classes. For this, consult the documentation of the single classes. The documentation of each matrix class is structured in the same way as in the list above (each topic above is listed there in two parts, one giving the functions that are (members) and one giving (friends) within this topic).

The matrix classes also follow a common design regarding

The number of sophisticated numerical linear algebra routines contained in this package is unfortunately, almost negligible. It includes, however, a rather well tested class of routines for the computation of a few extremal eigenvalues for large scale structured symmetric matrices, see Lanczos Interface and Classes.

Some convenient tools, that are independet of but used by the matrix library, are collected within the namespace CH_TOOLS. It contains inline implementations of a clock for timing, a random number generator and a heapsort template for sorting indices.

A design goal of the matrix classes was to keep the syntax rather intuitive for everybody who is acquainted with certain well known interactive numerical packages, and in particular to remove all difficulties of memory management and of keeping track of dimensions. So the hope is, that the use of the matrix classes will be quite easy (mainly as data structures and basis for numerical linear algebra, since most numerical routines are still missing).

In order to illustrate the ease of use by an example, we set up a symmetric random matrix, compute its eigenvalues and eigenvectors and display the corresponding matrices on standard output.

//******************************************************************************
//* Miniature Example in C++ for Computing an Eigenvalue Factorization *
//******************************************************************************
#include "matrix.hxx"
#include "symmat.hxx"
using namespace std;
using namespace CH_Matrix_Classes;
int main(void)
{
Integer n=7;
Matrix B;
B.rand(n,n);
Symmatrix A(B); //equivalent to: Symmatrix A=(B+transpose(B))/2.;
cout<<" Symmatrix A: ";
A.display(cout);
Matrix Lambda;
Matrix P;
A.eig(P,Lambda); //compute eigenvalue factorization
cout<<"\n Eigenvalues: ";
Lambda.display(cout);
cout<<"\n Eigenvectors: ";
P.display(cout);
cout<<"\n Test: "<<norm2((B+transpose(B))/2.-P*Diag(Lambda)*transpose(P))<<endl;
return 0;
}