# NMath User's Guide

23.3 Using the Eigenvalue Server Classes (.NET, C#, CSharp, VB, Visual Basic, F#)

The NMath eigenvalue server classes construct instances of the eigenvalue classes (Section 23.2), allowing you greater control over how the eigenvalue decomposition is performed. Servers can be configured to compute eigenvalues only, or both eigenvalues and eigenvectors. In addition, servers can be configured to compute only the eigenvalues in a given range. A tolerance for the convergence of the algorithm may also be specified.

Constructing Eigenvalue Servers

Instances of the eigenvalue server classes are constructed using a default constructor, then configured as desired. For example, this code creates a default DoubleSymEigDecompServer:

Code Example – C# eigenvalue decomposition

var server = new DoubleSymEigDecompServer();

Code Example – VB eigenvalue decomposition

Dim Server As New DoubleSymEigDecompServer()

Configuring Eigenvalue Servers

All eigenvalue server classes provide properties and member functions for configuring the server after construction:

ComputeRightVectors gets and sets a boolean value indicating whether or not right eigenvectors should be computed (true by default).

ComputeLeftVectors gets and sets a boolean value indicating whether or not left eigenvectors should be computed (true by default).

ComputeAllEigenValues() configures a server to compute all eigenvalues.

ComputeEigenValueRange() configures a server to compute only the eigenvalues in a specified range. Only eigenvalues that are greater than the given lower bound and less than or equal to the given upper bound are computed.

Balance gets and sets the balance option, using a value from the BalanceOption enumeration: None, Permute, Scale, Both. Balancing a matrix means permuting the rows and columns to make the matrix more nearly upper triangular, and applying a diagonal similarity transformation to make the rows and columns closer in norm and the condition numbers of the eigenvalues and eigenvectors smaller.

AbsTolerance gets and sets the absolute tolerance for each eigenvalue. An approximate eigenvalue is accepted as converged when it lies in an interval [a,b] of width less than or equal to AbsTolerance + epsilon * max(abs(a),abs(b)), where epsilon is machine precision. If AbsTolerance is set less than or equal to zero then epsilon * ||T|| is used, where T is the tridiagonal matrix obtained by reducing the decomposed matrix to tridiagonal form, and ||T|| is the one-norm of T.

NOTE—Eigenvalue ranges and tolerance are only provided for symmetric and Hermi­tian eigenvalue server classes. For general matrices, eigenvalues may be complex, and hence non-orderable.

For example, this code creates a default DoubleSymEigDecompServer, then configures the object not to compute eigenvectors, and only to compute eigenvalues within a specified range:

Code Example – C# eigenvalue decomposition

var server = new FloatSymEigDecompServer();
server.ComputeLeftVectors = false;
server.ComputeRightVectors = false;
server.ComputeEigenValueRange( 0, 3 );

Code Example – VB eigenvalue decomposition

Dim Server As New FloatSymEigDecompServer()
Server.ComputeLeftVectors = False
Server.ComputeRightVectors = False
Server.ComputeEigenValueRange(0, 3)

Creating Eigenvalue Objects from a Server

Eigenvalue server objects are used to create instances of the associated eigenvalue class, using the Factor() method. For instance, this code creates a FloatEigDecomp object from a configured FloatEigDecompServer:

Code Example – C# eigenvalue decomposition

var eigServer = new FloatEigDecompServer();
eigServer.ComputeLeftVectors = false;
eigServer.ComputeRightVectors = false;
eigServer.Balance = BalanceOption.Permute;
FloatEigDecomp decomp = eigServer.Factor( A );

Code Example – VB eigenvalue decomposition

Dim EigServer As New FloatEigDecompServer()
eigServer.ComputeLeftVectors = False
eigServer.ComputeRightVectors = False
eigServer.Balance = BalanceOption.Permute
Dim Decomp = EigServer.Factor(A)

Top

Top