📄 frob_norm_diag_scaling.m
字号:
% Frobenious norm diagonal scaling example% Section 4.5.4 example in Boyd & Vandenberghe "Convex Optimization"% (see page 163 for more details)%% Given a square matrix M, the goal is to find a positive vector d% such that ||DMD^{-1}||_F is minimized, where D = diag(d).% The problem can be cast into an unconstrained GP:%% minimize sum_{i,j=1}^{n} M_ij^2*d_i^2/d_j^2%% with variable d (vector in R^n) and data matrix M in R^{n-by-n}.%% Almir Mutapcic 10/15/05randn('state',0);% matrix size (M is an n-by-n matrix)n = 4;M = randn(n,n);% GP variablesgpvar d(n);% objective expressed using a for loopobj = posynomial; % initialize an empty posynomialfor i = 1:n for j = 1:n obj = obj + M(i,j)^2*d(i)^2*d(j)^-2; endend% objective can also be expressed using matrices% (can also use it below in the problem solving routine)% obj_vect = sum( sum( diag(d.^2)*(M.^2)*diag(d.^-2) ) );% solve the unconstrained GP problem[opt_frob_norm, solution, status] = gpsolve(obj,[]);% assign GP variables to their values (d now becomes an array of doubles)assign(solution);% construct matrix D and display resultsdisp(' ')disp('Optimal diagonal scaling d is: '), dD = diag(d);frob_norm_M = norm(M,'fro');frob_norm_A = norm(D*M*inv(D),'fro');fprintf(1,['The Frobenius norm for M before the scaling is %3.4f\n'... 'and after the optimal scaling (DMD^{-1}) it is %3.4f.\n'],... frob_norm_M,frob_norm_A);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -