Hello,
checkgradient prints out the following text:
The slope should be 2. It appears to be: 1.
If it is far from 2, then directional derivatives might be erroneous.
The residual should be 0, or very close. Residual: 2.50622e-16.
If it is far from 0, then the gradient is not in the tangent space.
In certain cases (e.g., hyperbolicfactory), the tangency test is inconclusive.
This indicates that the gradient is incorrect. The first step is to fix that.
Before printing that text, there are a few warnings:
Warning: Principal matrix logarithm is not defined for A with nonpositive real
eigenvalues. A non-principal matrix logarithm is returned.
> In logm (line 91)
In sympositivedefinitefactory>@(X,Y)real(trAA(real(logm(X\Y)))) (line 101)
In @(x)g(x)+0.25*M.dist(x,z)^2
In getCost (line 59)
These warnings might offer a clue as to what is going on. It seems logm (matrix logarithm) is applied to matrices that are not positive definite.
Maybe part of the issue is this bit in your code:
A = randn(n);
x= .5*(A+A');
There is no reason for x to be positive definite here. Don't know if that's needed, but thought I'd mention it.
Best,
Nicolas