Skip to content

Commit d549afa

Browse files
committed
hssrank: now it computes the maximum rank of the hss blocks
1 parent deec9fe commit d549afa

File tree

8 files changed

+38
-10
lines changed

8 files changed

+38
-10
lines changed

@hss/hodlrrank.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function k = hodlrrank(A)
2+
k = hss_hodlr_rank(A);
3+
end

@hss/hssrank.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
function k = hssrank(A)
2-
k = hss_rank(A);
2+
% Maximum rank of all the HSS block rows at each level
3+
k = hss_rank(A);
34
end

@hss/private/hss_chol_fact.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
k = size(A.U, 2);
4444
[row, col] = size(A.D);
4545
if k == row
46-
x = zeros(col, size(b,2)); D = A.D; U = A.U; ind = zeros(1,0); cind = [1:col];
46+
D = A.D; U = A.U; ind = zeros(1,0); cind = [1:col];
4747
return
4848
end
4949
ind = [1:row-k]; % Indices of computed entries in the solution, at the end

@hss/private/hss_chol_solve.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
% The procedure is based on the implicit generalized Cholesky factorization
55
% of A and is taken from the paper:
66
%
7-
% Xia, J., Chandrasekaran, S., Gu, M., & Li, X. S. (2010). Fast algorithodlrs for
7+
% Xia, J., Chandrasekaran, S., Gu, M., & Li, X. S. (2010). Fast algorithms for
88
% hierarchically semiseparable matrices. Numerical Linear Algebra with Applications, 17(6), 953-976.
99
%
1010
if A.leafnode == 1

@hss/private/hss_hodlr_rank.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function k = hss_hodlr_rank(A)
2+
% maximum rank of the off-diagonal blocks
3+
if A.leafnode == 1
4+
k = 0;
5+
else
6+
k = max([rank(A.B12), rank(A.B21), hss_hodlr_rank(A.A11), hss_hodlr_rank(A.A22)]);
7+
end
8+
end

@hss/private/hss_rank.m

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
function k = hss_rank(A)
2-
if A.leafnode == 1
3-
k = 0;
4-
else
5-
k = max([rank(A.B12), rank(A.B21), hss_rank(A.A11), hss_rank(A.A22)]);
2+
k = hss_rank_rec(A, zeros(size(A.B12, 1), 0), zeros(size(A.B21, 1), 0));
63
end
4+
function k = hss_rank_rec(A, M1, M2)
5+
% Compute the rank of all the HSS block rows at each level
6+
if A.leafnode == 1
7+
k = 0;
8+
else
9+
k1 = rank([A.B12, M1]);
10+
k2 = rank([A.B21, M2]);
11+
if A.A11.leafnode == 0
12+
k3 = hss_rank_rec(A.A11, A.A11.Rl * [A.B12, M1], A.A11.Rr * [A.B12, M1]);
13+
else
14+
k3 = 0;
15+
end
16+
if A.A22.leafnode == 0
17+
k4 = hss_rank_rec(A.A22, A.A22.Rl * [A.B21, M2], A.A22.Rr * [A.B21, M2]);
18+
else
19+
k4 = 0;
20+
end
21+
k = max([k1, k2, k3, k4]);
22+
end
723
end

@hss/spy.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function spy(H)
1616
axis([ 0 n 0 m ]);
1717
hold on;
1818

19-
spy_draw_block(H, 0, 0, hssrank(H));
19+
spy_draw_block(H, 0, 0, hodlrrank(H));
2020

2121
hold off;
2222

@@ -65,4 +65,4 @@ function spy_draw_block(H, xoffset, yoffset, rk)
6565
sprintf('%d', thisrk), ...
6666
'HorizontalAlignment', 'center');
6767
end
68-
end
68+
end

rk_sylv.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
check_residual = it >= needed_iterations;
124124
end
125125

126-
% check_residual = true;
126+
%check_residual = true;
127127

128128
if check_residual
129129
if poleA ~= inf

0 commit comments

Comments
 (0)