[GRASS-SVN] r56244 - in grass-addons/grass7/raster/r.fuzzy: r.fuzzy.logic r.fuzzy.set r.fuzzy.system

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 13 18:20:44 PDT 2013


Author: hamish
Date: 2013-05-13 18:20:44 -0700 (Mon, 13 May 2013)
New Revision: 56244

Modified:
   grass-addons/grass7/raster/r.fuzzy/r.fuzzy.logic/local_proto.h
   grass-addons/grass7/raster/r.fuzzy/r.fuzzy.logic/logic.c
   grass-addons/grass7/raster/r.fuzzy/r.fuzzy.logic/main.c
   grass-addons/grass7/raster/r.fuzzy/r.fuzzy.set/fuzzy.c
   grass-addons/grass7/raster/r.fuzzy/r.fuzzy.set/local_proto.h
   grass-addons/grass7/raster/r.fuzzy/r.fuzzy.set/main.c
   grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/fuzzylogic.c
   grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/helpers.c
   grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/io.c
   grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/local_proto.h
   grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/main.c
   grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/map_parser.c
   grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/rule_parser.c
   grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/system.c
Log:
run trunk/grass_indent.sh:
indent -npro -bad -bap -bbb -br -bli0 -bls -cli0 -ncs -fc1 -hnl -i4 \
       -nbbo -nbc -nbfda -nbfde -ncdb -ncdw -nce -nfca -npcs -nprs \
       -npsl -nsc -nsob -saf -sai -saw -sbi0 -ss -ts8 -ut


Modified: grass-addons/grass7/raster/r.fuzzy/r.fuzzy.logic/local_proto.h
===================================================================
--- grass-addons/grass7/raster/r.fuzzy/r.fuzzy.logic/local_proto.h	2013-05-14 01:15:07 UTC (rev 56243)
+++ grass-addons/grass7/raster/r.fuzzy/r.fuzzy.logic/local_proto.h	2013-05-14 01:20:44 UTC (rev 56244)
@@ -7,15 +7,15 @@
 #include <grass/glocale.h>
 
 #define _AND	1
-#define _OR		2
+#define _OR	2
 #define _NOT	3
 #define _IMP	4
 
 #define ZADEH 			1
-#define PRODUCT			2	
+#define PRODUCT			2
 #define DRASTIC			3
-#define LUKASIEWICZ	4
-#define FODOR				5
+#define LUKASIEWICZ		4
+#define FODOR			5
 #define HAMACHER		6
 
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
@@ -26,4 +26,3 @@
 float f_or(float cellx, float celly, int family);
 float f_imp(float cellx, float celly, int family);
 float f_not(float cellx, int family);
-

Modified: grass-addons/grass7/raster/r.fuzzy/r.fuzzy.logic/logic.c
===================================================================
--- grass-addons/grass7/raster/r.fuzzy/r.fuzzy.logic/logic.c	2013-05-14 01:15:07 UTC (rev 56243)
+++ grass-addons/grass7/raster/r.fuzzy/r.fuzzy.logic/logic.c	2013-05-14 01:20:44 UTC (rev 56244)
@@ -2,104 +2,107 @@
 #include <grass/glocale.h>
 #include "local_proto.h"
 
