| 53 | }; |
| 54 | |
| 55 | int main() { |
| 56 | int N = 1000, M = 4, d = 2; |
| 57 | MatrixXf f = 0.3*MatrixXf::Random( d, N ); |
| 58 | MatrixXf a = MatrixXf::Random( M, N ), b = MatrixXf::Random( M, N ); |
| 59 | PairwiseEnergy e( f.array(), a, a ); |
| 60 | |
| 61 | VectorXf p = e.initialValue(); |
| 62 | // p = VectorXf::Random( p.rows() ); |
| 63 | VectorXf g = p; |
| 64 | std::cout<<"start = "<<e.gradient( p, g )<<std::endl; |
| 65 | // std::cout<<p.transpose()<<std::endl; |
| 66 | p = minimizeLBFGS( e, 5, 1 ); |
| 67 | std::cout<<"E = "<<e.gradient( p, g )<<" "<<gradCheck( e, p, 1e-2 )<<" "<<p.transpose()<<std::endl; |
| 68 | std::cout<<"g = "<<g.transpose()<<std::endl; |
| 69 | std::cout<<"ng = "<<numericGradient( e, p ).transpose()<<std::endl; |
| 70 | std::cout<<"ng = "<<numericGradient( e, p, 1e-2 ).transpose()<<std::endl; |
| 71 | // int id; |
| 72 | // VectorXf dg = g.transpose()-numericGradient( e, p ); |
| 73 | // dg.array().abs().maxCoeff( &id ); |
| 74 | // std::cout<<computeFunction( e, p-g, 0.02*g ).transpose()<<std::endl; |
| 75 | } |
nothing calls this directly
no test coverage detected