1 /*
2 ARPACK++ v1.2 2/20/2000
3 c++ interface to ARPACK code.
4
5 MODULE UNSymReg.cc.
6 Example program that illustrates how to solve a real
7 nonsymmetric standard eigenvalue problem in regular mode
8 using the ARluNonSymStdEig class.
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 {nnz, irow, pcol, A}: 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 arunsmat.h The ARumNonSymMatrix class definition.
29 arusnsym.h The ARluNonSymStdEig class definition.
30 lnsymsol.h The Solution function.
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 "lnmatrxb.h"
44 #include "arunsmat.h"
45 #include "arusnsym.h"
46 #include "lnsymsol.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* irow; // pointer to an array that stores the row
58 // indices of the nonzeros in A.
59 int* pcol; // pointer to an array of pointers to the
60 // beginning of each column of A in vector A.
61 double* A; // pointer to an array that stores the
62 // nonzero elements of A.
63
64 // Creating a 100x100 matrix.
65
66 nx = 10;
67 BlockTridMatrix(nx, n, nnz, A, irow, pcol);
68 ARumNonSymMatrix<double, double> matrix(n, nnz, A, irow, pcol);
69
70 // Defining what we need: the four eigenvectors of A with largest magnitude.
71
72 ARluNonSymStdEig<double> dprob(4, matrix);
73
74 // Finding eigenvalues and eigenvectors.
75
76 dprob.FindEigenvectors();
77
78 // Printing solution.
79
80 Solution(matrix, dprob);
81
82 } // main.
83
84