-float f_and(float x, float y, int family) {
+float f_and(float x, float y, int family)
+{
 
-	switch (family) {
-		
-			case ZADEH:
-		return MIN(x,y);
-			break;
-		
-			case PRODUCT:
-		return x*y;
-			break;	
-		
-			case DRASTIC:
-		return MAX(x, y) == 1 ? MIN(x, y) : 0;
-			break;	
-		
-			case LUKASIEWICZ:
-		return MAX((x+y-1),0);
-			break;
-		
-			case FODOR:
-		return (x+y)>1 ? MIN(x,y) : 0;	
-			break;
-			
-			case HAMACHER:
-		return (x==y==0) ? 0 : (x*y)/((x+y)-x*y);	
-			break;
-			
+    switch (family) {
 
-				
-	}
-	return -1; /* error */
-}
+    case ZADEH:
+	return MIN(x, y);
+	break;
 
-float f_or(float x, float y, int family) {
-			float b;
-	switch (family) {
-		
-			case ZADEH:
-		return MAX(x,y);
-			break;
-		
-			case PRODUCT:
-		return x + y -x * y;
-			break;	
-		
-			case DRASTIC:
-		return (MIN(x, y) == 0) ? MAX(x, y) : 1;
-			break;	
-		
-			case LUKASIEWICZ:
-		return MIN((x+y),1);
-			break;
-	
-			case FODOR:
-		return (x+y<1) ? MAX(x,y) : 1;		
-			break;
-			
-			case HAMACHER:
-		return (x+y)/(1+x*y);
-			break;
-	}
-	return -1; /* error */
+    case PRODUCT:
+	return x * y;
+	break;
+
+    case DRASTIC:
+	return MAX(x, y) == 1 ? MIN(x, y) : 0;
+	break;
+
+    case LUKASIEWICZ:
+	return MAX((x + y - 1), 0);
+	break;
+
+    case FODOR:
+	return (x + y) > 1 ? MIN(x, y) : 0;
+	break;
+
+    case HAMACHER:
+	return (x == y == 0) ? 0 : (x * y) / ((x + y) - x * y);
+	break;
+
+
+
+    }
+    return -1;			/* error */
 }
 
-float f_imp(float x, float y, int family) {
-		
-	switch (family) {
-			
-			case ZADEH:
-		return (x <= y) ? 1 : y;
-			break;
+float f_or(float x, float y, int family)
+{
+    float b;
 
-			case PRODUCT:
-		return MIN(y/x,1);
-			break;	
-		
-			case DRASTIC:
-		return -1; /* not avaialble */	
-			break;	
-			
-			case LUKASIEWICZ:
-		return MIN((1-x+y),1);	
-			break;
-			
-			case FODOR:
-		return (x<=y) ? 1 : MAX(1-x,y);		
-			break;
-	}
-	return -1; /* error */	
+    switch (family) {
+
+    case ZADEH:
+	return MAX(x, y);
+	break;
+
+    case PRODUCT:
+	return x + y - x * y;
+	break;
+
+    case DRASTIC:
+	return (MIN(x, y) == 0) ? MAX(x, y) : 1;
+	break;
+
+    case LUKASIEWICZ:
+	return MIN((x + y), 1);
+	break;
+
+    case FODOR:
+	return (x + y < 1) ? MAX(x, y) : 1;
+	break;
+
+    case HAMACHER:
+	return (x + y) / (1 + x * y);
+	break;
+    }
+    return -1;			/* error */
 }
 
-float f_not(float x, int family) {
-	
-		if (family==HAMACHER)
-	return (1-x)/(1+x);
-		else
-	return ((1-x)<0 || (1-x)>1) ? -1 : 1-x;
+float f_imp(float x, float y, int family)
+{
+
+    switch (family) {
+
+    case ZADEH:
+	return (x <= y) ? 1 : y;
+	break;
+
+    case PRODUCT:
+	return MIN(y / x, 1);
+	break;
+
+    case DRASTIC:
+	return -1;		/* not avaialble */
+	break;
+
+    case LUKASIEWICZ:
+	return MIN((1 - x + y), 1);
+	break;
+
+    case FODOR:
+	return (x <= y) ? 1 : MAX(1 - x, y);
+	break;
+    }
+    return -1;			/* error */
 }
 
+float f_not(float x, int family)
+{
 
+    if (family == HAMACHER)
+	return (1 - x) / (1 + x);
+    else
+	return ((1 - x) < 0 || (1 - x) > 1) ? -1 : 1 - x;
+}

Modified: grass-addons/grass7/raster/r.fuzzy/r.fuzzy.logic/main.c
===================================================================
--- grass-addons/grass7/raster/r.fuzzy/r.fuzzy.logic/main.c	2013-05-14 01:15:07 UTC (rev 56243)
+++ grass-addons/grass7/raster/r.fuzzy/r.fuzzy.logic/main.c	2013-05-14 01:20:44 UTC (rev 56244)
@@ -20,221 +20,224 @@
 int main(int argc, char *argv[])
 {
 
-	struct GModule *module;
-	struct Option *par_inputx,
-								*par_inputy,
-								*par_output,
-								*par_operation,
-								*par_family;
-	
-	struct Cell_head cellhdx;
-	struct Cell_head cellhdy;  
-  struct FPRange membership_range;
-  struct History history;
+    struct GModule *module;
+    struct Option *par_inputx,
+	*par_inputy, *par_output, *par_operation, *par_family;
 
-	char *mapsetx, *mapsety;
-	char *inputx, *inputy;
-	char *output;
-	int nrows, ncols;
-	int row, col;
-	int infdx, infdy, outfd;
-	void *in_bufx, *in_bufy;
-	unsigned char *out_buf;
-	float tmp;
-	DCELL c_min, c_max;
-	int family, operator;
-	
-	G_gisinit(argv[0]);
-	
+    struct Cell_head cellhdx;
+    struct Cell_head cellhdy;
+    struct FPRange membership_range;
+    struct History history;
+
+    char *mapsetx, *mapsety;
+    char *inputx, *inputy;
+    char *output;
+    int nrows, ncols;
+    int row, col;
+    int infdx, infdy, outfd;
+    void *in_bufx, *in_bufy;
+    unsigned char *out_buf;
+    float tmp;
+    DCELL c_min, c_max;
+    int family, operator;
+
+    G_gisinit(argv[0]);
+
     module = G_define_module();
     module->keywords = _("raster, fuzzy logic");
-    module->description =
-        _("xxxx");
+    module->description = _("xxxx");
 
-	par_inputx = G_define_standard_option(G_OPT_R_INPUT);
+    par_inputx = G_define_standard_option(G_OPT_R_INPUT);
     par_inputx->description = _("x operand (membership map)");
     par_inputx->key = "xmap";
-  
+
     par_inputy = G_define_standard_option(G_OPT_R_INPUT);
     par_inputy->description = _("y operand (membership map)");
     par_inputy->key = "ymap";
     par_inputy->required = NO;
-  
+
     par_output = G_define_standard_option(G_OPT_R_OUTPUT);
-	par_output->description = _("Resulting map");
+    par_output->description = _("Resulting map");
 
-	par_operation=G_define_option();
-	par_operation->key = "operator";
-	par_operation->type = TYPE_STRING;
-	par_operation->options = "AND,OR,NOT,IMP";
-	par_operation->answer = "AND";
-	par_operation->multiple = NO;
-	par_operation->required = YES;
-	par_operation->description = _("Fuzzy logic operation");
-	
-	par_family=G_define_option();
-	par_family->key = "family";
-	par_family->type = TYPE_STRING;
-	par_family->options = "Zadeh,product,drastic,Lukasiewicz,Fodor,Hamacher";
-	par_family->answer = "Zadeh";
-	par_family->multiple = NO;
-	par_family->required = YES;
-	par_family->description = _("Fuzzy logic family");
-	
-  	if (G_parser(argc, argv))
+    par_operation = G_define_option();
+    par_operation->key = "operator";
+    par_operation->type = TYPE_STRING;
+    par_operation->options = "AND,OR,NOT,IMP";
+    par_operation->answer = "AND";
+    par_operation->multiple = NO;
+    par_operation->required = YES;
+    par_operation->description = _("Fuzzy logic operation");
+
+    par_family = G_define_option();
+    par_family->key = "family";
+    par_family->type = TYPE_STRING;
+    par_family->options = "Zadeh,product,drastic,Lukasiewicz,Fodor,Hamacher";
+    par_family->answer = "Zadeh";
+    par_family->multiple = NO;
+    par_family->required = YES;
+    par_family->description = _("Fuzzy logic family");
+
+    if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
-	
-	inputx=par_inputx->answer;
-	inputy=par_inputy->answer;
-	output=par_output->answer;
-	
-			if (!strcmp(par_operation->answer, "AND"))
-	operator=_AND;
-		else if (!strcmp(par_operation->answer, "OR"))
-	operator=_OR;
-		else if (!strcmp(par_operation->answer, "NOT"))
-	operator=_NOT;
-		else if (!strcmp(par_operation->answer, "IMP"))
-	operator=_IMP;
-	  
-  		if (!strcmp(par_family->answer, "Zadeh"))
-	family=ZADEH;
-		else if (!strcmp(par_family->answer, "product"))
-	family=PRODUCT;
-		else if (!strcmp(par_family->answer, "drastic"))
-	family=DRASTIC;
-		else if (!strcmp(par_family->answer, "Lukasiewicz"))
-	family=LUKASIEWICZ;
-		else if (!strcmp(par_family->answer, "Fodor"))
-	family=FODOR;
-			else if (!strcmp(par_family->answer, "Hamacher"))
-	family=HAMACHER;
-	
-		if(operator == _NOT && inputy)
+
+    inputx = par_inputx->answer;
+    inputy = par_inputy->answer;
+    output = par_output->answer;
+
+    if (!strcmp(par_operation->answer, "AND"))
+	operator= _AND;
+
+    else if (!strcmp(par_operation->answer, "OR"))
+	operator= _OR;
+
+    else if (!strcmp(par_operation->answer, "NOT"))
+	operator= _NOT;
+
+    else if (!strcmp(par_operation->answer, "IMP"))
+	operator= _IMP;
+
+    if (!strcmp(par_family->answer, "Zadeh"))
+	family = ZADEH;
+    else if (!strcmp(par_family->answer, "product"))
+	family = PRODUCT;
+    else if (!strcmp(par_family->answer, "drastic"))
+	family = DRASTIC;
+    else if (!strcmp(par_family->answer, "Lukasiewicz"))
+	family = LUKASIEWICZ;
+    else if (!strcmp(par_family->answer, "Fodor"))
+	family = FODOR;
+    else if (!strcmp(par_family->answer, "Hamacher"))
+	family = HAMACHER;
+
+    if (operator == _NOT && inputy)
 	G_warning("Negation is unary operaton ymap is ignored");
-	
-		if(operator != _NOT && !inputy)
+
+    if (operator != _NOT && !inputy)
 	G_fatal_error("For binary operation (AND, OR, IMP) ymap is required");
-	
-		if(family == DRASTIC && operator == _IMP)
-  G_fatal_error("implication is not available for <drastic> family");
-	
-	/* end of interface */
-	
-	mapsetx = (char *)G_find_raster2(inputx, "");
-	
-	  if (mapsetx == NULL)
+
+    if (family == DRASTIC && operator == _IMP)
+	G_fatal_error("implication is not available for <drastic> family");
+
+    /* end of interface */
+
+    mapsetx = (char *)G_find_raster2(inputx, "");
+
+    if (mapsetx == NULL)
 	G_fatal_error(_("Raster map <%s> not found"), inputx);
-	
-	infdx = Rast_open_old(inputx, mapsetx);
-	Rast_get_cellhd(inputx, mapsetx, &cellhdx);
-	
-		if (Rast_map_type(inputx, mapsetx) != FCELL_TYPE)
-	 G_fatal_error(_("<%s> is not of type CELL"), inputx);
-	 
-	Rast_init_fp_range(&membership_range);
-	Rast_read_fp_range(inputx,mapsetx,&membership_range);
-	Rast_get_fp_range_min_max(&membership_range, &c_min, &c_max);
-		if(c_min<0 || c_max>1)
+
+    infdx = Rast_open_old(inputx, mapsetx);
+    Rast_get_cellhd(inputx, mapsetx, &cellhdx);
+
+    if (Rast_map_type(inputx, mapsetx) != FCELL_TYPE)
+	G_fatal_error(_("<%s> is not of type CELL"), inputx);
+
+    Rast_init_fp_range(&membership_range);
+    Rast_read_fp_range(inputx, mapsetx, &membership_range);
+    Rast_get_fp_range_min_max(&membership_range, &c_min, &c_max);
+    if (c_min < 0 || c_max > 1)
 	G_fatal_error("Membership out of range");
-	
-	in_bufx = Rast_allocate_buf(FCELL_TYPE);
-	
-		if(inputy) {
-	
+
+    in_bufx = Rast_allocate_buf(FCELL_TYPE);
+
+    if (inputy) {
+
 	mapsety = (char *)G_find_raster2(inputy, "");
-	
-	  if (mapsety == NULL)
-	G_fatal_error(_("Raster map <%s> not found"), inputy);
-	
+
+	if (mapsety == NULL)
+	    G_fatal_error(_("Raster map <%s> not found"), inputy);
+
 	infdy = Rast_open_old(inputy, mapsety);
 	Rast_get_cellhd(inputy, mapsety, &cellhdy);
 
-		if (Rast_map_type(inputy, mapsety) != FCELL_TYPE);
+	if (Rast_map_type(inputy, mapsety) != FCELL_TYPE) ;
 	G_fatal_error(_("<%s> is not of type CELL"), inputy);
-	
+
 	Rast_init_fp_range(&membership_range);
-	Rast_read_fp_range(inputy,mapsety,&membership_range);
+	Rast_read_fp_range(inputy, mapsety, &membership_range);
 	Rast_get_fp_range_min_max(&membership_range, &c_min, &c_max);
-		if(c_min<0 || c_max>1)
-	G_fatal_error("Membership out of range");
-	
-	
+	if (c_min < 0 || c_max > 1)
+	    G_fatal_error("Membership out of range");
+
+
 	in_bufy = Rast_allocate_buf(FCELL_TYPE);
-		
-		} /* end if inputy */
-	
-	nrows = Rast_window_rows();
-	ncols = Rast_window_cols();
 
-	outfd = Rast_open_new(output, FCELL_TYPE);
-	out_buf = Rast_allocate_buf(FCELL_TYPE);
-	
-	
-	/* binary processing */
-	for (row = 0; row < nrows; row++) {
-		G_percent(row, nrows, 2);
-		
-		FCELL fx, fy=0;
-		
-		Rast_get_row(infdx, in_bufx, row, FCELL_TYPE);
-		
-			if(inputy)
-		Rast_get_row(infdy, in_bufy, row, FCELL_TYPE);
-		
-		for (col = 0; col < ncols; col++) {
-				
-				fx = ((FCELL *) in_bufx)[col];
-					if(inputy)
-				fy = ((FCELL *) in_bufy)[col];
+    }				/* end if inputy */
 
-				 if (Rast_is_f_null_value(&fx) || Rast_is_f_null_value(&fy))
-			Rast_set_f_null_value(&tmp, 1); 
-				 
-				 else
-			
-			switch (operator) {
-				case _AND:
-					//if((row+col)%100==0)
-						if(0>(tmp = f_and(fx,fy,family)))
-					G_warning("Cannot determine result at row %d, col %d", row,col);
-					break;
-				
-				case _OR:
-						if(0>(tmp=f_or(fx,fy,family)))
-					G_warning("Cannot determine result at row %d, col %d", row,col);
-					break;
-					
-				case _IMP:
-						if((tmp=f_imp(fx,fy,family))<0)
-					G_warning("Cannot determine result at row %d, col %d", row,col);
-					break;	
-				
-				case _NOT:
-						if((tmp=f_not(fx, family))<0)
-					G_warning("Cannot determine result at row %d, col %d", row,col);
-					break;
-			} /* end switch */
-			
-			((FCELL *) out_buf)[col] = tmp;
-		}
-		Rast_put_row(outfd, out_buf, FCELL_TYPE);
-	} /* end for row */
-	
-  G_free(in_bufx);
-	Rast_close(infdx);
-	
-		if(inputy) {
-  G_free(in_bufy);
-  Rast_close(infdy);
+    nrows = Rast_window_rows();
+    ncols = Rast_window_cols();
+
+    outfd = Rast_open_new(output, FCELL_TYPE);
+    out_buf = Rast_allocate_buf(FCELL_TYPE);
+
+
+    /* binary processing */
+    for (row = 0; row < nrows; row++) {
+	G_percent(row, nrows, 2);
+
+	FCELL fx, fy = 0;
+
+	Rast_get_row(infdx, in_bufx, row, FCELL_TYPE);
+
+	if (inputy)
+	    Rast_get_row(infdy, in_bufy, row, FCELL_TYPE);
+
+	for (col = 0; col < ncols; col++) {
+
+	    fx = ((FCELL *) in_bufx)[col];
+	    if (inputy)
+		fy = ((FCELL *) in_bufy)[col];
+
+	    if (Rast_is_f_null_value(&fx) || Rast_is_f_null_value(&fy))
+		Rast_set_f_null_value(&tmp, 1);
+
+	    else
+
+		switch (operator) {
+		case _AND:
+		    //if((row+col)%100==0)
+		    if (0 > (tmp = f_and(fx, fy, family)))
+			G_warning("Cannot determine result at row %d, col %d",
+				  row, col);
+		    break;
+
+		case _OR:
+		    if (0 > (tmp = f_or(fx, fy, family)))
+			G_warning("Cannot determine result at row %d, col %d",
+				  row, col);
+		    break;
+
+		case _IMP:
+		    if ((tmp = f_imp(fx, fy, family)) < 0)
+			G_warning("Cannot determine result at row %d, col %d",
+				  row, col);
+		    break;
+
+		case _NOT:
+		    if ((tmp = f_not(fx, family)) < 0)
+			G_warning("Cannot determine result at row %d, col %d",
+				  row, col);
+		    break;
+		}		/* end switch */
+
+	    ((FCELL *) out_buf)[col] = tmp;
 	}
-	
-	G_free(out_buf);
-	Rast_close(outfd);
+	Rast_put_row(outfd, out_buf, FCELL_TYPE);
+    }				/* end for row */
 
-	Rast_short_history(output, "raster", &history);
-	Rast_command_history(&history);
-	Rast_write_history(output, &history);
-	
-	exit(EXIT_SUCCESS);
+    G_free(in_bufx);
+    Rast_close(infdx);
+
+    if (inputy) {
+	G_free(in_bufy);
+	Rast_close(infdy);
+    }
+
+    G_free(out_buf);
+    Rast_close(outfd);
+
+    Rast_short_history(output, "raster", &history);
+    Rast_command_history(&history);
+    Rast_write_history(output, &history);
+
+    exit(EXIT_SUCCESS);
 }

Modified: grass-addons/grass7/raster/r.fuzzy/r.fuzzy.set/fuzzy.c
===================================================================
--- grass-addons/grass7/raster/r.fuzzy/r.fuzzy.set/fuzzy.c	2013-05-14 01:15:07 UTC (rev 56243)
+++ grass-addons/grass7/raster/r.fuzzy/r.fuzzy.set/fuzzy.c	2013-05-14 01:20:44 UTC (rev 56244)
@@ -1,52 +1,53 @@
 #include <grass/glocale.h>
 #include "local_proto.h"
 
-float fuzzy (FCELL cell) {
+float fuzzy(FCELL cell)
+{
 
-	float x, m;
-	
-	if (!side) { /* both left and right */
-	
-			if (cell <= p[0] || cell >= p[3])
-		return 0.;
-			if (cell >= p[1] && cell <= p[2])
-		return 1.;	
+    float x, m;
 
-		x = (cell<p[1]) ? (cell-p[0])/(p[1]-p[0])
-				: (p[3]-cell)/(p[3]-p[2]);
-	}
-	
-	if (side) { /* left: 1 OR right: 2 */
+    if (!side) {		/* both left and right */
 
-			if (cell <= p[0])
-		return (side == 1) ? 0. : 1.;
-			if (cell >= p[1])
-		return (side == 1) ? 1. : 0.;
-	
-		x = (side == 1) ? (cell-p[0])/(p[1]-p[0])
-				: (p[1]-cell)/(p[1]-p[0]);
-	}
+	if (cell <= p[0] || cell >= p[3])
+	    return 0.;
+	if (cell >= p[1] && cell <= p[2])
+	    return 1.;
 
-		if (type == LINEAR)
+	x = (cell < p[1]) ? (cell - p[0]) / (p[1] - p[0])
+	    : (p[3] - cell) / (p[3] - p[2]);
+    }
+
+    if (side) {			/* left: 1 OR right: 2 */
+
+	if (cell <= p[0])
+	    return (side == 1) ? 0. : 1.;
+	if (cell >= p[1])
+	    return (side == 1) ? 1. : 0.;
+
+	x = (side == 1) ? (cell - p[0]) / (p[1] - p[0])
+	    : (p[1] - cell) / (p[1] - p[0]);
+    }
+
+    if (type == LINEAR)
 	return x;
-		
-		if (type == JSHAPE) {
-	m = (shape < 0) ? pow(2,1+shape) 
-			: pow(2,exp(2*shape));	
-	return pow(tan(x * PI4),m);
-		}
-		
-		if (type == GSHAPE) {
-	m = (shape > 0) ? pow(2,1-shape) 
-			: pow(2,exp(-2*shape));	
-	return pow(tan(x * PI4),1/m);	
-		}
-	
-			if(type==SSHAPE) {
-		m =  pow(2,exp(2*abs(shape)));
-		return (shape < 0) ? pow(1-cos(x*PI2),m)
-			: pow(sin(x*PI2),m);
-	}
 
-return -1; /* error */
+    if (type == JSHAPE) {
+	m = (shape < 0) ? pow(2, 1 + shape)
+	    : pow(2, exp(2 * shape));
+	return pow(tan(x * PI4), m);
+    }
+
+    if (type == GSHAPE) {
+	m = (shape > 0) ? pow(2, 1 - shape)
+	    : pow(2, exp(-2 * shape));
+	return pow(tan(x * PI4), 1 / m);
+    }
+
+    if (type == SSHAPE) {
+	m = pow(2, exp(2 * abs(shape)));
+	return (shape < 0) ? pow(1 - cos(x * PI2), m)
+	    : pow(sin(x * PI2), m);
+    }
+
+    return -1;			/* error */
 }

Modified: grass-addons/grass7/raster/r.fuzzy/r.fuzzy.set/local_proto.h
===================================================================
--- grass-addons/grass7/raster/r.fuzzy/r.fuzzy.set/local_proto.h	2013-05-14 01:15:07 UTC (rev 56243)
+++ grass-addons/grass7/raster/r.fuzzy/r.fuzzy.set/local_proto.h	2013-05-14 01:20:44 UTC (rev 56244)
@@ -6,18 +6,18 @@
 #include <grass/gis.h>
 #include <grass/glocale.h>
 /*
-PI2= PI/2
-PI4= PI/4
-*/
+   PI2= PI/2
+   PI4= PI/4
+ */
 #ifndef PI2
-	#define PI2 (2*atan(1))
+#define PI2 (2*atan(1))
 #endif
 
 #ifndef PI4
-	#define PI4 (atan(1))
+#define PI4 (atan(1))
 #endif
-	
 
+
 #define LINEAR 0
 #define SSHAPE 1
 #define JSHAPE 2
@@ -30,7 +30,7 @@
 extern char *input, *output;
 extern float shape, height;
 extern int type, side;
-extern double p[4]; /* inflection points */
+extern double p[4];		/* inflection points */
 extern int num_points;
 
-float fuzzy (FCELL cell);
+float fuzzy(FCELL cell);

Modified: grass-addons/grass7/raster/r.fuzzy/r.fuzzy.set/main.c
===================================================================
--- grass-addons/grass7/raster/r.fuzzy/r.fuzzy.set/main.c	2013-05-14 01:15:07 UTC (rev 56243)
+++ grass-addons/grass7/raster/r.fuzzy/r.fuzzy.set/main.c	2013-05-14 01:20:44 UTC (rev 56244)
@@ -20,220 +20,221 @@
 char *input, *output;
 float shape, height;
 int type, side;
-double p[4]; /* inflection points */
+double p[4];			/* inflection points */
 int num_points;
 
 int main(int argc, char *argv[])
 {
-	struct GModule *module;
-	struct Option *par_input,
-								*par_output,
-								*par_points,
-								*par_side,
-								*par_type,
-								*par_height,
-								*par_shape;
-	
-	struct Cell_head cellhd; 
-  struct History history;
-	
-	
-	char *mapset;
-	int nrows, ncols;
-  int row, col;
-  int infd, outfd;
-  void *in_buf;
-	unsigned char *out_buf;
-  RASTER_MAP_TYPE raster_type;
-  FCELL tmp=0;
-	
-	G_gisinit(argv[0]);	
-	
-	par_input = G_define_standard_option(G_OPT_R_INPUT);
-  par_input->description = _("Raster map to be fuzzified");
-  
-  par_output = G_define_standard_option(G_OPT_R_OUTPUT);
-	par_output->description = _("Membership map");
-	
-	par_points=G_define_option();
-	par_points->key = "points";
-	par_points->type = TYPE_STRING;
-	par_points->answer = "a,b[,c,d]";
-	par_points->multiple = YES;
-	par_points->required = YES;
-	par_points->description = _("Inflection points: a,b[,c,d]");
-	
-	par_side=G_define_option();
-	par_side->key = "side";
-	par_side->type = TYPE_STRING;
-	par_side->options = "both,left,right";
-	par_side->answer = "both";
-	par_side->multiple = NO;
-	par_side->required = YES;
-	par_side->description = _("Fuzzy range");
-	
-	par_type=G_define_option();
-	par_type->key = "boundary";
-	par_type->type = TYPE_STRING;
-	par_type->options = "Linear,S-shaped,J-shaped,G-shaped";
-	par_type->answer = "S-shaped";
-	par_type->multiple = NO;
-	par_type->required = YES;
-	par_type->description = _("Type of fuzzy boundaries");
-	par_type->guisection = _("Default options");
-	
-	par_shape=G_define_option();
-	par_shape->key = "shape";
-	par_shape->type = TYPE_DOUBLE;
-	par_shape->options = "-1,1";
-	par_shape->answer = "0.";
-	par_shape->multiple = NO;
-	par_shape->required = YES;
-	par_shape->description = _("Shape modifier: -1 to 1");
-	par_shape->guisection = _("Default options");
-	
-	par_height=G_define_option();
-	par_height->key = "height";
-	par_height->type = TYPE_DOUBLE;
-	par_height->options = "0,1";
-	par_height->answer = "1.";
-	par_height->multiple = NO;
-	par_height->required = YES;
-	par_height->description = _("Membership height: 0 to 1");
-	par_height->guisection = _("Default options");
-	
-	    if (G_parser(argc, argv))
+    struct GModule *module;
+    struct Option *par_input,
+	*par_output,
+	*par_points, *par_side, *par_type, *par_height, *par_shape;
+
+    struct Cell_head cellhd;
+    struct History history;
+
+
+    char *mapset;
+    int nrows, ncols;
+    int row, col;
+    int infd, outfd;
+    void *in_buf;
+    unsigned char *out_buf;
+    RASTER_MAP_TYPE raster_type;
+    FCELL tmp = 0;
+
+    G_gisinit(argv[0]);
+
+    par_input = G_define_standard_option(G_OPT_R_INPUT);
+    par_input->description = _("Raster map to be fuzzified");
+
+    par_output = G_define_standard_option(G_OPT_R_OUTPUT);
+    par_output->description = _("Membership map");
+
+    par_points = G_define_option();
+    par_points->key = "points";
+    par_points->type = TYPE_STRING;
+    par_points->answer = "a,b[,c,d]";
+    par_points->multiple = YES;
+    par_points->required = YES;
+    par_points->description = _("Inflection points: a,b[,c,d]");
+
+    par_side = G_define_option();
+    par_side->key = "side";
+    par_side->type = TYPE_STRING;
+    par_side->options = "both,left,right";
+    par_side->answer = "both";
+    par_side->multiple = NO;
+    par_side->required = YES;
+    par_side->description = _("Fuzzy range");
+
+    par_type = G_define_option();
+    par_type->key = "boundary";
+    par_type->type = TYPE_STRING;
+    par_type->options = "Linear,S-shaped,J-shaped,G-shaped";
+    par_type->answer = "S-shaped";
+    par_type->multiple = NO;
+    par_type->required = YES;
+    par_type->description = _("Type of fuzzy boundaries");
+    par_type->guisection = _("Default options");
+
+    par_shape = G_define_option();
+    par_shape->key = "shape";
+    par_shape->type = TYPE_DOUBLE;
+    par_shape->options = "-1,1";
+    par_shape->answer = "0.";
+    par_shape->multiple = NO;
+    par_shape->required = YES;
+    par_shape->description = _("Shape modifier: -1 to 1");
+    par_shape->guisection = _("Default options");
+
+    par_height = G_define_option();
+    par_height->key = "height";
+    par_height->type = TYPE_DOUBLE;
+    par_height->options = "0,1";
+    par_height->answer = "1.";
+    par_height->multiple = NO;
+    par_height->required = YES;
+    par_height->description = _("Membership height: 0 to 1");
+    par_height->guisection = _("Default options");
+
+    if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
-	
-	input=par_input->answer;
-	output=par_output->answer;
-		
-		if (!strcmp(par_type->answer, "Linear"))
-	type=LINEAR;
-		else if (!strcmp(par_type->answer, "S-shaped"))
-	type=SSHAPE;
-		else if (!strcmp(par_type->answer, "J-shaped"))
-	type=JSHAPE;
-		else if (!strcmp(par_type->answer, "G-shaped"))
-	type=GSHAPE;
-	
-			if (!strcmp(par_side->answer, "both"))
-	side=BOTH;
-		else if (!strcmp(par_side->answer, "left"))
-	side=LEFT;
-		else if (!strcmp(par_side->answer, "right"))
-	side=RIGHT;
-	
-	shape = atof(par_shape->answer);
-		if(shape<-1. || shape>1.)
-	G_fatal_error(_("Shape modifier must be between -1 and 1 but is %f"),shape);
-	
-	height = atof(par_height->answer);
-		if(height>1 || height<0)
-	G_fatal_error(_("Heght modifier must be between 0 and 1 but is %f"),height);
-		
-	num_points=sscanf(par_points->answer,
-			"%lf,%lf,%lf,%lf", 
-			&p[0], &p[1], &p[2], &p[3]);
-	
-		if(!side && num_points != 4)
+
+    input = par_input->answer;
+    output = par_output->answer;
+
+    if (!strcmp(par_type->answer, "Linear"))
+	type = LINEAR;
+    else if (!strcmp(par_type->answer, "S-shaped"))
+	type = SSHAPE;
+    else if (!strcmp(par_type->answer, "J-shaped"))
+	type = JSHAPE;
+    else if (!strcmp(par_type->answer, "G-shaped"))
+	type = GSHAPE;
+
+    if (!strcmp(par_side->answer, "both"))
+	side = BOTH;
+    else if (!strcmp(par_side->answer, "left"))
+	side = LEFT;
+    else if (!strcmp(par_side->answer, "right"))
+	side = RIGHT;
+
+    shape = atof(par_shape->answer);
+    if (shape < -1. || shape > 1.)
+	G_fatal_error(_("Shape modifier must be between -1 and 1 but is %f"),
+		      shape);
+
+    height = atof(par_height->answer);
+    if (height > 1 || height < 0)
+	G_fatal_error(_("Heght modifier must be between 0 and 1 but is %f"),
+		      height);
+
+    num_points = sscanf(par_points->answer,
+			"%lf,%lf,%lf,%lf", &p[0], &p[1], &p[2], &p[3]);
+
+    if (!side && num_points != 4)
 	G_fatal_error(_("Wrong number of values: got %d but need 4"),
 		      num_points);
-	
-			if(side && num_points != 2)
+
+    if (side && num_points != 2)
 	G_fatal_error(_("Wrong number of values: got %d but need 2"),
 		      num_points);
-	
-	if (num_points==2) {
-			if(	p[0]>p[1])
-		G_fatal_error(_("Point sequence must be: a <= b"));
-	} else {
-			if(	p[0]>p[1]||p[1]>p[2]||p[2]>p[3])
-		G_fatal_error(_("Point sequence must be: a <= b; b <= c; c <= d;"));	
-	}
 
-	/* end of interface */
+    if (num_points == 2) {
+	if (p[0] > p[1])
+	    G_fatal_error(_("Point sequence must be: a <= b"));
+    }
+    else {
+	if (p[0] > p[1] || p[1] > p[2] || p[2] > p[3])
+	    G_fatal_error(_("Point sequence must be: a <= b; b <= c; c <= d;"));
+    }
 
-	mapset = (char *)G_find_raster2(input, "");
-	
-	    if (mapset == NULL)
+    /* end of interface */
+
+    mapset = (char *)G_find_raster2(input, "");
+
+    if (mapset == NULL)
 	G_fatal_error(_("Raster map <%s> not found"), input);
-	
-	infd = Rast_open_old(input, mapset);
-	Rast_get_cellhd(input, mapset, &cellhd);
-	
-	nrows = Rast_window_rows();
-	ncols = Rast_window_cols();
-	raster_type = Rast_map_type(input,mapset);
-	
-	outfd = Rast_open_new(output, FCELL_TYPE);
-	
-	in_buf = Rast_allocate_buf(raster_type);
-	out_buf = Rast_allocate_buf(FCELL_TYPE);
-	
-	/* processing */
-	for (row = 0; row < nrows; row++) {
-		G_percent(row, nrows, 2);
-		CELL c;
-		FCELL f;
-		DCELL d;
-		
+
+    infd = Rast_open_old(input, mapset);
+    Rast_get_cellhd(input, mapset, &cellhd);
+
+    nrows = Rast_window_rows();
+    ncols = Rast_window_cols();
+    raster_type = Rast_map_type(input, mapset);
+
+    outfd = Rast_open_new(output, FCELL_TYPE);
+
+    in_buf = Rast_allocate_buf(raster_type);
+    out_buf = Rast_allocate_buf(FCELL_TYPE);
+
+    /* processing */
+    for (row = 0; row < nrows; row++) {
+	G_percent(row, nrows, 2);
+	CELL c;
+	FCELL f;
+	DCELL d;
+
 	Rast_get_row(infd, in_buf, row, raster_type);
 
-		for (col = 0; col < ncols; col++) {
-				 
-			switch (raster_type) {
+	for (col = 0; col < ncols; col++) {
 
-				case CELL_TYPE:
-			c = ((CELL *) in_buf)[col];
-				if(Rast_is_null_value(&c,CELL_TYPE))
-			Rast_set_f_null_value(&tmp, 1);
-				else {
-					if(0>(tmp = fuzzy((FCELL) c)))
-			G_warning("Cannot determine memebership at row %d, col %d", row,col);
-			((FCELL *) out_buf)[col] = tmp;
-				}
-			break;
+	    switch (raster_type) {
 
-				case FCELL_TYPE:
-			f = ((FCELL *) in_buf)[col];
-				if(Rast_is_null_value(&f,FCELL_TYPE))
-			Rast_set_f_null_value(&tmp, 1);
-				else {			
-				tmp = fuzzy((FCELL) f);
-				if(0>(tmp = fuzzy((FCELL) f)))
-			G_warning("Cannot determine memebership at row %d, col %d", row,col);
-			((FCELL *) out_buf)[col] = tmp;
-				}
-			break;
+	    case CELL_TYPE:
+		c = ((CELL *) in_buf)[col];
+		if (Rast_is_null_value(&c, CELL_TYPE))
+		    Rast_set_f_null_value(&tmp, 1);
+		else {
+		    if (0 > (tmp = fuzzy((FCELL) c)))
+			G_warning
+			    ("Cannot determine memebership at row %d, col %d",
+			     row, col);
+		    ((FCELL *) out_buf)[col] = tmp;
+		}
+		break;
 
-				case DCELL_TYPE:
-			d = ((DCELL *) in_buf)[col];
-				if(Rast_is_null_value(&d,DCELL_TYPE))
-			Rast_set_f_null_value(&tmp, 1);
-				else {
-				if(0>(tmp = fuzzy ((FCELL) d)))
-			G_warning("Cannot determine memebership at row %d, col %d", row,col);
-			((FCELL *) out_buf)[col] = tmp;
-				}
-			break;
-	    }
+	    case FCELL_TYPE:
+		f = ((FCELL *) in_buf)[col];
+		if (Rast_is_null_value(&f, FCELL_TYPE))
+		    Rast_set_f_null_value(&tmp, 1);
+		else {
+		    tmp = fuzzy((FCELL) f);
+		    if (0 > (tmp = fuzzy((FCELL) f)))
+			G_warning
+			    ("Cannot determine memebership at row %d, col %d",
+			     row, col);
+		    ((FCELL *) out_buf)[col] = tmp;
 		}
-		Rast_put_row(outfd, out_buf, FCELL_TYPE);
-	} /* end for */
-	
-  G_free(in_buf);
-  G_free(out_buf);
+		break;
 
-	Rast_close(infd);
-	Rast_close(outfd);
+	    case DCELL_TYPE:
+		d = ((DCELL *) in_buf)[col];
+		if (Rast_is_null_value(&d, DCELL_TYPE))
+		    Rast_set_f_null_value(&tmp, 1);
+		else {
+		    if (0 > (tmp = fuzzy((FCELL) d)))
+			G_warning
+			    ("Cannot determine memebership at row %d, col %d",
+			     row, col);
+		    ((FCELL *) out_buf)[col] = tmp;
+		}
+		break;
+	    }
+	}
+	Rast_put_row(outfd, out_buf, FCELL_TYPE);
+    }				/* end for */
 
-	Rast_short_history(output, "raster", &history);
-	Rast_command_history(&history);
-	Rast_write_history(output, &history);
-	
-	exit(EXIT_SUCCESS);
+    G_free(in_buf);
+    G_free(out_buf);
+
+    Rast_close(infd);
+    Rast_close(outfd);
+
+    Rast_short_history(output, "raster", &history);
+    Rast_command_history(&history);
+    Rast_write_history(output, &history);
+
+    exit(EXIT_SUCCESS);
 }
-
-	
-	

Modified: grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/fuzzylogic.c
===================================================================
--- grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/fuzzylogic.c	2013-05-14 01:15:07 UTC (rev 56243)
+++ grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/fuzzylogic.c	2013-05-14 01:20:44 UTC (rev 56244)
@@ -48,8 +48,7 @@
     if (set->hedge)
 	x = (set->hedge > 0) ? pow(x, pow(2, set->hedge)) : pow(x,
 								pow(0.5,
-								    (-set->
-								     hedge)));
+								    (-set->hedge)));
 
     if (set->height < 1)
 	x = x * set->height;
@@ -82,7 +81,7 @@
 	break;
 
     case l_HAMACHER:
-	return (x == 0||y == 0) ? 0 : (x * y) / ((x + y) - x * y);
+	return (x == 0 || y == 0) ? 0 : (x * y) / ((x + y) - x * y);
 	break;
 
 

Modified: grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/helpers.c
===================================================================
--- grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/helpers.c	2013-05-14 01:15:07 UTC (rev 56243)
+++ grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/helpers.c	2013-05-14 01:20:44 UTC (rev 56244)
@@ -34,9 +34,9 @@
 {
     register char *a, *b;
 
-    for (a = b = buf; *a == rem || *a == ' ' || *a == '\t'; a++);
+    for (a = b = buf; *a == rem || *a == ' ' || *a == '\t'; a++) ;
     if (a != b)
-	while ((*b++ = *a++));
+	while ((*b++ = *a++)) ;
 
     return 0;
 }
@@ -84,7 +84,7 @@
     for (i = 0; i < resolution; ++i)
 	universe[i] = min + ((max - min) / resolution) * i;
 
-/* visual output */
+    /* visual output */
 
     return 0;
 }
@@ -99,32 +99,32 @@
     int num_points;
     float result;
 
-		visual_output = (float **)G_malloc(resolution * sizeof(float *));
+    visual_output = (float **)G_malloc(resolution * sizeof(float *));
 
-				for (j = 0; j < nrules; ++j) 
-		for (i = 0; i < resolution; ++i) {
+    for (j = 0; j < nrules; ++j)
+	for (i = 0; i < resolution; ++i) {
 	    visual_output[i] = (float *)G_calloc(nrules + 2, sizeof(float));
 	    visual_output[i][0] = universe[i];
-		}
-			
+	}
+
     Rast_get_window(&window);
     num_points = sscanf(answer, "%lf,%lf", &x, &y);
 
     c = (int)Rast_easting_to_col(x, &window);
     r = (int)Rast_northing_to_row(y, &window);
-    
-		get_rows(r);
+
+    get_rows(r);
     get_cells(c);
-    
-    result = implicate(); /* jump to different function */
 
+    result = implicate();	/* jump to different function */
+
     for (i = 0; i < nrules; ++i)
 	fprintf(stdout, "ANTECEDENT %s: %5.3f\n", s_rules[i].outname,
 		antecedents[i]);
 
-  fprintf(stdout, "RESULT (deffuzified):  %5.3f\n", result);
-  
-  fprintf(stdout, "UNIVERSE,");
+    fprintf(stdout, "RESULT (deffuzified):  %5.3f\n", result);
+
+    fprintf(stdout, "UNIVERSE,");
     for (i = 0; i < nrules; ++i)
 	fprintf(stdout, "%s,", s_rules[i].outname);
     fprintf(stdout, "AGREGATE \n");
@@ -138,133 +138,139 @@
 		fprintf(stdout, "\n");
 	}
 
-			for (i = 0; i < nmaps; ++i) {
+    for (i = 0; i < nmaps; ++i) {
 	G_free(s_maps[i].sets);
 	if (s_maps[i].output)
 	    continue;
-		G_free(s_maps[i].in_buf);
+	G_free(s_maps[i].in_buf);
 	Rast_close(s_maps[i].cfd);
     }
 
-			for (j = 0; j < nrules; ++j)
-				G_free(visual_output[j]);
+    for (j = 0; j < nrules; ++j)
+	G_free(visual_output[j]);
     G_free(visual_output);
-    
+
     G_free(antecedents);
     G_free(s_maps);
     G_free(s_rules);
-   
+
     exit(EXIT_SUCCESS);
 }
 
 
-void show_membership(void) {
-	int i,j,k;
-	STRING cur_mapset;
-	struct FPRange map_range;
-	DCELL min, max;
-	float* map_universe;
-	
-	resolution=resolution+1;
-	map_universe = (float *)G_calloc(resolution, sizeof(float));
+void show_membership(void)
+{
+    int i, j, k;
+    STRING cur_mapset;
+    struct FPRange map_range;
+    DCELL min, max;
+    float *map_universe;
 
-	for(i=0;i<nmaps;++i) {
-		
-		if(s_maps[i].output)
-			continue;
-		Rast_init_fp_range(&map_range);
-		cur_mapset = (STRING)G_find_raster2(s_maps[i].name, "");
-		Rast_read_fp_range(s_maps[i].name,cur_mapset,&map_range);
-		Rast_get_fp_range_min_max(&map_range,&min, &max);
-		
-			for (k = 0; k < resolution; ++k)
-		map_universe[k] = min + ((max - min) / resolution) * k;
-		
-		fprintf(stdout,"#MAP: %s \n",s_maps[i].name);
-		
-		fprintf(stdout,"value,");
-			for(j=0;j<s_maps[i].nsets;++j) {
-		fprintf(stdout,"%s",s_maps[i].sets[j].setname);
-				if (j < s_maps[i].nsets-1)
-			fprintf(stdout, ",");
-				else
-			fprintf(stdout, "\n");
-			}
-			
-			for(k=0;k<resolution;++k) { 
-				fprintf(stdout,"%5.3f,",map_universe[k]);
-				for(j=0;j<s_maps[i].nsets;++j) {
-					fprintf(stdout,"%5.3f",
-					fuzzy(map_universe[k],&s_maps[i].sets[j]));
-						if (j < s_maps[i].nsets-1)
-							fprintf(stdout, ",");
-						else
-							fprintf(stdout, "\n");
-				}
-			}
+    resolution = resolution + 1;
+    map_universe = (float *)G_calloc(resolution, sizeof(float));
+
+    for (i = 0; i < nmaps; ++i) {
+
+	if (s_maps[i].output)
+	    continue;
+	Rast_init_fp_range(&map_range);
+	cur_mapset = (STRING) G_find_raster2(s_maps[i].name, "");
+	Rast_read_fp_range(s_maps[i].name, cur_mapset, &map_range);
+	Rast_get_fp_range_min_max(&map_range, &min, &max);
+
+	for (k = 0; k < resolution; ++k)
+	    map_universe[k] = min + ((max - min) / resolution) * k;
+
+	fprintf(stdout, "#MAP: %s \n", s_maps[i].name);
+
+	fprintf(stdout, "value,");
+	for (j = 0; j < s_maps[i].nsets; ++j) {
+	    fprintf(stdout, "%s", s_maps[i].sets[j].setname);
+	    if (j < s_maps[i].nsets - 1)
+		fprintf(stdout, ",");
+	    else
+		fprintf(stdout, "\n");
 	}
 
-	G_free(map_universe);
+	for (k = 0; k < resolution; ++k) {
+	    fprintf(stdout, "%5.3f,", map_universe[k]);
+	    for (j = 0; j < s_maps[i].nsets; ++j) {
+		fprintf(stdout, "%5.3f",
+			fuzzy(map_universe[k], &s_maps[i].sets[j]));
+		if (j < s_maps[i].nsets - 1)
+		    fprintf(stdout, ",");
+		else
+		    fprintf(stdout, "\n");
+	    }
+	}
+    }
 
+    G_free(map_universe);
+
     for (i = 0; i < nmaps; ++i)
 	G_free(s_maps[i].sets);
 
     G_free(s_maps);
     G_free(s_rules);
 
-		exit(EXIT_SUCCESS);
-	
+    exit(EXIT_SUCCESS);
+
 }
 
 int set_cats(void)
 {
-struct Categories cats;
-float fmin, fmax;
-int cmin, cmax;
-int i, j;
+    struct Categories cats;
+    float fmin, fmax;
+    int cmin, cmax;
+    int i, j;
 
-fmin=universe[0];
-fmax=universe[resolution];
-cmin=(int)universe[0];
-cmax=(int)universe[resolution];
-double tmp1, tmp2;
-float fuzzy_val=0;
-char buf[200];
-float rang;
+    fmin = universe[0];
+    fmax = universe[resolution];
+    cmin = (int)universe[0];
+    cmax = (int)universe[resolution];
+    double tmp1, tmp2;
+    float fuzzy_val = 0;
+    char buf[200];
+    float rang;
 
-rang=(universe[0]+universe[1])/2.;
-Rast_read_cats(output, G_mapset(), &cats);
-Rast_set_cats_title("Result membership", &cats);
+    rang = (universe[0] + universe[1]) / 2.;
+    Rast_read_cats(output, G_mapset(), &cats);
+    Rast_set_cats_title("Result membership", &cats);
 
-	for (i=0;i<resolution;++i) {
-		strcpy(buf,"");
-		for (j=0; j<s_maps[output_index].nsets; ++j) { 
-			fuzzy_val=fuzzy(universe[i],&s_maps[output_index].sets[j]);
-				
-				if(universe[i]<s_maps[output_index].sets[1].points[0] ||
-					universe[i]>s_maps[output_index].sets[s_maps[output_index].nsets-2].points[3])
-			fuzzy_val=1;	
-				if (fuzzy_val>0.)
-			sprintf(buf,"%s %s=%2.2f", buf, s_maps[output_index].sets[j].setname,fuzzy_val);	
-		}
+    for (i = 0; i < resolution; ++i) {
+	strcpy(buf, "");
+	for (j = 0; j < s_maps[output_index].nsets; ++j) {
+	    fuzzy_val = fuzzy(universe[i], &s_maps[output_index].sets[j]);
 
-		tmp1=(double)universe[i]-rang;
-		tmp2=(double)universe[i]+rang;
-		if(i==0) tmp1=(double)universe[i];
-		if(i==resolution) tmp2=(double)universe[i];
-		Rast_set_d_cat(&tmp1, &tmp2, buf, &cats);
-	}	
-Rast_write_cats(output, &cats);
-Rast_free_cats(&cats);
-return 0;
+	    if (universe[i] < s_maps[output_index].sets[1].points[0] ||
+		universe[i] >
+		s_maps[output_index].sets[s_maps[output_index].nsets -
+					  2].points[3])
+		fuzzy_val = 1;
+	    if (fuzzy_val > 0.)
+		sprintf(buf, "%s %s=%2.2f", buf,
+			s_maps[output_index].sets[j].setname, fuzzy_val);
+	}
+
+	tmp1 = (double)universe[i] - rang;
+	tmp2 = (double)universe[i] + rang;
+	if (i == 0)
+	    tmp1 = (double)universe[i];
+	if (i == resolution)
+	    tmp2 = (double)universe[i];
+	Rast_set_d_cat(&tmp1, &tmp2, buf, &cats);
+    }
+    Rast_write_cats(output, &cats);
+    Rast_free_cats(&cats);
+    return 0;
 }
 
 
 /* not in use yet
-void set_colors(void) {
-struct Colors colors;
-Rast_init_colors(&colors);
-Rast_add_d_color_rule(&val1, 255, 255, 255, &val2, 255, 255, 0, &colors);
-Rast_write_colors(output, G_mapset(), &colors);
-}
-*/
+   void set_colors(void) {
+   struct Colors colors;
+   Rast_init_colors(&colors);
+   Rast_add_d_color_rule(&val1, 255, 255, 255, &val2, 255, 255, 0, &colors);
+   Rast_write_colors(output, G_mapset(), &colors);
+   }
+ */

Modified: grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/io.c
===================================================================
--- grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/io.c	2013-05-14 01:15:07 UTC (rev 56243)
+++ grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/io.c	2013-05-14 01:20:44 UTC (rev 56244)
@@ -7,11 +7,11 @@
     char *mapset;
     struct Cell_head cellhd;
 
-			for (i = 0; i < nmaps; ++i) {
-		if (s_maps[i].output) {
-	s_maps[i].in_buf = NULL;
-	continue;
-		}
+    for (i = 0; i < nmaps; ++i) {
+	if (s_maps[i].output) {
+	    s_maps[i].in_buf = NULL;
+	    continue;
+	}
 	mapset = (char *)G_find_raster2(s_maps[i].name, "");
 
 	if (mapset == NULL)
@@ -20,23 +20,23 @@
 	s_maps[i].cfd = Rast_open_old(s_maps[i].name, mapset);
 	Rast_get_cellhd(s_maps[i].name, mapset, &cellhd);
 
-	s_maps[i].raster_type = Rast_map_type(s_maps[i].name,mapset);
+	s_maps[i].raster_type = Rast_map_type(s_maps[i].name, mapset);
 	s_maps[i].in_buf = Rast_allocate_buf(s_maps[i].raster_type);
-			}
-	return 0;
+    }
+    return 0;
 }
 
 int get_rows(int row)
 {
-	int i;
+    int i;
 
     for (i = 0; i < nmaps; ++i) {
-			if (s_maps[i].output)
-		continue;
+	if (s_maps[i].output)
+	    continue;
 	Rast_get_row(s_maps[i].cfd, s_maps[i].in_buf, row,
-	     s_maps[i].raster_type);
-		}
-  return 0;
+		     s_maps[i].raster_type);
+    }
+    return 0;
 }
 
 int get_cells(int col)
@@ -103,6 +103,5 @@
 	m_outputs[i].out_buf = Rast_allocate_f_buf();
 
     }
