# dkogan/libdogleg forked from Oblong/libdogleg

### Subversion checkout URL

You can clone with
or
.
Fetching contributors…

Cannot retrieve contributors at this time

182 lines (144 sloc) 5.523 kB
 #include #include #include #include #include "dogleg.h" // This is a trivial sample application to demonstrate libdogleg in action. // Let's say that I have a simple non-linear model // // a*b * x**2 + b*c * y**2 + c * x*y + d * x + e * y * f = measurements // // here I'm trying to estimate the vector (a,b,c,d,e,f) to most closely fit the // data vector measurements. This problem is clearly non-sparse and libdogleg is // overkill to solve it, but it serves decently well as a demo // // First I generate some noise-corrupted data, and then use libdogleg to solve // the problem. // My state vector (a,b,c,d,e,f) has 6 elements #define Nstate 6 // I simulate my measurements using these as the TRUE values for the model #define REFERENCE_A 1.0 #define REFERENCE_B 2.0 #define REFERENCE_C 3.0 #define REFERENCE_D 4.0 #define REFERENCE_E 5.0 #define REFERENCE_F 6.0 // I simulate by sampling the x-y space in a grid. This grid is defined here #define SIMULATION_GRID_WIDTH 10 #define SIMULATION_GRID_MIN -10 #define SIMULATION_GRID_DELTA 2.0 #define Nmeasurements (SIMULATION_GRID_WIDTH*SIMULATION_GRID_WIDTH) static double allx [Nmeasurements]; static double ally [Nmeasurements]; static double allm_simulated_noisy[Nmeasurements]; static void simulate(void) { for(int i=0; ip; int* Jcolidx = (int*)Jt->i; double* Jval = (double*)Jt->x; int iJacobian = 0; #define STORE_JACOBIAN(col, g) \ do \ { \ Jcolidx[ iJacobian ] = col; \ Jval [ iJacobian ] = g; \ iJacobian++; \ } while(0) double norm2_x = 0.0; for(int i=0; i
Something went wrong with that request. Please try again.