在 2018年4月10日星期二 UTC+8上午10:22:00,Nicolas Boumal写道:
Dear Nicolas,
Yes. Please find the codes as follows:
m=8;
n=10;
a=randn(m,m);
A=a*a';
b=randn(n,n);
B=b*b';
x = Solver_stiefel_Manifold(A,B);
function x = Solver_stiefel_Manifold(A,B)
% Create the problem structure.
m=size(A,1);
n=size(B,1);
manifold=stiefelfactory(m, n);
problem.M = manifold;
% Define the problem cost function and its gradient.
problem.cost = @(X) -trace(X*A*X'*B);
problem.egrad = @(X) -B'*X*A'-B*X*A;
% Numerically check gradient and Hessian consistency.
figure;
checkgradient(problem);
% Solve.
[x, xcost, info] = trustregions(problem);
% Display some statistics.
figure;
semilogy([info.iter], [info.gradnorm], '.-');
xlabel('Iteration #');
ylabel('Gradient norm');
title('Convergence of the trust-regions algorithm on the sphere');
Best,
Jiaxi