-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSVT_KZ.m
44 lines (38 loc) · 1 KB
/
SVT_KZ.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
function [x] = SVT_KZ(filename, users)
clc;
big_M = load(filename);
sample = randsample(1:length(big_M), users);
M = big_M(sample,:);
[r,c] = size(M);
% generate the projection matrix Omega
Omega = zeros(r,c);
num = 0; % number of existing entries
for i=1:r
for j=1:c
if M(i,j) > 0
Omega(i,j) = 1;
num = num + 1;
end
end
end
disp(num);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% SVT algorithm %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
maxiter = 500; %maximum iterations
tau = 1000;
y{1} = ones(r,c);
% the singular vector thresholding algorithms
for k=2:maxiter
disp(k);
[U, S, V] = svd(y{k-1});
D = S - tau;
D = max(D,0);
x{k} = U*D*V';
y{k} = y{k-1} + (M-x{k}).*Omega;
end
c=clock;
save(strcat(mat2str(c),'.mat'))
end