1 /*
2    ARPACK++ v1.2 2/18/2000
3    c++ interface to ARPACK code.
4 
5    MODULE ACompReg.cc.
6    Example program that illustrates how to solve a complex standard
7    eigenvalue problem in regular mode using the AREig function.
8 
9    1) Problem description:
10 
11       In this example we try to solve A*x = x*lambda in regular mode,
12       where A is obtained from the standard central difference
13       discretization of the convection-diffusion operator
14                     (Laplacian u) + rho*(du / dx)
15       on the unit squre [0,1]x[0,1] with zero Dirichlet boundary
16       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       lcmatrxa.h       CompMatrixA, a function that generates matrix
27                        A in CSC format.
28       areig.h          The AREig function definition.
29       acompsol.h       The Solution function.
30       arcomp.h         The "arcomplex" (complex) type definition.
31 
32    4) ARPACK Authors:
33 
34       Richard Lehoucq
35       Kristyn Maschhoff
36       Danny Sorensen
37       Chao Yang
38       Dept. of Computational & Applied Mathematics
39       Rice University
40       Houston, Texas
41 */
42 
43 #include "arcomp.h"
44 #include "areig.h"
45 #include "lcmatrxa.h"
46 #include "acompsol.h"
47 
48 
main()49 int main()
50 {
51 
52   // Defining variables;
53 
54   int               nx;
55   int               n;            // Dimension of the problem.
56   int               nnz;          // Number of nonzero elements in A.
57   int               nconv;        // Number of "converged" eigenvalues.
58   int*              irow;         // pointer to an array that stores the row
59                                   // indices of the nonzeros in A.
60   int*              pcol;         // pointer to an array of pointers to the
61                                   // beginning of each column in vector A.
62   arcomplex<double> *A;           // pointer to an array that stores the
63                                   // nonzero elements of A.
64   arcomplex<double> EigVal[101];  // Eigenvalues.
65   arcomplex<double> EigVec[1001]; // Eigenvectors stored sequentially.
66 
67   // Creating a complex matrix.
68 
69   nx = 10;
70   n  =  nx*nx;
71   CompMatrixA(nx, nnz, A, irow, pcol);
72 
73   // Finding the four eigenvalues of A with largest magnitude
74   // and the related eigenvectors.
75 
76   nconv = AREig(EigVal, EigVec, n, nnz, A, irow, pcol, 4);
77 
78   // Printing solution.
79 
80   Solution(nconv, n, nnz, A, irow, pcol, EigVal, EigVec);
81 
82 } // main
83