-
Notifications
You must be signed in to change notification settings - Fork 0
/
solver_mu.m
51 lines (44 loc) · 1.18 KB
/
solver_mu.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
function [ H, iter ] = solver_mu(WtV, WtW, H, varargin)
%SOLVER_MU Multiplicative update
% minimize (1/2)*|| V - W*H ||^2 + r(H),
% s.t. H >= 0.
%
% Author: Deqing Wang
% Email: deqing.wang@foxmail.com
% Website: http://deqing.me/
% Affiliation: Dalian University of Technology, China
% University of Jyväskylä, Finland
% Date: July 19, 2019
%
%% Set algorithm parameters from input or by using defaults
params = inputParser;
params.addParameter('maxiters',5, @(x) isscalar(x) & x > 0);
params.addParameter('beta',0, @(x) isscalar(x) & x >= 0);
params.addParameter('tol',1e-2,@isscalar);
params.parse(varargin{:});
%% Copy from params object
maxiters = params.Results.maxiters;
beta = params.Results.beta;
tol = params.Results.tol;
%%
% Prevent the numerator to be zero
WtV = WtV + eps;
%%
for iter = 1:maxiters
H0 = H;
% Multiplicative Update
WtWH = WtW*H;
% Prevent the denominator to be zero
if beta > 0
WtWH = WtWH + beta;
else
WtWH = WtWH + eps;
end
H = H .* WtV;
H = H ./ WtWH;
Rh = H0 - H;
if norm(Rh(:)) < tol*norm(H(:))
break
end
end
end