-
Notifications
You must be signed in to change notification settings - Fork 17
/
initFactor.m
84 lines (72 loc) · 2.52 KB
/
initFactor.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
function ratio=initFactor(x_norm, Ax , y, z, funName, rsL2, x_2norm)
%
%% function initFactor
% compute the an optimal constant factor for the initialization
%
%
% Input parameters:
% x_norm- the norm of the starting point
% Ax- A*x, with x being the initialization point
% y- the response matrix
% z- the regularization parameter or the ball
% funName- the name of the function
%
% Output parameter:
% ratio- the computed optimal initialization point is ratio*x
%
%% Copyright (C) 2009-2010 Jun Liu, and Jieping Ye
%
% For any problem, please contact with Jun Liu via [email protected]
%
% Last revised on August 2, 2009.
switch(funName)
case 'LeastC'
ratio_max = z / x_norm;
ratio_optimal = Ax'*y / (Ax'*Ax + rsL2 * x_2norm);
if abs(ratio_optimal)<=ratio_max
ratio = ratio_optimal;
elseif ratio_optimal<0
ratio = -ratio_max;
else
ratio = ratio_max;
end
% fprintf('\n ratio=%e,%e,%e',ratio,ratio_optimal,ratio_max);
case 'LeastR'
ratio= (Ax'*y - z * x_norm) / (Ax'*Ax + rsL2 * x_2norm);
%fprintf('\n ratio=%e',ratio);
case 'glLeastR'
ratio= (Ax'*y - z * x_norm) / (Ax'*Ax);
%fprintf('\n ratio=%e',ratio);
case 'mcLeastR'
ratio= (Ax(:)'*y(:) - z * x_norm) / norm(Ax,'fro')^2;
%fprintf('\n ratio=%e',ratio);
case 'mtLeastR'
ratio= (Ax'*y - z * x_norm) / (Ax'*Ax);
%fprintf('\n ratio=%e',ratio);
case 'nnLeastR'
ratio= (Ax'*y - z * x_norm) / (Ax'*Ax + rsL2 * x_2norm);
ratio=max(0,ratio);
case 'nnLeastC'
ratio_max = z / x_norm;
ratio_optimal = Ax'*y / (Ax'*Ax + rsL2 * x_2norm);
if ratio_optimal<0
ratio=0;
elseif ratio_optimal<=ratio_max
ratio = ratio_optimal;
else
ratio = ratio_max;
end
% fprintf('\n ratio=%e,%e,%e',ratio,ratio_optimal,ratio_max);
case 'mcLeastC'
ratio_max = z / x_norm;
ratio_optimal = Ax(:)'*y(:) / (norm(Ax'*Ax,'fro')^2);
if abs(ratio_optimal)<=ratio_max
ratio = ratio_optimal;
elseif ratio_optimal<0
ratio = -ratio_max;
else
ratio = ratio_max;
end
otherwise
fprintf('\n The specified funName is not supprted');
end