[GRASS-SVN] r52179 - grass/trunk/raster/r.mapcalc

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jun 21 02:23:08 PDT 2012


Author: glynn
Date: 2012-06-21 02:23:07 -0700 (Thu, 21 Jun 2012)
New Revision: 52179

Modified:
   grass/trunk/raster/r.mapcalc/xnmedian.c
   grass/trunk/raster/r.mapcalc/xnmode.c
Log:
Fix r52178


Modified: grass/trunk/raster/r.mapcalc/xnmedian.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xnmedian.c	2012-06-21 09:16:04 UTC (rev 52178)
+++ grass/trunk/raster/r.mapcalc/xnmedian.c	2012-06-21 09:23:07 UTC (rev 52179)
@@ -74,19 +74,18 @@
 	    CELL *a2 = &a[argc / 2];
 
 	    for (i = 0; i < columns; i++) {
-		int nv = 1;
+		int n = 0;
 
 		for (j = 0; j < argc; j++) {
 		    if (IS_NULL_C(&argv[j][i]))
 			continue;
-		    a[j] = argv[j][i];
-		    nv = 0;
+		    a[n++] = argv[j][i];
 		}
 
-		if (nv)
+		if (!n)
 		    SET_NULL_C(&res[i]);
 		else {
-		    qsort(a, argc, sizeof(CELL), icmp);
+		    qsort(a, n, sizeof(CELL), icmp);
 		    res[i] = (*a1 + *a2) / 2;
 		}
 	    }
@@ -102,19 +101,18 @@
 	    FCELL *a2 = &a[argc / 2];
 
 	    for (i = 0; i < columns; i++) {
-		int nv = 1;
+		int n = 0;
 
 		for (j = 0; j < argc; j++) {
 		    if (IS_NULL_F(&argv[j][i]))
 			continue;
-		    a[j] = argv[j][i];
-		    nv = 0;
+		    a[n++] = argv[j][i];
 		}
 
-		if (nv)
+		if (!n)
 		    SET_NULL_F(&res[i]);
 		else {
-		    qsort(a, argc, sizeof(FCELL), fcmp);
+		    qsort(a, n, sizeof(FCELL), fcmp);
 		    res[i] = (*a1 + *a2) / 2;
 		}
 	    }
@@ -130,19 +128,18 @@
 	    DCELL *a2 = &a[argc / 2];
 
 	    for (i = 0; i < columns; i++) {
-		int nv = 1;
+		int n = 0;
 
 		for (j = 0; j < argc; j++) {
 		    if (IS_NULL_D(&argv[j][i]))
 			continue;
-		    a[j] = argv[j][i];
-		    nv = 0;
+		    a[n++] = argv[j][i];
 		}
 
-		if (nv)
+		if (!n)
 		    SET_NULL_D(&res[i]);
 		else {
-		    qsort(a, argc, sizeof(DCELL), dcmp);
+		    qsort(a, n, sizeof(DCELL), dcmp);
 		    res[i] = (*a1 + *a2) / 2;
 		}
 	    }

Modified: grass/trunk/raster/r.mapcalc/xnmode.c
===================================================================
--- grass/trunk/raster/r.mapcalc/xnmode.c	2012-06-21 09:16:04 UTC (rev 52178)
+++ grass/trunk/raster/r.mapcalc/xnmode.c	2012-06-21 09:23:07 UTC (rev 52179)
@@ -78,19 +78,18 @@
 	    CELL **argv = (CELL **) & args[1];
 
 	    for (i = 0; i < columns; i++) {
-		int nv = 1;
+		int n = 0;
 
 		for (j = 0; j < argc; j++) {
 		    if (IS_NULL_C(&argv[j][i]))
 			continue;
-		    value[j] = (double)argv[j][i];
-		    nv = 0;
+		    value[n++] = (double)argv[j][i];
 		}
 
-		if (nv)
+		if (!n)
 		    SET_NULL_C(&res[i]);
 		else
-		    res[i] = (CELL) mode(value, argc);
+		    res[i] = (CELL) mode(value, n);
 	    }
 	    return 0;
 	}
@@ -100,19 +99,18 @@
 	    FCELL **argv = (FCELL **) & args[1];
 
 	    for (i = 0; i < columns; i++) {
-		int nv = 1;
+		int n = 0;
 
 		for (j = 0; j < argc; j++) {
 		    if (IS_NULL_F(&argv[j][i]))
 			continue;
-		    value[j] = (double)argv[j][i];
-		    nv = 0;
+		    value[n++] = (double)argv[j][i];
 		}
 
-		if (nv)
+		if (!n)
 		    SET_NULL_F(&res[i]);
 		else
-		    res[i] = (FCELL) mode(value, argc);
+		    res[i] = (FCELL) mode(value, n);
 	    }
 	    return 0;
 	}
@@ -122,19 +120,18 @@
 	    DCELL **argv = (DCELL **) & args[1];
 
 	    for (i = 0; i < columns; i++) {
-		int nv = 1;
+		int n = 0;
 
 		for (j = 0; j < argc; j++) {
 		    if (IS_NULL_D(&argv[j][i]))
 			continue;
-		    value[j] = (double)argv[j][i];
-		    nv = 0;
+		    value[n++] = (double)argv[j][i];
 		}
 
-		if (nv)
+		if (!n)
 		    SET_NULL_D(&res[i]);
 		else
-		    res[i] = (DCELL) mode(value, argc);
+		    res[i] = (DCELL) mode(value, n);
 	    }
 	    return 0;
 	}



More information about the grass-commit mailing list