-return 0;
+    return 0;
 }
-

Modified: grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/local_proto.h
===================================================================
--- grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/local_proto.h	2013-05-14 01:15:07 UTC (rev 56243)
+++ grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/local_proto.h	2013-05-14 01:20:44 UTC (rev 56244)
@@ -120,13 +120,13 @@
 } VALUES;
 
 
-typedef struct /* stores queues with rules */
+typedef struct			/* stores queues with rules */
 {
     char outname[20];
     int output_set_index;
-    char parse_queue[STACKMAX][VARMAX]; /* original rule */
-    int work_queue[STACKMAX]; /* symbols of values and operators */
-    VALUES value_queue[STACKMAX]; /* pointers to values, operators and sets */
+    char parse_queue[STACKMAX][VARMAX];	/* original rule */
+    int work_queue[STACKMAX];	/* symbols of values and operators */
+    VALUES value_queue[STACKMAX];	/* pointers to values, operators and sets */
     float weight;
 } RULES;
 
@@ -187,4 +187,3 @@
 
 int parse(void);
 void display(void);
-

Modified: grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/main.c
===================================================================
--- grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/main.c	2013-05-14 01:15:07 UTC (rev 56243)
+++ grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/main.c	2013-05-14 01:20:44 UTC (rev 56244)
@@ -60,8 +60,7 @@
 
     module = G_define_module();
     module->keywords = _("raster, fuzzy logic");
