Servers
An eigenvalue decomposition server object encapsulates the algorithm used to construct the decomposition. Server objects are very useful tools in object-oriented design; they tend to be especially useful in numerical applications due to the large number of parameters and the complexity associated with numerical algorithms. You can think of a server object as representing the same sort of thing as a regular C or C++ function, except that it is much more flexible. By including the traditional parameter list as part of an object's state, you can use member functions to set only those parameters that concern you. You can use inheritance to modify parts of algorithms that you want changed. You can have several instantiations of a server to represent the same algorithm, but with different parameters.
One of the most common reasons for using an eigenvalue server is that you require a specific algorithm for the computation. For example, if you know that
A is a positive definite matrix, you might want to use the server
RWSymPDQREigServer<double>, which uses a special variant of the QR algorithm especially designed for positive definite matrices. Here is an example program that does this:
#include <iostream>
#include <rw/lapack/symmat.h>
#include <rw/lapack/seigsrv.h>
int main()
{
RWSymMat<double> A;
std::cin >> A;
RWSymPDQREigServer<double> server; // 1
RWSymEigDecomp<double> decomp = server(A); // 2
std::cout << decomp.eigenValues() << std::endl;
std::cout << decomp.eigenVectors() << std::endl;
return 0;
}
Table 8 provides a list of symmetric eigenvalue servers available in the Linear Algebra Module. Some of these are described in more detail in following sections.
Table 8 – Eigenvalue servers in the Linear Algebra Module
Server | Function |
---|
| Abstract base class - commonalities implemented here |
| Basic QR method - this is the default |
| Positive definite QR - positive definite matrices only |
| Root free QR method |
| Bisection method to compute eigenvalues in a range |
| Bisection method to compute selected eigenvalues |