Git commit 50e20cdcb3b01cb6107f20c1afed65967b27a767 by Stefan Gerlach. Committed on 31/08/2016 at 20:39. Pushed by sgerlach into branch 'master'. small improvements on line simplification error calculation M +14 -4 src/backend/nsl/nsl_geom_linesim.c M +3 -3 src/backend/nsl/nsl_geom_linesim.h M +7 -7 src/backend/nsl/nsl_geom_linesim_test.c http://commits.kde.org/labplot/50e20cdcb3b01cb6107f20c1afed65967b27a767 diff --git a/src/backend/nsl/nsl_geom_linesim.c b/src/backend/nsl/nsl_geom_= linesim.c index 3658c0e..68cedc3 100644 --- a/src/backend/nsl/nsl_geom_linesim.c +++ b/src/backend/nsl/nsl_geom_linesim.c @@ -26,27 +26,37 @@ * = * *************************************************************************= **/ = +/* + TODO: + * struct of algorithm and names + * extern nsl_compare + * non-parametric functions (calculate eps from data) + * more algorithm + * error calculation by area + * error statistics +*/ + #include #include #include #include "nsl_geom.h" #include "nsl_geom_linesim.h" = -double nsl_geom_linesim_positional_error(const double xdata[], const doubl= e ydata[], const size_t n, const size_t index[]) { +double nsl_geom_linesim_positional_squared_error(const double xdata[], con= st double ydata[], const size_t n, const size_t index[]) { double dist=3D0; - size_t i=3D0, j; /* index of index[] */ + size_t i=3D0, j; /* i: index of index[] */ do { /*for every point not in index[] calculate distance to line*/ /*printf("i=3D%d (index[i]-index[i+1]=3D%d-%d)\n", i , index[i], index[i= +1]);*/ for(j=3D1;j = -/* calculates positional error (summed perpendicular distance) - from simplified set (given by index[]) +/* calculates positional error (sum of squared perpendicular distance) + of simplified set (given by index[]) */ -double nsl_geom_linesim_positional_error(const double xdata[], const doubl= e ydata[], const size_t n, const size_t index[]); +double nsl_geom_linesim_positional_squared_error(const double xdata[], con= st double ydata[], const size_t n, const size_t index[]); = /* simple n-th point line simplification n: number of points diff --git a/src/backend/nsl/nsl_geom_linesim_test.c b/src/backend/nsl/nsl_= geom_linesim_test.c index 89c4fea..3701430 100644 --- a/src/backend/nsl/nsl_geom_linesim_test.c +++ b/src/backend/nsl/nsl_geom_linesim_test.c @@ -37,7 +37,7 @@ double main() { = printf("* n-th point\n"); size_t nout =3D nsl_geom_linesim_nthpoint(n, np, index); - printf("nout =3D %d (error =3D %g)\n", nout, nsl_geom_linesim_positional_= error(xdata, ydata, n, index)); + printf("nout =3D %d (error =3D %g)\n", nout, nsl_geom_linesim_positional_= squared_error(xdata, ydata, n, index)); = size_t i; for(i=3D0; i