-    module->description =
-        _("xxxx");
+    module->description = _("xxxx");
 
     file_vars = G_define_standard_option(G_OPT_F_INPUT);
     file_vars->key = "maps";
@@ -85,7 +84,8 @@
     par_defuzzify = G_define_option();
     par_defuzzify->key = "defuz";
     par_defuzzify->type = TYPE_STRING;
-    par_defuzzify->options = "centroid,bisector,min_of_highest,max_of_highest,mean_of_highest";
+    par_defuzzify->options =
+	"centroid,bisector,min_of_highest,max_of_highest,mean_of_highest";
     par_defuzzify->answer = "bisector";
     par_defuzzify->required = YES;
     par_defuzzify->description = _("Defuzzyfication method");
@@ -121,9 +121,8 @@
 
     out_membership = G_define_flag();
     out_membership->key = 'o';
-    out_membership->description =
-	_("Print only membership values and exit");
-		out_membership->guisection = _("Visual Output");
+    out_membership->description = _("Print only membership values and exit");
+    out_membership->guisection = _("Visual Output");
 
     out_multiple = G_define_flag();
     out_multiple->key = 'm';
@@ -133,7 +132,7 @@
 
     opt_output = G_define_standard_option(G_OPT_R_OUTPUT);
     opt_output->description = _("Name of output file");
