在这个例子中,我们尝试找到一个Y,使得对于一对随机选择的A(12 \times 12)和B(4 \times 4),\vert\vert AY-YB\vert\vert _F最小化。
>> !cp examples/procrustes/*.m . >> randn('state',0); >> [A,B] = randprob; >> parameters(A,B); >> Y0 = guess; >> [fn,Yn] = sg_min(Y0,'newton','euclidean'); iter grad F(Y) flops step type 0 2.334988e+01 3.071299e+01 4751 none invdgrad: Hessian not positive definite, CG terminating early 1 1.171339e+01 1.376463e+01 365678 Newton step invdgrad: Hessian not positive definite, CG terminating early 2 7.843279e+00 7.616381e+00 677599 Newton step invdgrad: Hessian not positive definite, CG terminating early 3 5.131680e+00 4.945824e+00 992823 Newton step invdgrad: Hessian not positive definite, CG terminating early 4 5.642834e+00 3.512826e+00 1293761 Newton step invdgrad: Hessian not positive definite, CG terminating early 5 5.500553e+00 1.721329e+00 1607969 Newton step invdgrad: Hessian not positive definite, CG terminating early 6 4.666307e+00 1.192561e+00 1964675 Newton step invdgrad: Hessian not positive definite, CG terminating early 7 3.576069e+00 6.850532e-01 2272355 Newton step invdgrad: max iterations reached inverting the Hessian by CG 8 1.228119e+00 3.046816e-01 2820625 Newton step 9 4.673779e-02 2.506848e-01 3345266 Newton step 10 6.411668e-04 2.505253e-01 3873582 Newton step 11 1.965463e-06 2.505253e-01 4430245 Newton step 12 1.620267e-06 2.505253e-01 5022629 Newton step
图9.1展示了此次运行的收敛曲线。