#include #include #include #include typedef double real; typedef DynColVector V; typedef DynMatrix M; typedef V Params; struct XY { V x; real y; }; Params lma( const std::vector &data, Function f, Function j, Params params){ real lambda=0.000001; bool updateJ=true; const int I = data[0].x.cols(); const int D = data.size(); const int P = params.dim(); const int MAX_IT = 10000; const real MIN_E = 1e-6; V y(D),y_est(D),y_est_new(D), dst(D); M J(P,D), H(P,P), H_damped(P,P); Params params_new(P); real e = 1e38, e_new(0); for(int i=0;i create_data(){ URand r(-4,4); const int N = 100; XY init = { V(1), 0 }; std::vector data(N,init); for(int i=0;i create_data_new(){ Params p(3); p[0] = 1; p[1] = 2; p[2] = 3; URand r(-10,10); const int N = 100; XY init = { V(1), 0 }; std::vector data(N,init); for(int i=0;i