-		opt_output->required = NO;
+    opt_output->required = NO;
 
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
@@ -145,8 +144,8 @@
     membership_only = (out_membership->answer != 0);
     coor_proc = (in_coor_opt->answer) ? 1 : 0;
 
-			if(!membership_only & (!output | !rule_name_file))
-		G_fatal_error(_("for standard analysis both output and rule file are required"));
+    if (!membership_only & (!output | !rule_name_file))
+	G_fatal_error(_("for standard analysis both output and rule file are required"));
 
     resolution = atoi(par_resolution->answer);
     if (resolution < 10)
@@ -185,32 +184,32 @@
 
     nrows = Rast_window_rows();
     ncols = Rast_window_cols();
-		
-		parse_map_file(var_name_file);
-			if (membership_only)
-    show_membership();
-    
-		parse_rule_file(rule_name_file);
+
+    parse_map_file(var_name_file);
+    if (membership_only)
+	show_membership();
+
+    parse_rule_file(rule_name_file);
     get_universe();
     open_maps();
-	
-		antecedents = (float *)G_malloc(nrules * sizeof(float));
-		agregate = (float *)G_calloc(resolution, sizeof(float));
-			if (coor_proc)
-		process_coors(in_coor_opt->answer);
 
-   outfd = Rast_open_new(output, FCELL_TYPE);
-   out_buf = Rast_allocate_f_buf();
+    antecedents = (float *)G_malloc(nrules * sizeof(float));
+    agregate = (float *)G_calloc(resolution, sizeof(float));
+    if (coor_proc)
+	process_coors(in_coor_opt->answer);
 
