[GRASS-SVN] r63912 - in grass/branches/releasebranch_7_0: . display/d.thematic.area include include/defs lib/arraystats vector/v.class

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jan 1 11:55:13 PST 2015


Author: martinl
Date: 2015-01-01 11:55:13 -0800 (Thu, 01 Jan 2015)
New Revision: 63912

Modified:
   grass/branches/releasebranch_7_0/
   grass/branches/releasebranch_7_0/display/d.thematic.area/main.c
   grass/branches/releasebranch_7_0/include/arraystats.h
   grass/branches/releasebranch_7_0/include/defs/arraystats.h
   grass/branches/releasebranch_7_0/lib/arraystats/arraystatslib.dox
   grass/branches/releasebranch_7_0/lib/arraystats/basic.c
   grass/branches/releasebranch_7_0/lib/arraystats/class.c
   grass/branches/releasebranch_7_0/vector/v.class/main.c
Log:
arraystatslib: rename fns to use prefix (AS)
doxygen cosmetics
arraystatslib: add AS_option_to_algorithm()
               (merge r63909-11 from trunk)



Property changes on: grass/branches/releasebranch_7_0
___________________________________________________________________
Modified: svn:mergeinfo
   - /grass/trunk:60817,61096,61141,61994,62105,62179-62180,62182,62190,62403,62422,62424,62437,62466,62469,62487,62491,62494,62501,62506,62508-62509,62515,62518-62519,62521,62526,62533,62539,62541,62555,62562,62566,62570,62573,62575,62585,62588,62597,62603,62606,62608-62609,62614,62618,62628,62632,62638,62642,62648-62649,62652,62654-62657,62666,62691,62705,62709,62723,62730,62739,62741,62743,62746,62750-62752,62757,62762,62785,62798,62800-62801,62803,62805,62812,62822,62824,62828,62831,62838,62845,62847,62850,62856,62879,62881,62886,62904,62907-62908,62910,62912,62914,62916,62918,62920,62925,62932-62933,62935,62940,62942,62944-62946,62949,62955-62956,62958,62960,62962,62964,62966-62968,62970,62973,62975,62977,62981,62983,62985,62987,62989,62991,62993,62995,62997,62999-63000,63003,63005,63007,63009,63011,63013,63015,63017,63020,63022,63024,63026,63028-63031,63033,63035,63037,63040,63043-63044,63047,63049,63051,63053,63055,63057,63060,63062-63064,63066,63068,63070-63071,63074,
 63076,63079,63081,63083,63085,63087,63089,63091,63093,63095,63098,63100,63102,63105,63107,63109,63111,63113-63114,63116,63119,63121,63123,63125,63130,63132-63133,63135,63137,63140,63143,63145,63147,63149,63151,63153-63154,63157,63160,63165,63170,63173,63175,63187,63192-63193,63196,63199-63200,63202,63209,63216,63220-63221,63224,63227,63240,63246,63250,63255,63259,63261,63275-63276,63279,63281,63283,63287,63290,63292,63297,63302,63304-63307,63315,63319,63327,63330,63332,63339,63342,63345,63361-63363,63367,63379,63389,63391,63393,63402,63408-63409,63416-63417,63425,63427,63429,63431,63433,63448,63451,63453,63457,63459,63464-63470,63473,63482,63497,63505,63508,63510,63515,63521-63524,63526,63536-63537,63551-63552,63554,63556,63558-63559,63562,63570,63576,63582,63589-63593,63602,63604,63608-63609,63616,63618,63624,63626,63628,63630,63634,63639,63642,63644,63650,63652,63656,63679,63685,63689,63691,63693,63695,63698,63700-63702,63704,63706-63707,63709,63711,63713,63715,63717-63718
 ,63721-63727,63731,63733,63740-63742,63744,63747-63749,63751-63752,63756,63758,63761,63767,63777,63780,63783,63787,63793,63796-63798,63801,63803,63807-63808,63812,63814,63816,63821,63823-63824,63827-63828,63830-63831,63834-63835,63837-63839,63841,63843-63844,63846-63847,63849,63851,63853,63855-63856,63858-63859,63862,63865,63869,63871,63882,63884,63889-63890,63892-63895,63897-63898,63900,63902-63903,63905,63907
   + /grass/trunk:60817,61096,61141,61994,62105,62179-62180,62182,62190,62403,62422,62424,62437,62466,62469,62487,62491,62494,62501,62506,62508-62509,62515,62518-62519,62521,62526,62533,62539,62541,62555,62562,62566,62570,62573,62575,62585,62588,62597,62603,62606,62608-62609,62614,62618,62628,62632,62638,62642,62648-62649,62652,62654-62657,62666,62691,62705,62709,62723,62730,62739,62741,62743,62746,62750-62752,62757,62762,62785,62798,62800-62801,62803,62805,62812,62822,62824,62828,62831,62838,62845,62847,62850,62856,62879,62881,62886,62904,62907-62908,62910,62912,62914,62916,62918,62920,62925,62932-62933,62935,62940,62942,62944-62946,62949,62955-62956,62958,62960,62962,62964,62966-62968,62970,62973,62975,62977,62981,62983,62985,62987,62989,62991,62993,62995,62997,62999-63000,63003,63005,63007,63009,63011,63013,63015,63017,63020,63022,63024,63026,63028-63031,63033,63035,63037,63040,63043-63044,63047,63049,63051,63053,63055,63057,63060,63062-63064,63066,63068,63070-63071,63074,
 63076,63079,63081,63083,63085,63087,63089,63091,63093,63095,63098,63100,63102,63105,63107,63109,63111,63113-63114,63116,63119,63121,63123,63125,63130,63132-63133,63135,63137,63140,63143,63145,63147,63149,63151,63153-63154,63157,63160,63165,63170,63173,63175,63187,63192-63193,63196,63199-63200,63202,63209,63216,63220-63221,63224,63227,63240,63246,63250,63255,63259,63261,63275-63276,63279,63281,63283,63287,63290,63292,63297,63302,63304-63307,63315,63319,63327,63330,63332,63339,63342,63345,63361-63363,63367,63379,63389,63391,63393,63402,63408-63409,63416-63417,63425,63427,63429,63431,63433,63448,63451,63453,63457,63459,63464-63470,63473,63482,63497,63505,63508,63510,63515,63521-63524,63526,63536-63537,63551-63552,63554,63556,63558-63559,63562,63570,63576,63582,63589-63593,63602,63604,63608-63609,63616,63618,63624,63626,63628,63630,63634,63639,63642,63644,63650,63652,63656,63679,63685,63689,63691,63693,63695,63698,63700-63702,63704,63706-63707,63709,63711,63713,63715,63717-63718
 ,63721-63727,63731,63733,63740-63742,63744,63747-63749,63751-63752,63756,63758,63761,63767,63777,63780,63783,63787,63793,63796-63798,63801,63803,63807-63808,63812,63814,63816,63821,63823-63824,63827-63828,63830-63831,63834-63835,63837-63839,63841,63843-63844,63846-63847,63849,63851,63853,63855-63856,63858-63859,63862,63865,63869,63871,63882,63884,63889-63890,63892-63895,63897-63898,63900,63902-63903,63905,63907,63909-63911

