1 /*
2    ARPACK++ v1.2 2/20/2000
3    c++ interface to ARPACK code.
4 
5    MODULE LCompShf.cc.
6    Example program that illustrates how to solve a complex standard
7    eigenvalue problem in shift and invert mode using the
8    ARluCompStdEig class.
9 
10    1) Problem description:
11 
12       In this example we try to solve A*x = x*lambda in shift and invert
13       mode, where A is derived from the central difference discretization
14       of the 1-dimensional convection-diffusion operator
15                         (d^2u/dx^2) + rho*(du/dx)
16       on the interval [0,1] with zero Dirichlet boundary conditions.
17 
18    2) Data structure used to represent matrix A:
19 
20       {nnz, irow, pcol, A}: matrix A data in CSC format.
21 
22    3) Library called by this example:
23 
24       The SuperLU package is called by ARluCompStdEig to solve
25       some linear systems involving (A-sigma*I). This is needed to
26       implement the shift and invert strategy.
27 
28    4) Included header files:
29 
30       File             Contents
31       -----------      ---------------------------------------------
32       lcmatrxb.h       CompMatrixB, a function that generates matrix
33                        A in CSC format.
34       arlnsmat.h       The ARluNonSymMatrix class definition.
35       arlscomp.h       The ARluCompStdEig class definition.
36       lcompsol.h       The Solution function.
37       arcomp.h         The "arcomplex" (complex) type definition.
38 
39    5) ARPACK Authors:
40 
41       Richard Lehoucq
42       Kristyn Maschhoff
43       Danny Sorensen
44       Chao Yang
45       Dept. of Computational & Applied Mathematics
46       Rice University
47       Houston, Texas
48 */
49 
50 #include "arcomp.h"
51 #include "arlnsmat.h"
52 #include "arlscomp.h"
53 #include "lcmatrxb.h"
54 #include "lcompsol.h"
55 
56 
main()57 int main()
58 {
59 
60   // Defining variables;
61 
62   int                n;     // Dimension of the problem.
63   int                nnz;   // Number of nonzero elements in A.
64   int*               irow;  // pointer to an array that stores the row
65                             // indices of the nonzeros in A.
66   int*               pcol;  // pointer to an array of pointers to the
67                             // beginning of each column of A in valA.
68   arcomplex<double>  rho;   // parameter used to define A.
69   arcomplex<double>* valA;  // pointer to an array that stores the
70                             // nonzero elements of A.
71 
72   // Creating a complex matrix.
73 
74   n   = 100;
75   rho = 10.0;
76   CompMatrixB(n, rho, nnz, valA, irow, pcol);
77   ARluNonSymMatrix<arcomplex<double>, double> A(n, nnz, valA, irow, pcol);
78 
79   // Defining what we need: the four eigenvectors of F nearest to 0.0.
80 
81   ARluCompStdEig<double> dprob(4L, A, arcomplex<double>(0.0, 0.0));
82 
83   // Finding eigenvalues and eigenvectors.
84 
85   dprob.FindEigenvectors();
86 
87   // Printing solution.
88 
89   Solution(A, dprob);
90 
91 } // main.
92 
93