-
Notifications
You must be signed in to change notification settings - Fork 8
/
rk_struct.m
32 lines (27 loc) · 998 Bytes
/
rk_struct.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function [S, ST] = rk_struct(A, cholesky)
%BUILD_RK_STRUCT Build a struct for building rational Krylov subspaces.
%
if isa(A, 'hss')
S = struct(...
'solve', @(nu, mu, x) shift(nu * A, - mu) \ x, ...
'multiply', @(rho, eta, x) rho * A * x - eta * x, ...
'isreal', isreal(A), ...
'nrm', normest(A, 1e-2));
ST = struct(...
'solve', @(nu, mu, x) shift(nu*A', -mu) \ x, ...
'multiply', @(rho, eta, x) rho * A' * x - eta * x, ...
'isreal', S.isreal, ...
'nrm', S.nrm);
else
S = struct(...
'solve', @(nu, mu, x) (nu * A - mu * eye(size(A), 'like',A)) \ x, ...
'multiply', @(rho, eta, x) rho * A * x - eta * x, ...
'isreal', isreal(A), ...
'nrm', normest(A, 1e-2));
ST = struct(...
'solve', @(nu, mu, x) (nu * A' - mu * eye(size(A), 'like', A)) \ x, ...
'multiply', @(rho, eta, x) rho * A' * x - eta * x, ...
'isreal', S.isreal, ...
'nrm', S.nrm);
end
end