[GRASS-dev] New module v.surf.trend but with external dependencies and ccmath problem

Jarek Jasiewicz jarekj at amu.edu.pl
Tue May 4 10:59:17 EDT 2010


Hi all!

I wrote new GRASS module, v.surf.trend I think it could be useful.

v.surf.trend allow to fit set of points to trend surface at any degree 
of polynomial (in fact if more than 6 has any  sense?)
Module v.surf.trend is ready to use (there remained some cosmetics) but 
is based on external dependencies: GNU Scientific library. It uses 
linear multifit with singular value matrix decomposition 
(gsl_multifit_linear). As I understood above this is not especially 
acceptable.

According some advice I decided to use function from ccmath and here is 
the problem.

There are two approach which allow to use multifit in ccmath:

function qrlsq which uses qr decomposition to solve linear least squares 
fitting and function lsqsv with singular value matrix decomposition

I assume that results shall be similar to that from gsl. In fact it is 
absolutely not.

I prepared testing version of the module. Is someone can help it is 
here: http://heretic.livenet.pl/heretic/v.surf.trend.tar.gz
(may be some problems with server)

To compile it gsl is necessary

This module performs calculating trend coefs with three methods:

1) gsl_multifit_linear gives perfect result up to 16 degree polynomial 
(and probably more but I stopped testing here). These results are in 
conicidence with result of trend from ArcGIS spatial analist

2) ccmath qrlsq gives perfect result to 3th degree of polynomial and 
good result on 4th degree but above (5 and more) coef are completely 
different from gsl and results are similar to good but with artifacts 
(see output)

3) ccmath svdlsq gives completely wrong results if degree of polynominal 
is greater than 2

if someone can help there only calc.c file is important: ccmath.c has 
function from ccmath library, vector.c process input vector file there  
is no help however  and there are some  issues like lack of 3D and WHERE 
support

or mabye there is different way to solve that problem. In general it 
would be nice to create that module without addational dependency

regards
Jarek

BTW:

there are two flags in current version -r and -s with no flag output is 
from gsl with -r  output is from qr matrix reduction with -s flag svd 
matrix reduction



More information about the grass-dev mailing list