comparison libcruft/arpack/docs/ex-nonsym.doc @ 12274:9f5d2ef078e8 release-3-4-x

import ARPACK sources to libcruft from Debian package libarpack2 2.1+parpack96.dfsg-3+b1
author John W. Eaton <jwe@octave.org>
date Fri, 28 Jan 2011 14:04:33 -0500
parents
children
comparison
equal deleted inserted replaced
12273:83133b5bf392 12274:9f5d2ef078e8
1 c-----------------------------------------------------------------------
2 c
3 c\Example-1
4 c ... Suppose want to solve A*x = lambda*x in regular mode
5 c ... so OP = A and B = I.
6 c ... Assume "call matvecA(n,x,y)" computes y = A*x
7 c ... Assume exact shifts are used
8 c ...
9 c ido = 0
10 c iparam(7) = 1
11 c
12 c %------------------------------------%
13 c | Beginning of reverse communication |
14 c %------------------------------------%
15 c 10 continue
16 c call _naupd ( ido, 'I', n, which, nev, tol, resid, ncv, v, ldv,
17 c & iparam, ipntr, workd, workl, lworkl, info )
18 c if (ido .eq. -1 .or. ido .eq. 1) then
19 c call matvecA (n, workd(ipntr(1)), workd(ipntr(2)))
20 c go to 10
21 c end if
22 c %------------------------------%
23 c | End of Reverse communication |
24 c %------------------------------%
25 c
26 c ... call _neupd to postprocess
27 c ... want the Ritz vectors set rvec = .true. else rvec = .false.
28 c call _neupd ( rvec, 'All', select, d, d(1,2), v, ldv,
29 c & sigmar, sigmai, workev, bmat, n, which, nev, tol,
30 c & resid, ncv, v, ldv, iparam, ipntr, workd, workl,
31 c & lworkl, info )
32 c stop
33 c end
34 c
35 c\Example-2
36 c ... Suppose want to solve A*x = lambda*x in shift-invert mode
37 c ... so OP = inv[A - sigma*I] and B = I, sigma has zero
38 c ... imaginary part
39 c ... Assume "call solve(n,rhs,x)" solves [A - sigma*I]*x = rhs
40 c ... Assume exact shifts are used
41 c ...
42 c ido = 0
43 c iaparam(7) = 3
44 c
45 c %------------------------------------%
46 c | Beginning of reverse communication |
47 c %------------------------------------%
48 c 10 continue
49 c call _naupd ( ido, 'I', n, which, nev, tol, resid, ncv, v, ldv,
50 c & iparam, ipntr, workd, workl, lworkl, info )
51 c if (ido .eq. -1 .or. ido .eq. 1) then
52 c call solve (n, workd(ipntr(1)), workd(ipntr(2)))
53 c go to 10
54 c end if
55 c %------------------------------%
56 c | End of Reverse communication |
57 c %------------------------------%
58 c
59 c ... call _neupd to postprocess
60 c ... want the Ritz vectors set rvec = .true. else rvec = .false.
61 c call _neupd ( rvec, 'All', select, d, d(1,2), v, ldv,
62 c & sigmar, sigmai, workev, bmat, n, which, nev, tol,
63 c & resid, ncv, v, ldv, iparam, ipntr, workd, workl,
64 c & lworkl, info )
65 c stop
66 c end
67 c
68 c\Example-3
69 c ... Suppose want to solve A*x = lambda*M*x in regular mode
70 c ... so OP = inv[M]*A and B = M.
71 c ... Assume "call matvecM(n,x,y)" computes y = M*x
72 c ... Assume "call matvecA(n,x,y)" computes y = A*x
73 c ... Assume "call solveM(n,rhs,x)" solves M*x = rhs
74 c ... Assume user will supplied shifts
75 c ...
76 c ido = 0
77 c iparam(7) = 2
78 c
79 c %------------------------------------%
80 c | Beginning of reverse communication |
81 c %------------------------------------%
82 c 10 continue
83 c call _naupd ( ido, 'G', n, which, nev, tol, resid, ncv, v, ldv,
84 c & iparam, ipntr, workd, workl, lworkl, info )
85 c if (ido .eq. -1 .or. ido .eq. 1) then
86 c call matvecA (n, workd(ipntr(1)), temp_array)
87 c call solveM (n, temp_array, workd(ipntr(2)))
88 c go to 10
89 c else if (ido .eq. 2) then
90 c call matvecM (n, workd(ipntr(1)), workd(ipntr(2)))
91 c go to 10
92 c
93 c ... delete this last conditional if want to use exact shifts
94 c else if (ido .eq. 3) then
95 c ... compute shifts and put in workl starting from the position
96 c ... pointed by ipntr(14).
97 c np = iparam(8)
98 c call scopy (np, shifts, 1, workl(ipntr(14), 1)
99 c go to 10
100 c end if
101 c %------------------------------%
102 c | End of Reverse communication |
103 c %------------------------------%
104 c
105 c ... call _neupd to postprocess
106 c ... want the Ritz vectors set rvec = .true. else rvec = .false.
107 c call _neupd ( rvec, 'All', select, d, d(1,2), v, ldv,
108 c & sigmar, sigmai, workev, bmat, n, which, nev, tol,
109 c & resid, ncv, v, ldv, iparam, ipntr, workd, workl,
110 c & lworkl, info )
111 c stop
112 c end
113 c
114 c\Example-4
115 c ... Suppose want to solve A*x = lambda*M*x in shift-invert mode
116 c ... so OP = inv[A - sigma*M]*M and B = M, sigma has zero
117 c ... imaginary part
118 c ... Assume "call matvecM(n,x,y)" computes y = M*x
119 c ... Assume "call solve(n,rhs,x)" solves [A - sigma*M]*x = rhs
120 c ... Assume exact shifts are used
121 c ...
122 c ido = 0
123 c iparam(7) = 3
124 c
125 c %------------------------------------%
126 c | Beginning of reverse communication |
127 c %------------------------------------%
128 c 10 continue
129 c call _naupd ( ido, 'G', n, which, nev, tol, resid, ncv, v, ldv,
130 c & iparam, ipntr, workd, workl, lworkl, info )
131 c if (ido .eq. -1) then
132 c call matvecM (n, workd(ipntr(1)), temp_array)
133 c call solve (n, temp_array, workd(ipntr(2)))
134 c go to 10
135 c else if (ido .eq. 1) then
136 c call solve (n, workd(ipntr(3)), workd(ipntr(2)))
137 c go to 10
138 c else if (ido .eq. 2) then
139 c call matvecM (n, workd(ipntr(1)), workd(ipntr(2)))
140 c go to 10
141 c end if
142 c %------------------------------%
143 c | End of Reverse communication |
144 c %------------------------------%
145 c
146 c ... call _neupd to postprocess
147 c ... want the Ritz vectors set rvec = .true. else rvec = .false.
148 c call _neupd ( rvec, 'All', select, d, d(1,2), v, ldv,
149 c & sigmar, sigmai, workev, bmat, n, which, nev, tol,
150 c & resid, ncv, v, ldv, iparam, ipntr, workd, workl,
151 c & lworkl, info )
152 c stop
153 c end
154 c
155 c\Example-5
156 c ... Suppose want to solve A*x = lambda*M*x in shift-invert mode
157 c ... So OP = Real_Part{inv[A-SIGMA*M]*M and B=M, sigma has
158 c ... nonzero imaginary part
159 c ... Assume "call matvecM(n,x,y)" computes y = M*x
160 c ... Assume "call solve(n,rhs,x)" solves [A - sigma*M]*x = rhs
161 c ... in complex arithmetic
162 c ... Assume exact shifts are used
163 c ...
164 c ido = 0
165 c iparam(7) = 3
166 c
167 c %------------------------------------%
168 c | Beginning of reverse communication |
169 c %------------------------------------%
170 c 10 continue
171 c call _naupd ( ido, 'G', n, which, nev, tol, resid, ncv, v, ldv,
172 c & iparam, ipntr, workd, workl, lworkl, info )
173 c if (ido .eq. -1) then
174 c call matvecM (n, workd(ipntr(1)), temp_array)
175 c call solve(n, temp_array, complex_array)
176 c do i = 1, n
177 c workd(ipntr(2)+i-1) = real(complex_array(i))
178 c end do
179 c go to 10
180 c else if (ido .eq. 1) then
181 c call solve (n, workd(ipntr(3)), complex_array)
182 c do i = 1, n
183 c workd(ipntr(2)+i-1) = real(complex_array(i))
184 c end do
185 c go to 10
186 c else if (ido .eq. 2) then
187 c call matvecM (n, workd(ipntr(1)), workd(ipntr(2)))
188 c go to 10
189 c end if
190 c %------------------------------%
191 c | End of Reverse communication |
192 c %------------------------------%
193 c
194 c ... call _neupd to postprocess.
195 c ... want the Ritz vectors set rvec = .true. else rvec = .false.
196 c call _neupd ( rvec, 'All', select, d, d(1,2), v, ldv,
197 c & sigmar, sigmai, workev, bmat, n, which, nev, tol,
198 c & resid, ncv, v, ldv, iparam, ipntr, workd, workl,
199 c & lworkl, info )
200 c ... Use Rayleigh quotient to transform d(:,1) and d(:,2)
201 c to the approximation to the original problem.
202 c stop
203 c end
204 c
205 c\Example-6
206 c ... Suppose want to solve A*x = lambda*M*x in shift-invert mode
207 c ... So OP = Imaginary_Part{inv[A-SIGMA*M]*M and B=M, sigma must
208 c ... have nonzero imaginary part
209 c ... Assume "call matvecM(n,x,y)" computes y = M*x
210 c ... Assume "call solve(n,rhs,x)" solves [A - sigma*M]*x = rhs
211 c ... in complex arithmetic
212 c ... Assume exact shifts are used
213 c ...
214 c ido = 0
215 c iparam(7) = 3
216 c
217 c %------------------------------------%
218 c | Beginning of reverse communication |
219 c %------------------------------------%
220 c 10 continue
221 c call _naupd ( ido, 'G', n, which, nev, tol, resid, ncv, v, ldv,
222 c & iparam, ipntr, workd, workl, lworkl, info )
223 c if (ido .eq. -1) then
224 c call matvecM (n, workd(ipntr(1)), temp_array)
225 c call solve(n, temp_array, complex_array)
226 c do i = 1, n
227 c workd(ipntr(2)+i-1) = aimag(complex_array(i))
228 c end do
229 c go to 10
230 c else if (ido .eq. 1) then
231 c call solve (n, workd(ipntr(3)), complex_array)
232 c do i = 1, n
233 c workd(ipntr(2)+i-1) = aimag(complex_array(i))
234 c end do
235 c go to 10
236 c else if (ido .eq. 2) then
237 c call matvecM (n, workd(ipntr(1)), workd(ipntr(2)))
238 c go to 10
239 c end if
240 c %------------------------------%
241 c | End of Reverse communication |
242 c %------------------------------%
243 c
244 c ... call _neupd to postprocess
245 c ... want the Ritz vectors set rvec = .true. else rvec = .false.
246 c call _neupd ( rvec, 'All', select, d, d(1,2), v, ldv,
247 c & sigmar, sigmai, workev, bmat, n, which, nev, tol,
248 c & resid, ncv, v, ldv, iparam, ipntr, workd, workl,
249 c & lworkl, info )
250 c ... Use Rayleigh quotient to transform d(:,1) and d(:,2)
251 c to the Ritz approximation to the original problem.
252 c stop
253 c end
254 c
255 c\EndDoc
256