[GRASS-dev] Re: Probable bug fix

Jyothish wrote:

> I have a small problem in understanding how the vect
> variable is being declared... in function tcholInv and
> tcholSolveInv.

Hamish:

i.e. array used but no space never allocated for it?
looks like a bug to me.

Jyothish:

And I think the initial author missed a
vect=G_alloc_vector(n);
T=G_alloc_matrix(n, BW);

ok. ... proposed patch:

Index: vector/lidar/lidarlib/TcholBand.c

--- vector/lidar/lidarlib/TcholBand.c (revision 37978)
+++ vector/lidar/lidarlib/TcholBand.c (working copy)
@@ -1,8 +1,7 @@
#include <stdlib.h> /* imported libraries */
#include <stdio.h>
#include <math.h>
-#include <grass/gis.h>
-#include <grass/PolimiFunct.h>
+#include "PolimiFunct.h"

/*--------------------------------------------------------------------------------------*/
/* Tcholetsky decomposition -> T= Lower Triangular Matrix */
@@ -129,8 +128,8 @@
     double somma;

        /*--------------------------------------*/
- G_alloc_matrix(n, BW);
- G_alloc_vector(n);
+ T = G_alloc_matrix(n, BW);
+ vect = G_alloc_vector(n);

     /* T computation */
     tcholDec(N, T, n, BW);
@@ -177,8 +176,8 @@
     double somma;

        /*--------------------------------------*/
- G_alloc_matrix(n, BW);
- G_alloc_vector(n);
+ T = G_alloc_matrix(n, BW);
+ vect = G_alloc_vector(n);

     /* T computation */
     tcholDec(N, T, n, BW);

Hamish