+    outfd = Rast_open_new(output, FCELL_TYPE);
+    out_buf = Rast_allocate_f_buf();
+
     if (multiple)
 	create_output_maps();
-  
-		G_message("Calculate...");
 
-	for (row = 0; row < nrows; ++row) {
-		G_percent(row, nrows, 2);
-		get_rows(row);
-		for (col = 0; col < ncols; ++col) {
+    G_message("Calculate...");
+
+    for (row = 0; row < nrows; ++row) {
+	G_percent(row, nrows, 2);
+	get_rows(row);
+	for (col = 0; col < ncols; ++col) {
 	    if (get_cells(col)) {
 		Rast_set_f_null_value(&out_buf[col], 1);
 
@@ -221,8 +220,8 @@
 	    }
 	    else {
 		out_buf[col] = implicate();
-			if (out_buf[col] == -9999)
-		Rast_set_f_null_value(&out_buf[col], 1);
+		if (out_buf[col] == -9999)
+		    Rast_set_f_null_value(&out_buf[col], 1);
 
 		if (multiple) {
 		    for (i = 0; i < nrules; ++i)
@@ -232,45 +231,46 @@
 	}
 	Rast_put_row(outfd, out_buf, FCELL_TYPE);
 
-			if (multiple) 
-	  for (i = 0; i < nrules; ++i)
-	Rast_put_row(m_outputs[i].ofd, m_outputs[i].out_buf, FCELL_TYPE);
+	if (multiple)
+	    for (i = 0; i < nrules; ++i)
+		Rast_put_row(m_outputs[i].ofd, m_outputs[i].out_buf,
+			     FCELL_TYPE);
     }
-  G_percent(row, nrows, 2);
-		
-  G_message("Close...");
+    G_percent(row, nrows, 2);
 
-		
+    G_message("Close...");
 
-  Rast_close(outfd);
-  Rast_short_history(output, "raster", &history);
-  Rast_command_history(&history);
-  Rast_write_history(output, &history);
-	set_cats();
-		/* free */
-			for (i = 0; i < nmaps; ++i) {
-		G_free(s_maps[i].sets);
-				if (s_maps[i].output)
+
+
+    Rast_close(outfd);
+    Rast_short_history(output, "raster", &history);
+    Rast_command_history(&history);
+    Rast_write_history(output, &history);
+    set_cats();
+    /* free */
+    for (i = 0; i < nmaps; ++i) {
+	G_free(s_maps[i].sets);
+	if (s_maps[i].output)
 	    continue;
-		G_free(s_maps[i].in_buf);
-		Rast_close(s_maps[i].cfd);
-			}
-  G_free(antecedents);
-  G_free(agregate);
-  G_free(out_buf);
-  G_free(s_maps);
-  G_free(s_rules);
-   
+	G_free(s_maps[i].in_buf);
+	Rast_close(s_maps[i].cfd);
+    }
+    G_free(antecedents);
+    G_free(agregate);
+    G_free(out_buf);
+    G_free(s_maps);
+    G_free(s_rules);
+
     if (multiple)
 	for (i = 0; i < nrules; ++i) {
-	  G_free(m_outputs[i].out_buf);
-	  Rast_close(m_outputs[i].ofd);
-	  Rast_short_history(m_outputs[i].output_name, "raster", &history);
-	  Rast_command_history(&history);
-	  Rast_write_history(m_outputs[i].output_name, &history);
+	    G_free(m_outputs[i].out_buf);
+	    Rast_close(m_outputs[i].ofd);
+	    Rast_short_history(m_outputs[i].output_name, "raster", &history);
+	    Rast_command_history(&history);
+	    Rast_write_history(m_outputs[i].output_name, &history);
 	}
 
-   G_message("Done!");
+    G_message("Done!");
     exit(EXIT_SUCCESS);
 
 }

Modified: grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/map_parser.c
===================================================================
--- grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/map_parser.c	2013-05-14 01:15:07 UTC (rev 56243)
+++ grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/map_parser.c	2013-05-14 01:20:44 UTC (rev 56244)
@@ -49,22 +49,23 @@
 	    sscanf(buf, "%[^\n]", map);
 	    char_strip(map, '%');
 	    G_strip(map);
-	    mapset = (STRING)G_find_raster2(map, "");
+	    mapset = (STRING) G_find_raster2(map, "");
 
 	    if (mapset == NULL && strcmp(map, "_OUTPUT_"))
 		G_fatal_error(_("Raster map <%s> not found"), map);
 
-				if (!strcmp(map, "_OUTPUT_")) {
-			strcpy(s_maps[nmaps2].name, output);
-			s_maps[nmaps2].output=1;
-				} else {
-	    strcpy(s_maps[nmaps2].name, map);
-	    s_maps[nmaps2].output=0;
-				}
+	    if (!strcmp(map, "_OUTPUT_")) {
+		strcpy(s_maps[nmaps2].name, output);
+		s_maps[nmaps2].output = 1;
+	    }
+	    else {
+		strcpy(s_maps[nmaps2].name, map);
+		s_maps[nmaps2].output = 0;
+	    }
 	    s_maps[nmaps2].position = position;
 	    s_maps[nmaps2].nsets = get_nsets(fd, position);
-	    
 
+
 	    if (!s_maps[nmaps2].nsets)
 		G_warning(_("map <%s> has no rules"), s_maps[nmaps2].name);
 

Modified: grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/rule_parser.c
===================================================================
--- grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/rule_parser.c	2013-05-14 01:15:07 UTC (rev 56243)
+++ grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/rule_parser.c	2013-05-14 01:20:44 UTC (rev 56244)
@@ -49,9 +49,9 @@
 	/* next rule */
     }
 
-			for (i = 0; i < nrules; ++i)
-		G_free(rules[i]);
-		G_free(rules);
+    for (i = 0; i < nrules; ++i)
+	G_free(rules[i]);
+    G_free(rules);
     fclose(fd);
     return 0;
 
@@ -79,9 +79,9 @@
 	G_strip(buf);
 	G_strip(tmp);
 
-		for (p = 0; p <= rule_num; ++p)
-	strcpy(rules[p],"");
-	
+	for (p = 0; p <= rule_num; ++p)
+	    strcpy(rules[p], "");
+
 	done = 1;
 	for (s = 0; s <= s_maps[n - 1].nsets; ++s) {	/* output map */
 
@@ -141,21 +141,21 @@
     /* ******************************************************************* */
 
 
-/*    {				 adding weight: not implemented yet
+    /*    {                          adding weight: not implemented yet
 
-	char local[900];
-	char weight[10];
+       char local[900];
+       char weight[10];
 
-	sscanf(buf, "%[^}] %[^;]", local, weight);
-	char_strip(weight, '}');
-	G_strip(weight);
-	if (strlen(weight) == 0)
-	    strcpy(weight, "1");
-	s_rules[rule_num].weight = atof(weight);
-	if (s_rules[rule_num].weight <= 0.)
-	    G_fatal_error(_("Weight must be grater than 0 or non-number character"));
+       sscanf(buf, "%[^}] %[^;]", local, weight);
+       char_strip(weight, '}');
+       G_strip(weight);
+       if (strlen(weight) == 0)
+       strcpy(weight, "1");
+       s_rules[rule_num].weight = atof(weight);
+       if (s_rules[rule_num].weight <= 0.)
+       G_fatal_error(_("Weight must be grater than 0 or non-number character"));
 
-    } */
+       } */
 
     {				/* check if rule syntax is proper and map names and vars values exist */
 	int k;
@@ -191,12 +191,15 @@
 
 				s_rules[rule_num].work_queue[work_queue_pos] =
 				    t_VAL;
-				s_rules[rule_num].value_queue[work_queue_pos].
-				    value = &s_maps[j].cell;
-				s_rules[rule_num].value_queue[work_queue_pos].
-				    set = &s_maps[j].sets[k];
-				s_rules[rule_num].value_queue[work_queue_pos].
-				    oper = *s_rules[rule_num].parse_queue[i];
+				s_rules[rule_num].
+				    value_queue[work_queue_pos].value =
+				    &s_maps[j].cell;
+				s_rules[rule_num].
+				    value_queue[work_queue_pos].set =
+				    &s_maps[j].sets[k];
+				s_rules[rule_num].
+				    value_queue[work_queue_pos].oper =
+				    *s_rules[rule_num].parse_queue[i];
 				done = 0;
 				break;
 			    }

Modified: grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/system.c
===================================================================
--- grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/system.c	2013-05-14 01:15:07 UTC (rev 56243)
+++ grass-addons/grass7/raster/r.fuzzy/r.fuzzy.system/system.c	2013-05-14 01:20:44 UTC (rev 56244)
@@ -4,6 +4,7 @@
 {
 
     int i, j;
+
     //float *agregate = NULL;
     int set_index;
     float consequent;
@@ -11,49 +12,50 @@
     float max_agregate = 0;
     float result;
 
-    memset(agregate,0,resolution * sizeof(float));
+    memset(agregate, 0, resolution * sizeof(float));
 
     for (j = 0; j < nrules; ++j) {
 	antecedents[j] = parse_expression(j);
 	max_antecedent =
 	    (max_antecedent >
-	     antecedents[j]) ? max_antecedent : antecedents[j]; 
-   }
+	     antecedents[j]) ? max_antecedent : antecedents[j];
+    }
 
     if (max_antecedent == 0. && !coor_proc)
 	return -9999;		/* for all rules value is 0 */
 
     for (j = 0; j < nrules; ++j) {
 
-	if (defuzzyfication > d_BISECTOR && antecedents[j] < max_antecedent && !coor_proc)
+	if (defuzzyfication > d_BISECTOR && antecedents[j] < max_antecedent &&
+	    !coor_proc)
 	    continue;
-	    
-	    set_index = s_rules[j].output_set_index;
 
+	set_index = s_rules[j].output_set_index;
+
 	for (i = 0; i < resolution; ++i) {
-	    
+
 	    consequent = fuzzy(universe[i],
 			       &s_maps[output_index].sets[set_index]);
-	    
+
 	    consequent = (!implication) ? MIN(antecedents[j], consequent) :
 		antecedents[j] * consequent;
 	    agregate[i] = MAX(agregate[i], consequent);
-	    
-	   max_agregate = (max_agregate > agregate[i]) 
-				? max_agregate : agregate[i];
-	   
 
+	    max_agregate = (max_agregate > agregate[i])
+		? max_agregate : agregate[i];
+
+
 	    if (coor_proc)
 		visual_output[i][j + 1] = consequent;
 	}
-	
+
     }
     if (coor_proc)
 	for (i = 0; i < resolution; ++i)
 	    visual_output[i][j + 1] = agregate[i];
 
-     result=defuzzify(defuzzyfication, max_agregate);
-     return result;
+    result = defuzzify(defuzzyfication, max_agregate);
+    return result;
 }
 
 float parse_expression(int n)
