[GRASS-SVN] r37970 - in grass/branches/develbranch_6/vector/lidar: lidarlib v.lidar.edgedetection

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jun 19 14:44:24 EDT 2009


Author: hamish
Date: 2009-06-19 14:44:24 -0400 (Fri, 19 Jun 2009)
New Revision: 37970

Modified:
   grass/branches/develbranch_6/vector/lidar/lidarlib/TcholBand.c
   grass/branches/develbranch_6/vector/lidar/v.lidar.edgedetection/edgedetection.c
   grass/branches/develbranch_6/vector/lidar/v.lidar.edgedetection/main.c
Log:
cleaner verbose messages; loop speedup from Markus Metz (merge from trunk)

Modified: grass/branches/develbranch_6/vector/lidar/lidarlib/TcholBand.c
===================================================================
--- grass/branches/develbranch_6/vector/lidar/lidarlib/TcholBand.c	2009-06-19 18:36:45 UTC (rev 37969)
+++ grass/branches/develbranch_6/vector/lidar/lidarlib/TcholBand.c	2009-06-19 18:44:24 UTC (rev 37970)
@@ -9,18 +9,20 @@
 
 void tcholDec(double **N, double **T, int n, int BW)
 {
-    int i, j, k;
+    int i, j, k, end;
     double somma;
 
-    G_debug(3, "tcholDec(): n=%d  BW=%d", n, BW);
+    G_debug(2, "tcholDec(): n=%d  BW=%d", n, BW);
 
     for (i = 0; i < n; i++) {
 	G_percent(i, n, 2);
 	for (j = 0; j < BW; j++) {
 	    somma = N[i][j];
-	    for (k = 1; k < BW; k++)
-		if (((i - k) >= 0) && ((j + k) < BW))
-		    somma -= T[i - k][k] * T[i - k][j + k];
+	    /* start = 1 */
+	    /* end = BW - j or i + 1 */
+	    end = ((BW - j) < (i + 1) ? (BW - j) : (i + 1));
+	    for (k = 1; k < end; k++)
+		somma -= T[i - k][k] * T[i - k][j + k];
 	    if (j == 0) {
 		if (somma <= 0.0)
 		    G_fatal_error(_("Decomposition failed"));
@@ -42,7 +44,7 @@
 {
 
     double **T;
-    int i, j;
+    int i, j, start, end;
 
 	/*--------------------------------------*/
     T = G_alloc_matrix(n, BW);
@@ -54,18 +56,22 @@
     parVect[0] = TN[0] / T[0][0];
     for (i = 1; i < n; i++) {
 	parVect[i] = TN[i];
-	for (j = 0; j < i; j++)
-	    if ((i - j) < BW)
-		parVect[i] -= T[j][i - j] * parVect[j];
+	/* start = 0 or i - BW + 1 */
+	start = ((i - BW + 1) < 0 ? 0 : (i - BW + 1));
+	/* end = i */
+	for (j = start; j < i; j++)
+	    parVect[i] -= T[j][i - j] * parVect[j];
 	parVect[i] = parVect[i] / T[i][0];
     }
 
     /* Backward substitution */
     parVect[n - 1] = parVect[n - 1] / T[n - 1][0];
     for (i = n - 2; i >= 0; i--) {
-	for (j = i + 1; j < n; j++)
-	    if ((j - i) < BW)
-		parVect[i] -= T[i][j - i] * parVect[j];
+	/* start = i + 1 */
+	/* end = n or BW + i */
+	end = (n < (BW + i) ? n : (BW + i));
+	for (j = i + 1; j < end; j++)
+	    parVect[i] -= T[i][j - i] * parVect[j];
 	parVect[i] = parVect[i] / T[i][0];
     }
 
@@ -84,24 +90,28 @@
 		 int BW)
 {
 
-    int i, j;
+    int i, j, start, end;
 
     /* Forward substitution */
     parVect[0] = TN[0] / T[0][0];
     for (i = 1; i < n; i++) {
 	parVect[i] = TN[i];
-	for (j = 0; j < i; j++)
-	    if ((i - j) < BW)
-		parVect[i] -= T[j][i - j] * parVect[j];
+	/* start = 0 or i - BW + 1 */
+	start = ((i - BW + 1) < 0 ? 0 : (i - BW + 1));
+	/* end = i */
+	for (j = start; j < i; j++)
+	    parVect[i] -= T[j][i - j] * parVect[j];
 	parVect[i] = parVect[i] / T[i][0];
     }
 
     /* Backward substitution */
     parVect[n - 1] = parVect[n - 1] / T[n - 1][0];
     for (i = n - 2; i >= 0; i--) {
-	for (j = i + 1; j < n; j++)
-	    if ((j - i) < BW)
-		parVect[i] -= T[i][j - i] * parVect[j];
+	/* start = i + 1 */
+	/* end = n or BW + i */
+	end = (n < (BW + i) ? n : (BW + i));
+	for (j = i + 1; j < end; j++)
+	    parVect[i] -= T[i][j - i] * parVect[j];
 	parVect[i] = parVect[i] / T[i][0];
     }
 
@@ -115,7 +125,7 @@
 {
     double **T = NULL;
     double *vect = NULL;
-    int i, j, k;
+    int i, j, k, start;
     double somma;
 
 	/*--------------------------------------*/
@@ -136,9 +146,11 @@
 	invNdiag[i] = vect[0] * vect[0];
 	for (j = i + 1; j < n; j++) {
 	    somma = 0.0;
-	    for (k = i; k < j; k++) {
-		if ((j - k) < BW)
-		    somma -= vect[k - i] * T[k][j - k];
+	    /* start = i or j - BW + 1 */
+	    start = ((j - BW + 1) < i ? i : (j - BW + 1));
+	    /* end = j */
+	    for (k = start; k < j; k++) {
+		somma -= vect[k - i] * T[k][j - k];
 	    }
 	    vect[j - i] = somma * T[j][0];
 	    invNdiag[i] += vect[j - i] * vect[j - i];
@@ -161,7 +173,7 @@
 
     double **T = NULL;
     double *vect = NULL;
-    int i, j, k;
+    int i, j, k, start, end;
     double somma;
 
 	/*--------------------------------------*/
@@ -175,18 +187,22 @@
     parVect[0] = TN[0] / T[0][0];
     for (i = 1; i < n; i++) {
 	parVect[i] = TN[i];
-	for (j = 0; j < i; j++)
-	    if ((i - j) < BW)
-		parVect[i] -= T[j][i - j] * parVect[j];
+	/* start = 0 or i - BW + 1 */
+	start = ((i - BW + 1) < 0 ? 0 : (i - BW + 1));
+	/* end = i */
+	for (j = start; j < i; j++)
+	    parVect[i] -= T[j][i - j] * parVect[j];
 	parVect[i] = parVect[i] / T[i][0];
     }
 
     /* Backward substitution */
     parVect[n - 1] = parVect[n - 1] / T[n - 1][0];
     for (i = n - 2; i >= 0; i--) {
-	for (j = i + 1; j < n; j++)
-	    if ((j - i) < BW)
-		parVect[i] -= T[i][j - i] * parVect[j];
+	/* start = i + 1 */
+	/* end = n or BW + i */
+	end = (n < (BW + i) ? n : (BW + i));
+	for (j = i + 1; j < end; j++)
+	    parVect[i] -= T[i][j - i] * parVect[j];
 	parVect[i] = parVect[i] / T[i][0];
     }
 
@@ -201,9 +217,11 @@
 	invNdiag[i] = vect[0] * vect[0];
 	for (j = i + 1; j < n; j++) {
 	    somma = 0.0;
-	    for (k = i; k < j; k++) {
-		if ((j - k) < BW)
-		    somma -= vect[k - i] * T[k][j - k];
+	    /* start = i or j - BW + 1 */
+	    start = ((j - BW + 1) < i ? i : (j - BW + 1));
+	    /* end = j */
+	    for (k = start; k < j; k++) {
+		somma -= vect[k - i] * T[k][j - k];
 	    }
 	    vect[j - i] = somma * T[j][0];
 	    invNdiag[i] += vect[j - i] * vect[j - i];

Modified: grass/branches/develbranch_6/vector/lidar/v.lidar.edgedetection/edgedetection.c
===================================================================
--- grass/branches/develbranch_6/vector/lidar/v.lidar.edgedetection/edgedetection.c	2009-06-19 18:36:45 UTC (rev 37969)
+++ grass/branches/develbranch_6/vector/lidar/v.lidar.edgedetection/edgedetection.c	2009-06-19 18:44:24 UTC (rev 37970)
@@ -188,6 +188,7 @@
     categories = Vect_new_cats_struct();
 
     for (i = 0; i < num_points; i++) {	/* Sparse points */
+	G_percent(i, num_points, 6);
 
 	Vect_reset_line(point);
 	Vect_reset_cats(categories);
@@ -394,6 +395,8 @@
 	    }
 	}			/*end if obs */
     }				/*end for */
+    G_percent(i, num_points, 6); /* finish it */
+
     Vect_destroy_line_struct(point);
     Vect_destroy_cats_struct(categories);
 }				/*end puntisparsi_select */

Modified: grass/branches/develbranch_6/vector/lidar/v.lidar.edgedetection/main.c
===================================================================
--- grass/branches/develbranch_6/vector/lidar/v.lidar.edgedetection/main.c	2009-06-19 18:36:45 UTC (rev 37969)
+++ grass/branches/develbranch_6/vector/lidar/v.lidar.edgedetection/main.c	2009-06-19 18:44:24 UTC (rev 37970)
@@ -46,7 +46,7 @@
 	mean;
     char *dvr, *db, *mapset, table_interpolation[1024], table_name[1024];
 
-    int last_row, last_column, flag_auxiliar = FALSE;
+    int last_row, last_column, flag_auxiliar = FALSE, pass_num;
 
     int *lineVect;
     double *TN, *Q, *parVect_bilin, *parVect_bicub;	/* Interpolating and least-square vectors */
@@ -200,9 +200,9 @@
     Vect_region_box(&elaboration_reg, &overlap_box);
     Vect_region_box(&elaboration_reg, &general_box);
 
-    /* Fixxing parameters of the elaboration region */
+    /* Fixing parameters of the elaboration region */
     /*! Each original_region will be divided into several subregions. These
-     *  subregion will be overlapped by its neibourgh subregions. This overlapping
+     *  subregion will be overlapped by its neighboring subregions. This overlapping
      *  is calculated as OVERLAP_PASS times the east-west resolution. */
 
     ew_resol = original_reg.ew_res;
@@ -219,6 +219,7 @@
 
     last_row = FALSE;
     first_it = TRUE;
+    pass_num = 0;
 
     while (last_row == FALSE) {	/* For each row */
 
@@ -281,13 +282,16 @@
 	    if (npoints > 0) {	/* If there is any point falling into elaboration_reg... */
 		int i, tn;
 
+		pass_num++;
+		G_verbose_message(_("Pass %d:"), pass_num);
+
 		nparameters = nsplx * nsply;
 
 		/* Mean's calculation */
 		mean = P_Mean_Calc(&elaboration_reg, observ, npoints);
 
 		/* Least Squares system */
-		G_debug(1, _("Allocation memory for bilinear interpolation"));
+		G_debug(1, _("Allocating memory for bilinear interpolation"));
 		BW = P_get_BandWidth(P_BILINEAR, nsply);	/* Bilinear interpolation */
 		N = G_alloc_matrix(nparameters, BW);	/* Normal matrix */
 		TN = G_alloc_vector(nparameters);	/* vector */
@@ -320,7 +324,7 @@
 		for (tn = 0; tn < nparameters; tn++)
 		    TN[tn] = 0;
 
-		G_debug(1, _("Allocation memory for bicubic interpolation"));
+		G_debug(1, _("Allocating memory for bicubic interpolation"));
 		BW = P_get_BandWidth(P_BICUBIC, nsply);
 		N = G_alloc_matrix(nparameters, BW);	/* Normal matrix */
 		parVect_bicub = G_alloc_vector(nparameters);	/* Bicubic parameters vector */



More information about the grass-commit mailing list