-
Notifications
You must be signed in to change notification settings - Fork 2
/
hstorage.m
104 lines (86 loc) · 2.47 KB
/
hstorage.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
function y = hstorage(obj, varargin)
y = 0;
if nargin == 1
level = 1;
else
level = varargin{1};
end
if isa(obj, 'hodlr')
if ~isempty(obj.D)
if isa(obj.D, 'double')
bits = 64;
else
bits = 32;
end
[m, n] = size(obj.D);
y = (m * n) * bits;
return;
else
if isa(obj.U1, 'double')
bits = 64;
else
bits = 32;
end
[m, k] = size(obj.U1);
[n, k] = size(obj.V2);
y = y + (m + n) * k * bits;
[m, k] = size(obj.U2);
[n, k] = size(obj.V1);
y = y + (m + n) * k * bits;
y = y + hstorage(obj.A11, level+1);
y = y + hstorage(obj.A22, level+1);
end
end
if isa(obj, 'mphodlr')
if ~isempty(obj.D)
if isa(obj.D, 'double')
bits = 64;
else
bits = 32;
end
[m, n] = size(obj.D);
y = (m * n) * bits;
return;
else
if size(obj.prec_settings, 2) >= level
bits = obj.prec_settings{level}.bits;
else
bits = 64;
end
[m, k] = size(obj.U1);
[n, k] = size(obj.V2);
y = y + (m + n) * k * bits;
[m, k] = size(obj.U2);
[n, k] = size(obj.V1);
y = y + (m + n) * k * bits;
y = y + hstorage(obj.A11, level+1);
y = y + hstorage(obj.A22, level+1);
end
end
if isa(obj, 'amphodlr')
if ~isempty(obj.D)
if isa(obj.D, 'double')
bits = 64;
else
bits = 32;
end
[m, n] = size(obj.D);
y = (m * n) * bits;
return;
else
if obj.precIndex(level) ~= 0
bits = obj.prec_settings{obj.precIndex(level)}.bits;
else
bits = 64;
end
[m, k] = size(obj.U1);
[n, k] = size(obj.V2);
y = y + (m + n) * k * bits;
[m, k] = size(obj.U2);
[n, k] = size(obj.V1);
y = y + (m + n) * k * bits;
y = y + hstorage(obj.A11, level+1);
y = y + hstorage(obj.A22, level+1);
end
end
end