3431
|
1 ## Copyright (C) 1996, 1998 Auburn University. All rights reserved. |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by the |
|
7 ## Free Software Foundation; either version 2, or (at your option) any |
|
8 ## later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 ## for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301 USA. |
3431
|
19 |
|
20 ## -*- texinfo -*- |
5016
|
21 ## @deftypefn {Function File} {@var{y} =} zgfmul (@var{a}, @var{b}, @var{c}, @var{d}, @var{x}) |
|
22 ## Compute product of @var{zgep} incidence matrix @math{F} with vector @var{x}. |
|
23 ## Used by @command{zgepbal} (in @command{zgscal}) as part of generalized conjugate gradient |
3431
|
24 ## iteration. |
|
25 ## @end deftypefn |
|
26 |
|
27 ## References: |
|
28 ## ZGEP: Hodel, "Computation of Zeros with Balancing," 1992, submitted to LAA |
|
29 ## Generalized CG: Golub and Van Loan, "Matrix Computations, 2nd ed" 1989 |
|
30 |
|
31 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
32 ## Conversion to Octave July 3, 1994 |
|
33 |
|
34 function y = zgfmul (a, b, c, d, x) |
|
35 |
|
36 [n,m] = size(b); |
|
37 [p,m1] = size(c); |
|
38 nm = n+m; |
|
39 y = zeros(nm+p,1); |
|
40 |
|
41 ## construct F column by column |
|
42 for jj=1:n |
|
43 Fj = zeros(nm+p,1); |
|
44 |
|
45 ## rows 1:n: F1 |
|
46 aridx = complement(jj,find(a(jj,:) != 0)); |
|
47 acidx = complement(jj,find(a(:,jj) != 0)); |
|
48 bidx = find(b(jj,:) != 0); |
|
49 cidx = find(c(:,jj) != 0); |
|
50 |
|
51 Fj(aridx) = Fj(aridx) - 1; # off diagonal entries of F1 |
|
52 Fj(acidx) = Fj(acidx) - 1; |
|
53 ## diagonal entry of F1 |
|
54 Fj(jj) = length(aridx)+length(acidx) + length(bidx) + length(cidx); |
|
55 |
|
56 if(!isempty(bidx)) Fj(n+bidx) = 1; endif # B' incidence |
|
57 if(!isempty(cidx)) Fj(n+m+cidx) = -1; endif # -C incidence |
|
58 y = y + x(jj)*Fj; # multiply by corresponding entry of x |
|
59 endfor |
|
60 |
|
61 for jj=1:m |
|
62 Fj = zeros(nm+p,1); |
|
63 bidx = find(b(:,jj) != 0); |
|
64 if(!isempty(bidx)) Fj(bidx) = 1; endif # B incidence |
|
65 didx = find(d(:,jj) != 0); |
|
66 if(!isempty(didx)) Fj(n+m+didx) = 1; endif # D incidence |
|
67 Fj(n+jj) = length(bidx) + length(didx); # F2 is diagonal |
|
68 y = y + x(n+jj)*Fj; # multiply by corresponding entry of x |
|
69 endfor |
|
70 |
|
71 for jj=1:p |
|
72 Fj = zeros(nm+p,1); |
|
73 cidx = find(c(jj,:) != 0); |
|
74 if(!isempty(cidx)) Fj(cidx) = -1; endif # -C' incidence |
|
75 didx = find(d(jj,:) != 0); |
|
76 if(!isempty(didx)) Fj(n+didx) = 1; endif # D' incidence |
|
77 Fj(n+m+jj) = length(cidx) + length(didx); # F2 is diagonal |
|
78 y = y + x(n+m+jj)*Fj; # multiply by corresponding entry of x |
|
79 endfor |
|
80 |
|
81 endfunction |