Modified: grass/branches/releasebranch_7_0/display/d.thematic.area/main.c
===================================================================
--- grass/branches/releasebranch_7_0/display/d.thematic.area/main.c	2015-01-01 19:45:14 UTC (rev 63911)
+++ grass/branches/releasebranch_7_0/display/d.thematic.area/main.c	2015-01-01 19:55:13 UTC (rev 63912)
@@ -325,9 +325,9 @@
 
 	    /* Get classbreaks for given algorithm and number of classbreaks.
 	     * class_info takes any info coming from the classification algorithms */
-	    class_info =
-		class_apply_algorithm(algo_opt->answer, data, nrec, &nbreaks,
-				      breakpoints);
+	    class_info = AS_class_apply_algorithm(AS_option_to_algorithm(algo_opt),
+                                                  data, nrec, &nbreaks,
+                                                  breakpoints);
 
 	}
 	else {
@@ -414,10 +414,10 @@
     frequencies = (int *)G_malloc((nbreaks + 1) * sizeof(int));
     for (i = 0; i < nbreaks + 1; i++)
 	frequencies[i] = 0.0;
-    class_frequencies(data, nrec, nbreaks, breakpoints, frequencies);
+    AS_class_frequencies(data, nrec, nbreaks, breakpoints, frequencies);
 
     /*Get basic statistics about the data */
-    basic_stats(data, nrec, &stats);
+    AS_basic_stats(data, nrec, &stats);
 
     if (legend_flag->answer) {
 

Modified: grass/branches/releasebranch_7_0/include/arraystats.h
===================================================================
--- grass/branches/releasebranch_7_0/include/arraystats.h	2015-01-01 19:45:14 UTC (rev 63911)
+++ grass/branches/releasebranch_7_0/include/arraystats.h	2015-01-01 19:55:13 UTC (rev 63912)
@@ -22,6 +22,12 @@
     double stdev;
 };
 
+#define CLASS_INTERVAL 1
+#define CLASS_STDEV    2
+#define CLASS_QUANT    3
+#define CLASS_EQUIPROB 4
+#define CLASS_DISCONT  5
+      
 #include <grass/defs/arraystats.h>
 
 #endif

Modified: grass/branches/releasebranch_7_0/include/defs/arraystats.h
===================================================================
--- grass/branches/releasebranch_7_0/include/defs/arraystats.h	2015-01-01 19:45:14 UTC (rev 63911)
+++ grass/branches/releasebranch_7_0/include/defs/arraystats.h	2015-01-01 19:55:13 UTC (rev 63912)
@@ -1,16 +1,18 @@
 #ifndef GRASS_ARRAYSTATSDEFS_H
 #define GRASS_ARRAYSTATSDEFS_H
 
-double class_apply_algorithm(char *, double *, int, int *, double *);
-int class_interval(double *, int, int, double *);
-int class_quant(double *, int, int, double *);
-double class_discont(double *, int, int, double *);
-double class_stdev(double *, int, int, double *);
-int class_equiprob(double *, int, int *, double *);
+/* basic.c */
+void AS_eqdrt(double[], double[], int, int, double *);
+void AS_basic_stats(double *, int, struct GASTATS *);
 
-int class_frequencies(double *, int, int, double *, int *);
+/* class.c */
+int AS_option_to_algorithm(const struct Option *);
+double AS_class_apply_algorithm(int, double *, int, int *, double *);
+int AS_class_interval(double *, int, int, double *);
+int AS_class_quant(double *, int, int, double *);
+double AS_class_discont(double *, int, int, double *);
+double AS_class_stdev(double *, int, int, double *);
+int AS_class_equiprob(double *, int, int *, double *);
+int AS_class_frequencies(double *, int, int, double *, int *);
 
-void eqdrt(double[], double[], int, int, double *);
-void basic_stats(double *, int, struct GASTATS *);
-
 #endif

Modified: grass/branches/releasebranch_7_0/lib/arraystats/arraystatslib.dox
===================================================================
--- grass/branches/releasebranch_7_0/lib/arraystats/arraystatslib.dox	2015-01-01 19:45:14 UTC (rev 63911)
+++ grass/branches/releasebranch_7_0/lib/arraystats/arraystatslib.dox	2015-01-01 19:55:13 UTC (rev 63912)
@@ -1,4 +1,4 @@
-/*! \page arraystatslib GRASS array statistics Library
+/*! \page arraystatslib GRASS Array Statistics Library
 
 by GRASS Development Team (http://grass.osgeo.org)
 
@@ -6,15 +6,15 @@
 
 \section listOfFunctios List of functions
 
-- class_apply_algorithm()
-- class_interval()
-- class_quant()
-- class_discont()
-- class_stdev()
-- class_equiprob()
-- class_frequencies()
-- eqdrt()
-- basic_stats()
+- AS_class_apply_algorithm()
+- AS_class_interval()
+- AS_class_quant()
+- AS_class_discont()
+- AS_class_stdev()
+- AS_class_equiprob()
+- AS_class_frequencies()
+- AS_eqdrt()
+- AS_basic_stats()
 
 */
 

Modified: grass/branches/releasebranch_7_0/lib/arraystats/basic.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/arraystats/basic.c	2015-01-01 19:45:14 UTC (rev 63911)
+++ grass/branches/releasebranch_7_0/lib/arraystats/basic.c	2015-01-01 19:55:13 UTC (rev 63912)
@@ -3,7 +3,7 @@
 
 
 /*provides basic univar stats */
-void basic_stats(double *data, int count, struct GASTATS *stats)
+void AS_basic_stats(double *data, int count, struct GASTATS *stats)
 {
     int i = 1;
     double sum = 0, sumsq = 0, sumabs = 0;
@@ -37,7 +37,7 @@
 }
 
 
-void eqdrt(double vectx[], double vecty[], int i1, int i2, double *vabc)
+void AS_eqdrt(double vectx[], double vecty[], int i1, int i2, double *vabc)
 {
     double bn = 0, bd = 0, x1 = 0, y1 = 0;
 

Modified: grass/branches/releasebranch_7_0/lib/arraystats/class.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/arraystats/class.c	2015-01-01 19:45:14 UTC (rev 63911)
+++ grass/branches/releasebranch_7_0/lib/arraystats/class.c	2015-01-01 19:55:13 UTC (rev 63912)
@@ -3,32 +3,55 @@
 #include <grass/glocale.h>
 #include <grass/arraystats.h>
 
-double class_apply_algorithm(char *algo, double *data, int nrec, int *nbreaks,
-			     double *classbreaks)
+int AS_option_to_algorithm(const struct Option * option)
 {
+    if (G_strcasecmp(option->answer, "int") == 0)
+        return CLASS_INTERVAL;
+    if (G_strcasecmp(option->answer, "std") == 0)
+        return CLASS_STDEV;
+    if (G_strcasecmp(option->answer, "qua") == 0)
+        return CLASS_QUANT;
+    if (G_strcasecmp(option->answer, "equ") == 0)
+        return CLASS_EQUIPROB;
+    if (G_strcasecmp(option->answer, "dis") == 0)
+        return CLASS_DISCONT;
+
+    G_fatal_error(_("Unknown algorithm '%s'"), option->answer);
+}
+    
+double AS_class_apply_algorithm(int algo, double *data, int nrec, int *nbreaks,
+                                double *classbreaks)
+{
     double finfo = 0.0;
 
-    if (G_strcasecmp(algo, "int") == 0)
-	finfo = class_interval(data, nrec, *nbreaks, classbreaks);
-    else if (G_strcasecmp(algo, "std") == 0)
-	finfo = class_stdev(data, nrec, *nbreaks, classbreaks);
-    else if (G_strcasecmp(algo, "qua") == 0)
-	finfo = class_quant(data, nrec, *nbreaks, classbreaks);
-    else if (G_strcasecmp(algo, "equ") == 0)
-	finfo = class_equiprob(data, nrec, nbreaks, classbreaks);
-    else if (G_strcasecmp(algo, "dis") == 0)
-	    /*	finfo = class_discont(data, nrec, *nbreaks, classbreaks); disabled because of bugs */
+    switch (algo) {
+    case CLASS_INTERVAL:
+        finfo = AS_class_interval(data, nrec, *nbreaks, classbreaks);
+        break;
+    case CLASS_STDEV:
+        finfo = AS_class_stdev(data, nrec, *nbreaks, classbreaks);
+        break;
+    case CLASS_QUANT:
+        finfo = AS_class_quant(data, nrec, *nbreaks, classbreaks);
+        break;
+    case CLASS_EQUIPROB:
+        finfo = AS_class_equiprob(data, nrec, nbreaks, classbreaks);
+        break;
+    case CLASS_DISCONT:
+        /*	finfo = class_discont(data, nrec, *nbreaks, classbreaks); disabled because of bugs */
         G_fatal_error(_("Discont algorithm currently not available because of bugs"));
-    else
-	G_fatal_error(_("%s: Unknown algorithm"), algo);
+        break;
+    default:
+        break;
+    }
 
     if (finfo == 0)
-	G_fatal_error(_("%s: Error in classification algorithm"), algo);
+	G_fatal_error(_("Classification algorithm failed"));
 
     return finfo;
 }
 
-int class_interval(double *data, int count, int nbreaks, double *classbreaks)
+int AS_class_interval(double *data, int count, int nbreaks, double *classbreaks)
 {
     double min, max;
     double step;
@@ -45,14 +68,14 @@
     return (1);
 }
 
-double class_stdev(double *data, int count, int nbreaks, double *classbreaks)
+double AS_class_stdev(double *data, int count, int nbreaks, double *classbreaks)
 {
     struct GASTATS stats;
     int i;
     int nbclass;
     double scale = 1.0;
 
-    basic_stats(data, count, &stats);
+    AS_basic_stats(data, count, &stats);
 
     nbclass = nbreaks + 1;
 
@@ -109,7 +132,7 @@
     return (scale);
 }
 
-int class_quant(double *data, int count, int nbreaks, double *classbreaks)
+int AS_class_quant(double *data, int count, int nbreaks, double *classbreaks)
 {
     int i, step;
 
@@ -122,7 +145,7 @@
 }
 
 
-int class_equiprob(double *data, int count, int *nbreaks, double *classbreaks)
+int AS_class_equiprob(double *data, int count, int *nbreaks, double *classbreaks)
 {
     int i, j;
     double *lequi;		/*Vector of scale factors for probabilities of the normal distribution */
@@ -201,11 +224,10 @@
 	lequi[8] = 1.28155;
     }
     else {
-	G_fatal_error
-	    ("Equiprobable classbreaks currently limited to 10 classes");
+	G_fatal_error(_("Equiprobable classbreaks currently limited to 10 classes"));
     }
 
-    basic_stats(data, count, &stats);
+    AS_basic_stats(data, count, &stats);
 
     /* Check if any of the classbreaks would fall outside of the range min-max */
     j = 0;
@@ -242,7 +264,7 @@
 
 /* FIXME: there seems to a problem with array overflow, probably due to
    the fact that the code was ported from fortran which has 1-based arrays*/
-double class_discont(double *data, int count, int nbreaks,
+double AS_class_discont(double *data, int count, int nbreaks,
 		     double *classbreaks)
 {
     int *num, nbclass;
@@ -319,7 +341,7 @@
 	    nd = nf;		/*Start number */
 	    nf = num[j];
 	    co[j] = 10e37;
-	    eqdrt(x, xn, nd, nf, abc);
+	    AS_eqdrt(x, xn, nd, nf, abc);
 	    den = sqrt(pow(abc[1], 2) + 1.0);
 	    nd++;
 	    /*              Loop through observations */
@@ -422,7 +444,7 @@
     return (chi2);
 }
 
-int class_frequencies(double *data, int count, int nbreaks,
+int AS_class_frequencies(double *data, int count, int nbreaks,
 		      double *classbreaks, int *frequencies)
 {
     int i, j;

Modified: grass/branches/releasebranch_7_0/vector/v.class/main.c
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.class/main.c	2015-01-01 19:45:14 UTC (rev 63911)
+++ grass/branches/releasebranch_7_0/vector/v.class/main.c	2015-01-01 19:55:13 UTC (rev 63912)
@@ -163,10 +163,11 @@
      * finfo takes any info coming from the classification algorithms
      * equ algorithm can alter number of class breaks */
     finfo =
-	class_apply_algorithm(algo_opt->answer, data, nrec, &nbreaks,
-			      classbreaks);
+        AS_class_apply_algorithm(AS_option_to_algorithm(algo_opt),
+                                 data, nrec, &nbreaks,
+                                 classbreaks);
+    
 
-
     if (G_strcasecmp(algo_opt->answer, "dis") == 0 && finfo < 3.84148)
 	G_warning(_("The discontinuities algorithm indicates that some "
 		    "class breaks are not statistically significant at "
@@ -187,9 +188,8 @@
 	for (i = 0; i < nbreaks + 1; i++)
 	    frequencies[i] = 0;
 
-	ret =
-	    class_frequencies(data, nrec, nbreaks, classbreaks, frequencies);
-	basic_stats(data, nrec, &stats);
+	ret = AS_class_frequencies(data, nrec, nbreaks, classbreaks, frequencies);
+	AS_basic_stats(data, nrec, &stats);
 
 	min = data[0];
 	max = data[nrec - 1];



More information about the grass-commit mailing list