@@ -62,7 +64,7 @@
     /*  tokens and actions must heve the same order */
     actions parse_tab[t_size][t_size] = {
 	/* stk -----------INPUT------------------ */
-	/*  		{   &  | ~   =  (  )  }   */
+	/*              {   &  | ~   =  (  )  }   */
 	/*      --  -- -- -- -- -- -- -- */
 	/* { */ {E, S, S, E, E, S, E, A},
 	/* & */ {E, R, R, E, E, S, R, R},
@@ -94,9 +96,12 @@
 
 	if (s_rules[n].work_queue[i] == t_VAL) {
 	    f_value =
-		fuzzy(*s_rules[n].value_queue[i].value, s_rules[n].value_queue[i].set);
-	    values_stack[++val_top] =	(s_rules[n].value_queue[i].oper == '~') ? 
-				f_not(f_value, family) :	f_value;
+		fuzzy(*s_rules[n].value_queue[i].value,
+		      s_rules[n].value_queue[i].set);
+	    values_stack[++val_top] =
+		(s_rules[n].value_queue[i].oper == '~') ? f_not(f_value,
+								family) :
+		f_value;
 	    continue;
 	}
 
@@ -140,16 +145,16 @@
 		break;
 
 	    case A:		/* accept */
-	
+
 		if (!val_top)
 		    G_fatal_error("Stack error at end, contact autor");
 		return values_stack[val_top];
-	
+
 	    }
 	}
 
     } while (s_rules[n].work_queue[i++] != t_STOP);
-    
+
     G_fatal_error("Parse Stack empty, contact autor");
 }
 
@@ -176,11 +181,11 @@
 	return universe[i];
 
     case d_MINOFHIGHEST:
-	for (i = 0; agregate[i] < max_agregate;++i) ;
+	for (i = 0; agregate[i] < max_agregate; ++i) ;
 	return universe[i];
 
     case d_MAXOFHIGHEST:
-	for (i = resolution; agregate[i] < max_agregate;--i) ;
+	for (i = resolution; agregate[i] < max_agregate; --i) ;
 	return universe[i];
 
     case d_MEANOFHIGHEST:



More information about the grass-commit mailing list