1 /*
2    ARPACK++ v1.2 2/18/2000
3    c++ interface to ARPACK code.
4 
5    MODULE ANSymReg.cc.
6    Example program that illustrates how to solve a real
7    nonsymmetric standard eigenvalue problem in regular mode
8    using the AREig function.
9 
10    1) Problem description:
11 
12       In this example we try to solve A*x = x*lambda in regular mode,
13       where A is derived from the standard central difference
14       discretization of the 2-dimensional convection-diffusion operator
15                        (Laplacian u) + rho*(du/dx)
16       on a unit square with zero Dirichlet boundary conditions.
17 
18    2) Data structure used to represent matrix A:
19 
20       {nnzA, irowA, pcolA, valA}: matrix A data in CSC format.
21 
22    3) Included header files:
23 
24       File             Contents
25       -----------      -------------------------------------------
26       lnmatrxb.h       BlockTridMatrix, a function that generates
27                        matrix A in CSC format.
28       areig.h          The AREig function definition.
29       ansymsol.h       The Solution function.
30 
31    4) ARPACK Authors:
32 
33       Richard Lehoucq
34       Kristyn Maschhoff
35       Danny Sorensen
36       Chao Yang
37       Dept. of Computational & Applied Mathematics
38       Rice University
39       Houston, Texas
40 */
41 
42 #include "lnmatrxb.h"
43 #include "areig.h"
44 #include "ansymsol.h"
45 
46 
main()47 int main()
48 {
49 
50   // Defining variables;
51 
52   int     nx;
53   int     n;           // Dimension of the problem.
54   int     nconv;       // Number of "converged" eigenvalues.
55   int     nnz;         // Number of nonzero elements in A.
56   int*    irow;        // pointer to an array that stores the row
57                        // indices of the nonzeros in A.
58   int*    pcol;        // pointer to an array of pointers to the
59                        // beginning of each column of A in vector A.
60   double* A;           // pointer to an array that stores the
61                        // nonzero elements of A.
62   double EigValR[101]; // Real part of the eigenvalues.
63   double EigValI[101]; // Imaginary part of the eigenvalues.
64   double EigVec[1001]; // Eigenvectors stored sequentially.
65 
66   // Creating a double precision 100x100 matrix.
67 
68   nx = 10;
69   BlockTridMatrix(nx, n, nnz, A, irow, pcol);
70 
71   // Finding the four eigenvalues with largest magnitude and
72   // the related eigenvectors.
73 
74   nconv = AREig(EigValR, EigValI, EigVec, n, nnz, A, irow, pcol, 4);
75 
76   // Printing solution.
77 
78   Solution(nconv, n, nnz, A, irow, pcol, EigValR, EigValI, EigVec);
79 
80 } // main.
81