[GRASS-SVN] r31774 - in grass/branches/develbranch_6: imagery/i.cluster include include/Make lib lib/cluster lib/imagery

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jun 21 05:28:27 EDT 2008


Author: neteler
Date: 2008-06-21 05:28:26 -0400 (Sat, 21 Jun 2008)
New Revision: 31774

Added:
   grass/branches/develbranch_6/include/cluster.h
   grass/branches/develbranch_6/lib/cluster/
   grass/branches/develbranch_6/lib/cluster/Makefile
   grass/branches/develbranch_6/lib/cluster/c_assign.c
   grass/branches/develbranch_6/lib/cluster/c_begin.c
   grass/branches/develbranch_6/lib/cluster/c_clear.c
   grass/branches/develbranch_6/lib/cluster/c_distinct.c
   grass/branches/develbranch_6/lib/cluster/c_exec.c
   grass/branches/develbranch_6/lib/cluster/c_execmem.c
   grass/branches/develbranch_6/lib/cluster/c_means.c
   grass/branches/develbranch_6/lib/cluster/c_merge.c
   grass/branches/develbranch_6/lib/cluster/c_nclasses.c
   grass/branches/develbranch_6/lib/cluster/c_point.c
   grass/branches/develbranch_6/lib/cluster/c_reassign.c
   grass/branches/develbranch_6/lib/cluster/c_reclass.c
   grass/branches/develbranch_6/lib/cluster/c_sep.c
   grass/branches/develbranch_6/lib/cluster/c_sig.c
   grass/branches/develbranch_6/lib/cluster/c_sum2.c
Removed:
   grass/branches/develbranch_6/lib/cluster/Makefile
   grass/branches/develbranch_6/lib/cluster/c_assign.c
   grass/branches/develbranch_6/lib/cluster/c_begin.c
   grass/branches/develbranch_6/lib/cluster/c_clear.c
   grass/branches/develbranch_6/lib/cluster/c_distinct.c
   grass/branches/develbranch_6/lib/cluster/c_exec.c
   grass/branches/develbranch_6/lib/cluster/c_execmem.c
   grass/branches/develbranch_6/lib/cluster/c_means.c
   grass/branches/develbranch_6/lib/cluster/c_merge.c
   grass/branches/develbranch_6/lib/cluster/c_nclasses.c
   grass/branches/develbranch_6/lib/cluster/c_point.c
   grass/branches/develbranch_6/lib/cluster/c_reassign.c
   grass/branches/develbranch_6/lib/cluster/c_reclass.c
   grass/branches/develbranch_6/lib/cluster/c_sep.c
   grass/branches/develbranch_6/lib/cluster/c_sig.c
   grass/branches/develbranch_6/lib/cluster/c_sum2.c
   grass/branches/develbranch_6/lib/imagery/c_assign.c
   grass/branches/develbranch_6/lib/imagery/c_begin.c
   grass/branches/develbranch_6/lib/imagery/c_clear.c
   grass/branches/develbranch_6/lib/imagery/c_distinct.c
   grass/branches/develbranch_6/lib/imagery/c_exec.c
   grass/branches/develbranch_6/lib/imagery/c_execmem.c
   grass/branches/develbranch_6/lib/imagery/c_means.c
   grass/branches/develbranch_6/lib/imagery/c_merge.c
   grass/branches/develbranch_6/lib/imagery/c_nclasses.c
   grass/branches/develbranch_6/lib/imagery/c_point.c
   grass/branches/develbranch_6/lib/imagery/c_reassign.c
   grass/branches/develbranch_6/lib/imagery/c_reclass.c
   grass/branches/develbranch_6/lib/imagery/c_sep.c
   grass/branches/develbranch_6/lib/imagery/c_sig.c
   grass/branches/develbranch_6/lib/imagery/c_sum2.c
Modified:
   grass/branches/develbranch_6/imagery/i.cluster/Makefile
   grass/branches/develbranch_6/imagery/i.cluster/global.h
   grass/branches/develbranch_6/imagery/i.cluster/main.c
   grass/branches/develbranch_6/imagery/i.cluster/open_files.c
   grass/branches/develbranch_6/imagery/i.cluster/print1.c
   grass/branches/develbranch_6/imagery/i.cluster/print2.c
   grass/branches/develbranch_6/imagery/i.cluster/print3.c
   grass/branches/develbranch_6/imagery/i.cluster/print4.c
   grass/branches/develbranch_6/imagery/i.cluster/print5.c
   grass/branches/develbranch_6/imagery/i.cluster/print6.c
   grass/branches/develbranch_6/include/Make/Grass.make.in
   grass/branches/develbranch_6/include/imagedefs.h
   grass/branches/develbranch_6/include/imagery.h
   grass/branches/develbranch_6/lib/Makefile
Log:
Move cluster code from lib/imagery to lib/cluster
Rename remaining imagery library from libgrass_I to libgrass_imagery (merge from trunk)


Modified: grass/branches/develbranch_6/imagery/i.cluster/Makefile
===================================================================
--- grass/branches/develbranch_6/imagery/i.cluster/Makefile	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/imagery/i.cluster/Makefile	2008-06-21 09:28:26 UTC (rev 31774)
@@ -2,8 +2,8 @@
 
 PGM = i.cluster
 
-LIBES     = $(IMAGERYLIB) $(GISLIB) $(GMATHLIB)
-DEPENDENCIES= $(IMAGERYDEP) $(GISDEP) $(GMATHDEP)
+LIBES     = $(CLUSTERLIB) $(IMAGERYLIB) $(GISLIB) $(GMATHLIB)
+DEPENDENCIES= $(CLUSTERDEP) $(IMAGERYDEP) $(GISDEP) $(GMATHDEP)
 
 include $(MODULE_TOPDIR)/include/Make/Module.make
 

Modified: grass/branches/develbranch_6/imagery/i.cluster/global.h
===================================================================
--- grass/branches/develbranch_6/imagery/i.cluster/global.h	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/imagery/i.cluster/global.h	2008-06-21 09:28:26 UTC (rev 31774)
@@ -13,30 +13,25 @@
 #endif
 
 #include <grass/imagery.h>
+#include <grass/cluster.h>
 
-#ifndef GLOBAL
-# define GLOBAL extern
-#endif
+extern struct Cluster C;
+extern struct Signature in_sig;
 
-
-
-GLOBAL struct Cluster C;
-GLOBAL struct Signature in_sig;
-
-GLOBAL int maxclass ;
-GLOBAL double conv ;
-GLOBAL double sep ;
-GLOBAL int iters ;
-GLOBAL int mcs;
-GLOBAL char *group;
-GLOBAL char *subgroup;
-GLOBAL struct Ref ref;
-GLOBAL char *outsigfile;
-GLOBAL char *insigfile;
-GLOBAL char *reportfile;
-GLOBAL CELL **cell;
-GLOBAL int *cellfd;
-GLOBAL FILE *report;
-GLOBAL int sample_rows, sample_cols;
-GLOBAL int verbose;
-GLOBAL time_t start_time;
+extern int maxclass ;
+extern double conv ;
+extern double sep ;
+extern int iters ;
+extern int mcs;
+extern char *group;
+extern char *subgroup;
+extern struct Ref ref;
+extern char *outsigfile;
+extern char *insigfile;
+extern char *reportfile;
+extern DCELL **cell;
+extern int *cellfd;
+extern FILE *report;
+extern int sample_rows, sample_cols;
+extern int verbose;
+extern time_t start_time;

Modified: grass/branches/develbranch_6/imagery/i.cluster/main.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.cluster/main.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/imagery/i.cluster/main.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -26,6 +26,27 @@
 #include "local_proto.h"
 
 
+struct Cluster C;
+struct Signature in_sig;
+
+int maxclass ;
+double conv ;
+double sep ;
+int iters ;
+int mcs;
+char *group;
+char *subgroup;
+struct Ref ref;
+char *outsigfile;
+char *insigfile;
+char *reportfile;
+DCELL **cell;
+int *cellfd;
+FILE *report;
+int sample_rows, sample_cols;
+int verbose;
+time_t start_time;
+
 static int interrupted = 0;
 
 
@@ -36,7 +57,7 @@
     int n;
     int row,nrows;
     int col,ncols;
-    CELL *x;
+    DCELL *x;
     struct Cell_head window;
     FILE *fd;
 
@@ -261,7 +282,7 @@
     fprintf(report, "\n");
     fflush (report);
 
-    x = (CELL *) G_malloc (ref.nfiles * sizeof(CELL));
+    x = (DCELL *) G_malloc (ref.nfiles * sizeof(DCELL));
 
     I_cluster_begin (&C,ref.nfiles);
 
@@ -272,7 +293,7 @@
 	if (verbose)
 	    G_percent (row, nrows, 2);
 	for (n=0; n < ref.nfiles; n++)
-	    if (G_get_c_raster_row (cellfd[n], cell[n], row) < 0)
+	    if (G_get_d_raster_row (cellfd[n], cell[n], row) < 0)
 		exit(EXIT_FAILURE);
 	for (col = sample_cols-1; col < ncols; col += sample_cols)
 	{

Modified: grass/branches/develbranch_6/imagery/i.cluster/open_files.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.cluster/open_files.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/imagery/i.cluster/open_files.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -47,11 +47,11 @@
                 G_program_name());
     }
 
-    cell = (CELL **) G_malloc (ref.nfiles * sizeof (CELL *));
+    cell = (DCELL **) G_malloc (ref.nfiles * sizeof (DCELL *));
     cellfd = (int *) G_malloc (ref.nfiles * sizeof (int));
     for (n=0; n < ref.nfiles; n++)
     {
-	cell[n] = G_allocate_cell_buf();
+	cell[n] = G_allocate_d_raster_buf();
 	name   = ref.file[n].name;
 	mapset = ref.file[n].mapset;
 	if ((cellfd[n] = G_open_cell_old (name, mapset)) < 0)

Modified: grass/branches/develbranch_6/imagery/i.cluster/print1.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.cluster/print1.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/imagery/i.cluster/print1.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,6 +1,7 @@
-#include <grass/imagery.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 
 int print_band_means (FILE *fd, struct Cluster *C)

Modified: grass/branches/develbranch_6/imagery/i.cluster/print2.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.cluster/print2.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/imagery/i.cluster/print2.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,6 +1,7 @@
-#include <grass/imagery.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 
 /* safe to call only during checkpoint(2) and after

Modified: grass/branches/develbranch_6/imagery/i.cluster/print3.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.cluster/print3.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/imagery/i.cluster/print3.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,6 +1,7 @@
-#include <grass/imagery.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 
 /*

Modified: grass/branches/develbranch_6/imagery/i.cluster/print4.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.cluster/print4.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/imagery/i.cluster/print4.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,6 +1,7 @@
-#include <grass/imagery.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 
 #define FMT1 "%g/%d=%.1f"

Modified: grass/branches/develbranch_6/imagery/i.cluster/print5.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.cluster/print5.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/imagery/i.cluster/print5.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,6 +1,7 @@
-#include <grass/imagery.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 
 int 

Modified: grass/branches/develbranch_6/imagery/i.cluster/print6.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.cluster/print6.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/imagery/i.cluster/print6.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,6 +1,7 @@
-#include <grass/imagery.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+#include <grass/imagery.h>
+#include <grass/cluster.h>
 
 
 int print_distribution (FILE *fd, struct Cluster *C)

Modified: grass/branches/develbranch_6/include/Make/Grass.make.in
===================================================================
--- grass/branches/develbranch_6/include/Make/Grass.make.in	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/include/Make/Grass.make.in	2008-06-21 09:28:26 UTC (rev 31774)
@@ -91,6 +91,7 @@
 ARRAYSTATS_LIBNAME        = grass_arraystats
 BITMAP_LIBNAME        = grass_bitmap
 BTREE_LIBNAME         = grass_btree
+CLUSTER_LIBNAME       = grass_cluster
 COORCNV_LIBNAME       = grass_coorcnv
 DATETIME_LIBNAME      = grass_datetime
 DBDIALOG_LIBNAME      = grass_dbdialog
@@ -109,7 +110,7 @@
 GPROJ_LIBNAME         = grass_gproj
 IBTREE_LIBNAME        = grass_ibtree
 ICON_LIBNAME          = grass_icon
-IMAGERY_LIBNAME       = grass_I
+IMAGERY_LIBNAME       = grass_imagery
 IORTHO_LIBNAME        = grass_Iortho
 ISMAP_LIBNAME         = grass_ismap
 LINKM_LIBNAME         = grass_linkm
@@ -186,6 +187,7 @@
 ARRAYSTATSLIB      = -l$(ARRAYSTATS_LIBNAME) $(GISLIB) 
 BITMAPLIB     = -l$(BITMAP_LIBNAME) $(LINKMLIB) 
 BTREELIB      = -l$(BTREE_LIBNAME)
+CLUSTERLIB    = -l$(CLUSTER_LIBNAME) $(IMAGERYLIB) $(GISLIB)
 COORCNVLIB    = -l$(COORCNV_LIBNAME)
 DATETIMELIB   = -l$(DATETIME_LIBNAME)
 DBDIALOGLIB   = -l$(DBDIALOG_LIBNAME)
@@ -283,6 +285,7 @@
 BITMAPDEP   = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(BITMAP_LIBNAME)$(LIB_SUFFIX)
 BTREEDEP    = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(BTREE_LIBNAME)$(LIB_SUFFIX)
 COORCNVDEP  = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(COORCNV_LIBNAME)$(LIB_SUFFIX)
+CLUSTERDEP  = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(CLUSTER_LIBNAME)$(LIB_SUFFIX)
 DATETIMEDEP = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(DATETIME_LIBNAME)$(LIB_SUFFIX)
 DBDIALOGDEP = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(DBDIALOG_LIBNAME)$(LIB_SUFFIX)
 DISPLAYDEP  = $(ARCH_LIBDIR)/$(LIB_PREFIX)$(DISPLAY_LIBNAME)$(LIB_SUFFIX)

Copied: grass/branches/develbranch_6/include/cluster.h (from rev 31744, grass/trunk/include/cluster.h)
===================================================================
--- grass/branches/develbranch_6/include/cluster.h	                        (rev 0)
+++ grass/branches/develbranch_6/include/cluster.h	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,68 @@
+#ifndef GRASS_CLUSTER_H
+#define GRASS_CLUSTER_H
+
+#include <grass/gis.h>
+#include <grass/imagery.h>
+
+struct Cluster
+{
+    int nbands;
+    int npoints;
+    DCELL **points;
+    int np;
+
+    double *band_sum     ; /* sum over each band */
+    double *band_sum2    ; /* sum of squares over each band */
+
+    int    *class        ; /* class of each point */
+    int    *reclass      ; /* for removing empty classes  */
+    int    *count        ; /* number of points in each class */
+    int    *countdiff    ; /* change in count */
+    double **sum         ; /* sum over band per class */
+    double **sumdiff     ; /* change in sum */
+    double **sum2        ; /* sum of squares per band per class */
+    double **mean        ; /* initial class means */
+    struct Signature S   ; /* final signature(s) */
+
+    int nclasses;
+    int merge1, merge2;
+    int iteration;
+    double percent_stable;
+} ;
+
+/* c_assign.c */
+int I_cluster_assign(struct Cluster *, int *);
+/* c_begin.c */
+int I_cluster_begin(struct Cluster *, int);
+/* c_clear.c */
+int I_cluster_clear(struct Cluster *);
+/* c_distinct.c */
+int I_cluster_distinct(struct Cluster *, double);
+/* c_exec.c */
+int I_cluster_exec(struct Cluster *, int, int, double, double, int, int (*)(), int *);
+/* c_execmem.c */
+int I_cluster_exec_allocate(struct Cluster *);
+int I_cluster_exec_free(struct Cluster *);
+/* c_means.c */
+int I_cluster_means(struct Cluster *);
+/* c_merge.c */
+int I_cluster_merge(struct Cluster *);
+/* c_nclasses.c */
+int I_cluster_nclasses(struct Cluster *, int);
+/* c_point.c */
+int I_cluster_point(struct Cluster *, DCELL *);
+int I_cluster_begin_point_set(struct Cluster *, int);
+int I_cluster_point_part(struct Cluster *, DCELL, int, int);
+int I_cluster_end_point_set(struct Cluster *, int);
+/* c_reassign.c */
+int I_cluster_reassign(struct Cluster *, int *);
+/* c_reclass.c */
+int I_cluster_reclass(struct Cluster *, int);
+/* c_sep.c */
+double I_cluster_separation(struct Cluster *, int, int);
+/* c_sig.c */
+int I_cluster_signatures(struct Cluster *);
+/* c_sum2.c */
+int I_cluster_sum2(struct Cluster *);
+
+#endif

Modified: grass/branches/develbranch_6/include/imagedefs.h
===================================================================
--- grass/branches/develbranch_6/include/imagedefs.h	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/include/imagedefs.h	2008-06-21 09:28:26 UTC (rev 31774)
@@ -101,39 +101,4 @@
 double I_variance(double, double, int);
 double I_stddev(double, double, int);
 
-/* c_assign.c */
-int I_cluster_assign(struct Cluster *, int *);
-/* c_begin.c */
-int I_cluster_begin(struct Cluster *, int);
-/* c_clear.c */
-int I_cluster_clear(struct Cluster *);
-/* c_distinct.c */
-int I_cluster_distinct(struct Cluster *, double);
-/* c_exec.c */
-int I_cluster_exec(struct Cluster *, int, int, double, double, int, int (*)(), int *);
-/* c_execmem.c */
-int I_cluster_exec_allocate(struct Cluster *);
-int I_cluster_exec_free(struct Cluster *);
-/* c_means.c */
-int I_cluster_means(struct Cluster *);
-/* c_merge.c */
-int I_cluster_merge(struct Cluster *);
-/* c_nclasses.c */
-int I_cluster_nclasses(struct Cluster *, int);
-/* c_point.c */
-int I_cluster_point(struct Cluster *, CELL *);
-int I_cluster_begin_point_set(struct Cluster *, int);
-int I_cluster_point_part(struct Cluster *, register CELL, int, int);
-int I_cluster_end_point_set(struct Cluster *, int);
-/* c_reassign.c */
-int I_cluster_reassign(struct Cluster *, int *);
-/* c_reclass.c */
-int I_cluster_reclass(struct Cluster *, int);
-/* c_sep.c */
-double I_cluster_separation(struct Cluster *, int, int);
-/* c_sig.c */
-int I_cluster_signatures(struct Cluster *);
-/* c_sum2.c */
-int I_cluster_sum2(struct Cluster *);
-
 #endif

Modified: grass/branches/develbranch_6/include/imagery.h
===================================================================
--- grass/branches/develbranch_6/include/imagery.h	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/include/imagery.h	2008-06-21 09:28:26 UTC (rev 31774)
@@ -59,32 +59,6 @@
     } *sig;
 } ;
 
-struct Cluster
-{
-    int nbands;
-    int npoints;
-    CELL **points ;
-    int np;
-
-    double *band_sum     ; /* sum over each band */
-    double *band_sum2    ; /* sum of squares over each band */
-
-    int    *class        ; /* class of each point */
-    int    *reclass      ; /* for removing empty classes  */
-    int    *count        ; /* number of points in each class */
-    int    *countdiff    ; /* change in count */
-    double **sum         ; /* sum over band per class */
-    double **sumdiff     ; /* change in sum */
-    double **sum2        ; /* sum of squares per band per class */
-    double **mean        ; /* initial class means */
-    struct Signature S   ; /* final signature(s) */
-
-    int nclasses;
-    int merge1, merge2;
-    int iteration;
-    double percent_stable;
-} ;
-
 struct SigSet
 {
     int nbands;

Modified: grass/branches/develbranch_6/lib/Makefile
===================================================================
--- grass/branches/develbranch_6/lib/Makefile	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/Makefile	2008-06-21 09:28:26 UTC (rev 31774)
@@ -21,6 +21,7 @@
 	gtcltk \
 	form \
 	imagery \
+	cluster \
 	proj \
 	rowio \
 	segment \

Copied: grass/branches/develbranch_6/lib/cluster (from rev 31744, grass/trunk/lib/cluster)

Deleted: grass/branches/develbranch_6/lib/cluster/Makefile
===================================================================
--- grass/trunk/lib/cluster/Makefile	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/Makefile	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,10 +0,0 @@
-MODULE_TOPDIR = ../..
-
-LIB_NAME = $(CLUSTER_LIBNAME)
-
-include $(MODULE_TOPDIR)/include/Make/Lib.make
-
-EXTRA_LIBS = $(IMAGERYLIB) $(GMATHLIB) $(GISLIB)
-
-default: lib
-

Copied: grass/branches/develbranch_6/lib/cluster/Makefile (from rev 31744, grass/trunk/lib/cluster/Makefile)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/Makefile	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/Makefile	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,10 @@
+MODULE_TOPDIR = ../..
+
+LIB_NAME = $(CLUSTER_LIBNAME)
+
+include $(MODULE_TOPDIR)/include/Make/Lib.make
+
+EXTRA_LIBS = $(IMAGERYLIB) $(GMATHLIB) $(GISLIB)
+
+default: lib
+

Deleted: grass/branches/develbranch_6/lib/cluster/c_assign.c
===================================================================
--- grass/trunk/lib/cluster/c_assign.c	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/c_assign.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,44 +0,0 @@
-#include <math.h>
-#include <grass/cluster.h>
-
-int I_cluster_assign ( struct Cluster *C, int *interrupted)
-{
-    int p, c;
-    int class, band;
-    double d,q;
-    double dmin;
-
-/*
-fprintf (stderr,"I_cluster_assign(npoints=%d,nclasses=%d,nbands=%d)\n",
-    C->npoints, C->nclasses, C->nbands);
-*/
-
-    for (p = 0; p < C->npoints; p++)
-    {
-	if (*interrupted) return -1;
-
-	dmin = HUGE_VAL;
-	class = 0;
-	for (c = 0; c < C->nclasses; c++)
-	{
-	    d = 0.0;
-	    for (band = 0; band < C->nbands; band++)
-	    {
-		q = C->points[band][p];
-		q -= C->mean[band][c];
-		d += q*q;
-	    }
-	    if (c == 0 || d < dmin)
-	    {
-		class = c;
-		dmin = d;
-	    }
-	}
-	C->class[p] = class;
-	C->count[class]++;
-	for (band = 0; band < C->nbands; band++)
-	    C->sum[band][class] += C->points[band][p] ;
-    }
-
-	return 0;
-}

Copied: grass/branches/develbranch_6/lib/cluster/c_assign.c (from rev 31744, grass/trunk/lib/cluster/c_assign.c)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/c_assign.c	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/c_assign.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,44 @@
+#include <math.h>
+#include <grass/cluster.h>
+
+int I_cluster_assign ( struct Cluster *C, int *interrupted)
+{
+    int p, c;
+    int class, band;
+    double d,q;
+    double dmin;
+
+/*
+fprintf (stderr,"I_cluster_assign(npoints=%d,nclasses=%d,nbands=%d)\n",
+    C->npoints, C->nclasses, C->nbands);
+*/
+
+    for (p = 0; p < C->npoints; p++)
+    {
+	if (*interrupted) return -1;
+
+	dmin = HUGE_VAL;
+	class = 0;
+	for (c = 0; c < C->nclasses; c++)
+	{
+	    d = 0.0;
+	    for (band = 0; band < C->nbands; band++)
+	    {
+		q = C->points[band][p];
+		q -= C->mean[band][c];
+		d += q*q;
+	    }
+	    if (c == 0 || d < dmin)
+	    {
+		class = c;
+		dmin = d;
+	    }
+	}
+	C->class[p] = class;
+	C->count[class]++;
+	for (band = 0; band < C->nbands; band++)
+	    C->sum[band][class] += C->points[band][p] ;
+    }
+
+	return 0;
+}

Deleted: grass/branches/develbranch_6/lib/cluster/c_begin.c
===================================================================
--- grass/trunk/lib/cluster/c_begin.c	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/c_begin.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,78 +0,0 @@
-#include <stdlib.h>
-#include <grass/cluster.h>
-/****************************************************************
- * I_cluster_begin (C,nbands)
- *
- * initialize the cluster routines for nbands
- *
- * returns 
- *  0 ok
- * -1 out of memory
- *  1 illegal number of bands
- *
- ***************************************************************/
-
-int I_cluster_begin(struct Cluster *C,int nbands)
-{
-    int band;
-    if (C->points != NULL)
-    {
-	for (band = 0; band < C->nbands; band++)
-	    if (C->points[band] != NULL)
-		free (C->points[band]);
-	free (C->points);
-    }
-    if (C->band_sum != NULL)
-	free (C->band_sum);
-    if (C->band_sum2 != NULL)
-	free (C->band_sum2);
-
-    C->points = NULL;
-    C->band_sum = NULL;
-    C->band_sum2 = NULL;
-
-    I_free_signatures (&C->S);
-
-/* record the number of bands */
-    C->nbands = nbands;
-    if (nbands <= 0)
-	return 1;
-
-/* prepare the signatures for nbands */
-
-    I_init_signatures (&C->S, nbands);
-    sprintf (C->S.title, "produced by i.cluster");
-
-/* allocate the data (points) arrays */
-    C->points = (DCELL **) malloc (C->nbands * sizeof (DCELL *));
-    if (C->points == NULL)
-	return -1;
-    for (band = 0; band < C->nbands; band++)
-	C->points[band] = NULL;
-
-    C->np = 128 ;
-    for (band = 0; band < C->nbands; band++)
-    {
-	C->points[band] = (DCELL *) malloc (C->np * sizeof (DCELL)) ;
-	if (C->points[band] == NULL)
-	    return -1;
-    }
-
-/* initialize the count to zero */
-    C->npoints = 0;
-
-/* allocate the band sums and means */
-    C->band_sum = (double *) malloc (C->nbands * sizeof(double));
-    if (C->band_sum == NULL)
-	return -1;
-    C->band_sum2 = (double *) malloc (C->nbands * sizeof(double));
-    if (C->band_sum2 == NULL)
-	return -1;
-    for (band = 0; band < C->nbands; band++)
-    {
-	C->band_sum[band] = 0;
-	C->band_sum2[band] = 0;
-    }
-
-    return 0;
-}

Copied: grass/branches/develbranch_6/lib/cluster/c_begin.c (from rev 31744, grass/trunk/lib/cluster/c_begin.c)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/c_begin.c	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/c_begin.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,78 @@
+#include <stdlib.h>
+#include <grass/cluster.h>
+/****************************************************************
+ * I_cluster_begin (C,nbands)
+ *
+ * initialize the cluster routines for nbands
+ *
+ * returns 
+ *  0 ok
+ * -1 out of memory
+ *  1 illegal number of bands
+ *
+ ***************************************************************/
+
+int I_cluster_begin(struct Cluster *C,int nbands)
+{
+    int band;
+    if (C->points != NULL)
+    {
+	for (band = 0; band < C->nbands; band++)
+	    if (C->points[band] != NULL)
+		free (C->points[band]);
+	free (C->points);
+    }
+    if (C->band_sum != NULL)
+	free (C->band_sum);
+    if (C->band_sum2 != NULL)
+	free (C->band_sum2);
+
+    C->points = NULL;
+    C->band_sum = NULL;
+    C->band_sum2 = NULL;
+
+    I_free_signatures (&C->S);
+
+/* record the number of bands */
+    C->nbands = nbands;
+    if (nbands <= 0)
+	return 1;
+
+/* prepare the signatures for nbands */
+
+    I_init_signatures (&C->S, nbands);
+    sprintf (C->S.title, "produced by i.cluster");
+
+/* allocate the data (points) arrays */
+    C->points = (DCELL **) malloc (C->nbands * sizeof (DCELL *));
+    if (C->points == NULL)
+	return -1;
+    for (band = 0; band < C->nbands; band++)
+	C->points[band] = NULL;
+
+    C->np = 128 ;
+    for (band = 0; band < C->nbands; band++)
+    {
+	C->points[band] = (DCELL *) malloc (C->np * sizeof (DCELL)) ;
+	if (C->points[band] == NULL)
+	    return -1;
+    }
+
+/* initialize the count to zero */
+    C->npoints = 0;
+
+/* allocate the band sums and means */
+    C->band_sum = (double *) malloc (C->nbands * sizeof(double));
+    if (C->band_sum == NULL)
+	return -1;
+    C->band_sum2 = (double *) malloc (C->nbands * sizeof(double));
+    if (C->band_sum2 == NULL)
+	return -1;
+    for (band = 0; band < C->nbands; band++)
+    {
+	C->band_sum[band] = 0;
+	C->band_sum2[band] = 0;
+    }
+
+    return 0;
+}

Deleted: grass/branches/develbranch_6/lib/cluster/c_clear.c
===================================================================
--- grass/trunk/lib/cluster/c_clear.c	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/c_clear.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,19 +0,0 @@
-#include <grass/cluster.h>
-int I_cluster_clear (struct Cluster *C)
-{
-    C->points = NULL;
-    C->band_sum = NULL;
-    C->band_sum2 = NULL;
-    C->class = NULL;
-    C->reclass = NULL;
-    C->count = NULL;
-    C->countdiff = NULL;
-    C->sum = NULL;
-    C->sumdiff = NULL;
-    C->sum2 = NULL;
-    C->mean = NULL;
-    C->nbands = 0;
-    I_init_signatures (&C->S, 0);
-
-	return 0;
-}

Copied: grass/branches/develbranch_6/lib/cluster/c_clear.c (from rev 31744, grass/trunk/lib/cluster/c_clear.c)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/c_clear.c	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/c_clear.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,19 @@
+#include <grass/cluster.h>
+int I_cluster_clear (struct Cluster *C)
+{
+    C->points = NULL;
+    C->band_sum = NULL;
+    C->band_sum2 = NULL;
+    C->class = NULL;
+    C->reclass = NULL;
+    C->count = NULL;
+    C->countdiff = NULL;
+    C->sum = NULL;
+    C->sumdiff = NULL;
+    C->sum2 = NULL;
+    C->mean = NULL;
+    C->nbands = 0;
+    I_init_signatures (&C->S, 0);
+
+	return 0;
+}

Deleted: grass/branches/develbranch_6/lib/cluster/c_distinct.c
===================================================================
--- grass/trunk/lib/cluster/c_distinct.c	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/c_distinct.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,35 +0,0 @@
-#include <grass/cluster.h>
-
-int I_cluster_distinct(struct Cluster *C, double separation)
-{
-    int class1, class2;
-    int distinct;
-    double dmin;
-    double dsep;
-
-/* compute sum of squares for each class */
-    I_cluster_sum2 (C);
-
-/* find closest classes */
-    distinct = 1;
-    dmin = separation;
-    for (class1 = 0; class1 < (C->nclasses-1); class1++)
-    {
-	if (C->count[class1] < 2) continue;
-	for (class2 = class1+1; class2 < C->nclasses; class2++)
-	{
-	    if (C->count[class2] < 2) continue;
-	    dsep = I_cluster_separation (C, class1,class2);
-
-	    if (dsep >= 0.0 && dsep < dmin)
-	    {
-		distinct = 0;
-		C->merge1 = class1;
-		C->merge2 = class2;
-		dmin = dsep ;
-	    }
-	}
-    }
-
-    return distinct;
-}

Copied: grass/branches/develbranch_6/lib/cluster/c_distinct.c (from rev 31744, grass/trunk/lib/cluster/c_distinct.c)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/c_distinct.c	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/c_distinct.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,35 @@
+#include <grass/cluster.h>
+
+int I_cluster_distinct(struct Cluster *C, double separation)
+{
+    int class1, class2;
+    int distinct;
+    double dmin;
+    double dsep;
+
+/* compute sum of squares for each class */
+    I_cluster_sum2 (C);
+
+/* find closest classes */
+    distinct = 1;
+    dmin = separation;
+    for (class1 = 0; class1 < (C->nclasses-1); class1++)
+    {
+	if (C->count[class1] < 2) continue;
+	for (class2 = class1+1; class2 < C->nclasses; class2++)
+	{
+	    if (C->count[class2] < 2) continue;
+	    dsep = I_cluster_separation (C, class1,class2);
+
+	    if (dsep >= 0.0 && dsep < dmin)
+	    {
+		distinct = 0;
+		C->merge1 = class1;
+		C->merge2 = class2;
+		dmin = dsep ;
+	    }
+	}
+    }
+
+    return distinct;
+}

Deleted: grass/branches/develbranch_6/lib/cluster/c_exec.c
===================================================================
--- grass/trunk/lib/cluster/c_exec.c	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/c_exec.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,124 +0,0 @@
-/***************************************************************
- *
- * I_cluster_exec (C, maxclass, iterations,
- *               convergence, separation, min_class_size,
- *               checkpoint, interrupted)
- *
- *  maxclass       maximum number of classes
- *  iterations     maximum number of iterations
- *  convergence    percentage of points stable
- *  separation     minimum distance between class centroids
- *  checkpoint     routine to be called at various steps
- *  interrupted    boolean to check for interrupt
- *
- * returns:
- *   0 ok
- *  -1 out of memory
- *  -2 interrupted
- *   1 not enough data points
- *************************************************************/
-#include <grass/cluster.h>
-
-int I_cluster_exec (
-    struct Cluster *C,int maxclass,int iterations,
-    double convergence,
-    double separation,int min_class_size,
-    int (*checkpoint)(),
-    int *interrupted)
-{
-    int changes;
-
-/* set interrupted to false */
-    *interrupted = 0;
-
-/* check for valid inputs */
-    if (C->npoints < 2)
-    {
-	fprintf (stderr, "cluster: not enough data points (%d)\n",
-	    C->npoints);
-	return 1;
-    }
-
-/* check other parms */
-    if (maxclass < 0)
-	maxclass = 1;
-    C->nclasses = maxclass;
-
-    if (min_class_size <= 0)
-	min_class_size = 17;
-    if (min_class_size < 2)
-	min_class_size = 2;
-
-    if (iterations <= 0)
-	iterations = 20;
-    if (convergence <= 0.0)
-	convergence = 98.0;
-    if (separation < 0.0)
-	separation = 0.5;
-
-
-/* allocate memory */
-    if (!I_cluster_exec_allocate(C))
-	return -1;
-
-
-/* generate class means */
-    I_cluster_means (C);
-    if (checkpoint)
-    	(*checkpoint) (C,1);
-
-/* now assign points to nearest class */
-    I_cluster_assign (C,interrupted);
-    if (*interrupted) return -2;
-    I_cluster_sum2(C);
-    if (checkpoint)
-    	(*checkpoint) (C,2);
-
-/* get rid of empty classes now */
-    I_cluster_reclass (C,1);
-
-    for (C->iteration = 1; ; C->iteration++)
-    {
-	if (*interrupted) return -2;
-
-	changes = 0;
-
-/* re-assign points to nearest class */
-
-	changes = I_cluster_reassign (C,interrupted);
-	if (*interrupted) return -2;
-
-/* if too many points have changed class, re-assign points */
-	C->percent_stable = (C->npoints-changes) * 100.0;
-	C->percent_stable /= (double) C->npoints;
-
-	if (checkpoint)
-	    (*checkpoint) (C,3);
-
-	if (C->iteration >= iterations)
-	    break;
-
-	if (C->percent_stable < convergence)
-	    continue;
-
-/* otherwise merge non-distinct classes */
-
-	if (I_cluster_distinct (C,separation))
-	    break;
-
-	if (checkpoint)
-	    (*checkpoint) (C,4);
-
-	I_cluster_merge (C) ;
-    }
-
-/* get rid of small classes */
-    I_cluster_reclass (C,min_class_size);
-    I_cluster_sum2(C);
-
-/* compute the resulting signatures */
-    I_cluster_signatures (C);
-
-
-    return 0;
-}

Copied: grass/branches/develbranch_6/lib/cluster/c_exec.c (from rev 31744, grass/trunk/lib/cluster/c_exec.c)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/c_exec.c	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/c_exec.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,124 @@
+/***************************************************************
+ *
+ * I_cluster_exec (C, maxclass, iterations,
+ *               convergence, separation, min_class_size,
+ *               checkpoint, interrupted)
+ *
+ *  maxclass       maximum number of classes
+ *  iterations     maximum number of iterations
+ *  convergence    percentage of points stable
+ *  separation     minimum distance between class centroids
+ *  checkpoint     routine to be called at various steps
+ *  interrupted    boolean to check for interrupt
+ *
+ * returns:
+ *   0 ok
+ *  -1 out of memory
+ *  -2 interrupted
+ *   1 not enough data points
+ *************************************************************/
+#include <grass/cluster.h>
+
+int I_cluster_exec (
+    struct Cluster *C,int maxclass,int iterations,
+    double convergence,
+    double separation,int min_class_size,
+    int (*checkpoint)(),
+    int *interrupted)
+{
+    int changes;
+
+/* set interrupted to false */
+    *interrupted = 0;
+
+/* check for valid inputs */
+    if (C->npoints < 2)
+    {
+	fprintf (stderr, "cluster: not enough data points (%d)\n",
+	    C->npoints);
+	return 1;
+    }
+
+/* check other parms */
+    if (maxclass < 0)
+	maxclass = 1;
+    C->nclasses = maxclass;
+
+    if (min_class_size <= 0)
+	min_class_size = 17;
+    if (min_class_size < 2)
+	min_class_size = 2;
+
+    if (iterations <= 0)
+	iterations = 20;
+    if (convergence <= 0.0)
+	convergence = 98.0;
+    if (separation < 0.0)
+	separation = 0.5;
+
+
+/* allocate memory */
+    if (!I_cluster_exec_allocate(C))
+	return -1;
+
+
+/* generate class means */
+    I_cluster_means (C);
+    if (checkpoint)
+    	(*checkpoint) (C,1);
+
+/* now assign points to nearest class */
+    I_cluster_assign (C,interrupted);
+    if (*interrupted) return -2;
+    I_cluster_sum2(C);
+    if (checkpoint)
+    	(*checkpoint) (C,2);
+
+/* get rid of empty classes now */
+    I_cluster_reclass (C,1);
+
+    for (C->iteration = 1; ; C->iteration++)
+    {
+	if (*interrupted) return -2;
+
+	changes = 0;
+
+/* re-assign points to nearest class */
+
+	changes = I_cluster_reassign (C,interrupted);
+	if (*interrupted) return -2;
+
+/* if too many points have changed class, re-assign points */
+	C->percent_stable = (C->npoints-changes) * 100.0;
+	C->percent_stable /= (double) C->npoints;
+
+	if (checkpoint)
+	    (*checkpoint) (C,3);
+
+	if (C->iteration >= iterations)
+	    break;
+
+	if (C->percent_stable < convergence)
+	    continue;
+
+/* otherwise merge non-distinct classes */
+
+	if (I_cluster_distinct (C,separation))
+	    break;
+
+	if (checkpoint)
+	    (*checkpoint) (C,4);
+
+	I_cluster_merge (C) ;
+    }
+
+/* get rid of small classes */
+    I_cluster_reclass (C,min_class_size);
+    I_cluster_sum2(C);
+
+/* compute the resulting signatures */
+    I_cluster_signatures (C);
+
+
+    return 0;
+}

Deleted: grass/branches/develbranch_6/lib/cluster/c_execmem.c
===================================================================
--- grass/trunk/lib/cluster/c_execmem.c	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/c_execmem.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,48 +0,0 @@
-#include <grass/cluster.h>
-
-int I_cluster_exec_allocate(struct Cluster *C)
-{
-/*
-fprintf(stderr,"I_cluster_exec_allocate(npoints=%d,nclasses=%d,nbands=%d)\n", C->npoints, C->nclasses, C->nbands);
-*/
-
-    C->class     = I_alloc_int (C->npoints);
-    C->reclass   = I_alloc_int (C->nclasses);
-    C->count     = I_alloc_int (C->nclasses);
-    C->countdiff = I_alloc_int (C->nclasses);
-    C->sum       = I_alloc_double2 (C->nbands, C->nclasses);
-    C->sumdiff   = I_alloc_double2 (C->nbands, C->nclasses);
-    C->sum2      = I_alloc_double2 (C->nbands, C->nclasses);
-    C->mean      = I_alloc_double2 (C->nbands, C->nclasses);
-    if (C->class == NULL || C->reclass == NULL   ||
-        C->sum == NULL   || C->sumdiff == NULL   ||
-        C->count == NULL || C->countdiff == NULL  ||
-        C->sum2 == NULL  || C->mean == NULL)
-    {
-	I_cluster_exec_free (C);
-	return 0;
-    }
-    return 1;
-}
-
-int I_cluster_exec_free (struct Cluster *C)
-{
-    I_free (C->class);
-    I_free (C->reclass);
-    I_free (C->count);
-    I_free (C->countdiff);
-    I_free_double2 (C->sum2);
-    I_free_double2 (C->sum);
-    I_free_double2 (C->sumdiff);
-    I_free_double2 (C->mean);
-
-    C->class     = NULL;
-    C->count     = NULL;
-    C->countdiff = NULL;
-    C->sum       = NULL;
-    C->sumdiff   = NULL;
-    C->sum2      = NULL;
-    C->mean      = NULL;
-
-	return 0;
-}

Copied: grass/branches/develbranch_6/lib/cluster/c_execmem.c (from rev 31744, grass/trunk/lib/cluster/c_execmem.c)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/c_execmem.c	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/c_execmem.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,48 @@
+#include <grass/cluster.h>
+
+int I_cluster_exec_allocate(struct Cluster *C)
+{
+/*
+fprintf(stderr,"I_cluster_exec_allocate(npoints=%d,nclasses=%d,nbands=%d)\n", C->npoints, C->nclasses, C->nbands);
+*/
+
+    C->class     = I_alloc_int (C->npoints);
+    C->reclass   = I_alloc_int (C->nclasses);
+    C->count     = I_alloc_int (C->nclasses);
+    C->countdiff = I_alloc_int (C->nclasses);
+    C->sum       = I_alloc_double2 (C->nbands, C->nclasses);
+    C->sumdiff   = I_alloc_double2 (C->nbands, C->nclasses);
+    C->sum2      = I_alloc_double2 (C->nbands, C->nclasses);
+    C->mean      = I_alloc_double2 (C->nbands, C->nclasses);
+    if (C->class == NULL || C->reclass == NULL   ||
+        C->sum == NULL   || C->sumdiff == NULL   ||
+        C->count == NULL || C->countdiff == NULL  ||
+        C->sum2 == NULL  || C->mean == NULL)
+    {
+	I_cluster_exec_free (C);
+	return 0;
+    }
+    return 1;
+}
+
+int I_cluster_exec_free (struct Cluster *C)
+{
+    I_free (C->class);
+    I_free (C->reclass);
+    I_free (C->count);
+    I_free (C->countdiff);
+    I_free_double2 (C->sum2);
+    I_free_double2 (C->sum);
+    I_free_double2 (C->sumdiff);
+    I_free_double2 (C->mean);
+
+    C->class     = NULL;
+    C->count     = NULL;
+    C->countdiff = NULL;
+    C->sum       = NULL;
+    C->sumdiff   = NULL;
+    C->sum2      = NULL;
+    C->mean      = NULL;
+
+	return 0;
+}

Deleted: grass/branches/develbranch_6/lib/cluster/c_means.c
===================================================================
--- grass/trunk/lib/cluster/c_means.c	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/c_means.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,29 +0,0 @@
-#include <math.h>
-#include <grass/cluster.h>
-
-int I_cluster_means (struct Cluster *C)
-{
-    int band;
-    int class;
-    double m,v; /* m=mean, v=variance then std dev */
-    double s;
-
-/*
-fprintf(stderr,"I_cluster_means(nbands=%d,nclasses=%d)\n",C->nbands, C->nclasses);
-*/
-    for (band = 0; band < C->nbands; band++)
-    {
-	s = C->band_sum[band] ;
-	m = s / C->npoints;
-	v = C->band_sum2[band]  - s * m;
-	v = sqrt(v / (C->npoints - 1));
-	for (class = 0; class < C->nclasses; class++)
-	    C->mean[band][class] = m;
-	if (C->nclasses > 1)
-	    for (class = 0; class < C->nclasses; class++)
-		C->mean[band][class] +=
-		    ((2.0 * class) / (C->nclasses-1) - 1.0) * v;
-    }
-
-    return 0;
-}

Copied: grass/branches/develbranch_6/lib/cluster/c_means.c (from rev 31744, grass/trunk/lib/cluster/c_means.c)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/c_means.c	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/c_means.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,29 @@
+#include <math.h>
+#include <grass/cluster.h>
+
+int I_cluster_means (struct Cluster *C)
+{
+    int band;
+    int class;
+    double m,v; /* m=mean, v=variance then std dev */
+    double s;
+
+/*
+fprintf(stderr,"I_cluster_means(nbands=%d,nclasses=%d)\n",C->nbands, C->nclasses);
+*/
+    for (band = 0; band < C->nbands; band++)
+    {
+	s = C->band_sum[band] ;
+	m = s / C->npoints;
+	v = C->band_sum2[band]  - s * m;
+	v = sqrt(v / (C->npoints - 1));
+	for (class = 0; class < C->nclasses; class++)
+	    C->mean[band][class] = m;
+	if (C->nclasses > 1)
+	    for (class = 0; class < C->nclasses; class++)
+		C->mean[band][class] +=
+		    ((2.0 * class) / (C->nclasses-1) - 1.0) * v;
+    }
+
+    return 0;
+}

Deleted: grass/branches/develbranch_6/lib/cluster/c_merge.c
===================================================================
--- grass/trunk/lib/cluster/c_merge.c	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/c_merge.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,23 +0,0 @@
-#include <grass/cluster.h>
-
-int I_cluster_merge (struct Cluster *C)
-{
-    int band, p;
-    int c1, c2;
-
-    c1 = C->merge1;
-    c2 = C->merge2;
-
-    for (p = 0; p < C->npoints; p++)
-	if (C->class[p] == c2)
-	    C->class[p] = c1;
-    C->count[c1] += C->count[c2];
-    C->count[c2] = 0;
-    for (band = 0; band < C->nbands; band++)
-    {
-	C->sum[band][c1] += C->sum[band][c2];
-	C->sum[band][c2] = 0;
-    }
-
-    return 0;
-}

Copied: grass/branches/develbranch_6/lib/cluster/c_merge.c (from rev 31744, grass/trunk/lib/cluster/c_merge.c)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/c_merge.c	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/c_merge.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,23 @@
+#include <grass/cluster.h>
+
+int I_cluster_merge (struct Cluster *C)
+{
+    int band, p;
+    int c1, c2;
+
+    c1 = C->merge1;
+    c2 = C->merge2;
+
+    for (p = 0; p < C->npoints; p++)
+	if (C->class[p] == c2)
+	    C->class[p] = c1;
+    C->count[c1] += C->count[c2];
+    C->count[c2] = 0;
+    for (band = 0; band < C->nbands; band++)
+    {
+	C->sum[band][c1] += C->sum[band][c2];
+	C->sum[band][c2] = 0;
+    }
+
+    return 0;
+}

Deleted: grass/branches/develbranch_6/lib/cluster/c_nclasses.c
===================================================================
--- grass/trunk/lib/cluster/c_nclasses.c	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/c_nclasses.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,11 +0,0 @@
-#include <grass/cluster.h>
-
-int I_cluster_nclasses (struct Cluster *C,int minsize)
-{
-    int i,n;
-    n = 0;
-    for (i = 0; i < C->nclasses; i++)
-	if (C->count[i] >= minsize)
-	    n++;
-    return n;
-}

Copied: grass/branches/develbranch_6/lib/cluster/c_nclasses.c (from rev 31744, grass/trunk/lib/cluster/c_nclasses.c)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/c_nclasses.c	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/c_nclasses.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,11 @@
+#include <grass/cluster.h>
+
+int I_cluster_nclasses (struct Cluster *C,int minsize)
+{
+    int i,n;
+    n = 0;
+    for (i = 0; i < C->nclasses; i++)
+	if (C->count[i] >= minsize)
+	    n++;
+    return n;
+}

Deleted: grass/branches/develbranch_6/lib/cluster/c_point.c
===================================================================
--- grass/trunk/lib/cluster/c_point.c	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/c_point.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,115 +0,0 @@
-/****************************************************************
- * I_cluster_point (C,x)
- *     struct Cluster *C;
- *     DCELL *x;
- *
- * adds the point x to the list of data points to be "clustered"
- *
- * returns
- *   0  ok
- *  -1  out of memory, point not added
- *   1  all values are zero, point not added
- *
- * the dimension of x must agree with the number of bands specified
- * in the initializing call to I_cluster_begin()
- *
- * note: if all values in x are zero, the point is rejected
- ***************************************************************/
-
-#include <grass/cluster.h>
-static int extend(struct Cluster *,int);
-static int all_zero(struct Cluster *,int);
-
-int I_cluster_point( struct Cluster *C, DCELL *x)
-{
-    int band;
-
-/* reject points which contain nulls in one of the bands */
-    for (band = 0; band < C->nbands; band++)
-	if (G_is_d_null_value(&x[band])) return 1; /* fixed 11/99 Agus Carr */
-/*
-    if (band >= C->nbands)
-	return 1;
-*/
-
-/* extend the arrays for each band, if necessary */
-    if(!extend(C,1))
-	return -1;
-
-/* add the point to the points arrays */
-    for (band = 0; band < C->nbands; band++)
-    {
-	register double z;
-
- /*       if(G_is_d_null_value(&x[band])) continue;*/
-	z = C->points[band][C->npoints] = x[band];
-	C->band_sum[band]  += z;
-	C->band_sum2[band] += z*z;
-    }
-    C->npoints++;
-    return 0;
-}
-
-int I_cluster_begin_point_set (struct Cluster *C, int n)
-{
-    return extend(C,n) ? 0 : -1;
-}
-
-int I_cluster_point_part (
-    struct Cluster *C, DCELL x, int band, int n)
-{
-    DCELL tmp=x;
-    if(G_is_d_null_value(&tmp)) return 1;
-    C->points[band][C->npoints+n] = x;
-    C->band_sum[band]  += x;
-    C->band_sum2[band] += x*x;
-
-    return 0;
-}
-
-int I_cluster_end_point_set (
-    struct Cluster *C, int n)
-{
-    int band;
-    int cur,next;
-
-    cur = C->npoints;
-    n += C->npoints;
-    for (next = cur; next < n; next++)
-    {
-	if (!all_zero (C, next))
-	{
-	    if (cur != next)
-		for (band = 0; band < C->nbands; band++)
-		    C->points[band][cur] = C->points[band][next] ;
-	    cur++;
-	}
-    }
-    return C->npoints = cur;
-}
-
-static int all_zero(struct Cluster *C, int i)
-{
-    int band;
-
-    for (band = 0; band < C->nbands; band++)
-	if (C->points[band][i])
-	    return 0;
-    return 1;
-}
-
-static int extend(struct Cluster *C, int n)
-{
-    int band;
-    while ((C->npoints+n) > C->np)
-    {
-	C->np += 128;
-	for (band = 0; band < C->nbands; band++)
-	{
-	    C->points[band] = (DCELL *) I_realloc (C->points[band], C->np * sizeof(DCELL)) ;
-	    if (C->points[band] == NULL)
-		return 0;
-	}
-    }
-    return 1;
-}

Copied: grass/branches/develbranch_6/lib/cluster/c_point.c (from rev 31744, grass/trunk/lib/cluster/c_point.c)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/c_point.c	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/c_point.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,115 @@
+/****************************************************************
+ * I_cluster_point (C,x)
+ *     struct Cluster *C;
+ *     DCELL *x;
+ *
+ * adds the point x to the list of data points to be "clustered"
+ *
+ * returns
+ *   0  ok
+ *  -1  out of memory, point not added
+ *   1  all values are zero, point not added
+ *
+ * the dimension of x must agree with the number of bands specified
+ * in the initializing call to I_cluster_begin()
+ *
+ * note: if all values in x are zero, the point is rejected
+ ***************************************************************/
+
+#include <grass/cluster.h>
+static int extend(struct Cluster *,int);
+static int all_zero(struct Cluster *,int);
+
+int I_cluster_point( struct Cluster *C, DCELL *x)
+{
+    int band;
+
+/* reject points which contain nulls in one of the bands */
+    for (band = 0; band < C->nbands; band++)
+	if (G_is_d_null_value(&x[band])) return 1; /* fixed 11/99 Agus Carr */
+/*
+    if (band >= C->nbands)
+	return 1;
+*/
+
+/* extend the arrays for each band, if necessary */
+    if(!extend(C,1))
+	return -1;
+
+/* add the point to the points arrays */
+    for (band = 0; band < C->nbands; band++)
+    {
+	register double z;
+
+ /*       if(G_is_d_null_value(&x[band])) continue;*/
+	z = C->points[band][C->npoints] = x[band];
+	C->band_sum[band]  += z;
+	C->band_sum2[band] += z*z;
+    }
+    C->npoints++;
+    return 0;
+}
+
+int I_cluster_begin_point_set (struct Cluster *C, int n)
+{
+    return extend(C,n) ? 0 : -1;
+}
+
+int I_cluster_point_part (
+    struct Cluster *C, DCELL x, int band, int n)
+{
+    DCELL tmp=x;
+    if(G_is_d_null_value(&tmp)) return 1;
+    C->points[band][C->npoints+n] = x;
+    C->band_sum[band]  += x;
+    C->band_sum2[band] += x*x;
+
+    return 0;
+}
+
+int I_cluster_end_point_set (
+    struct Cluster *C, int n)
+{
+    int band;
+    int cur,next;
+
+    cur = C->npoints;
+    n += C->npoints;
+    for (next = cur; next < n; next++)
+    {
+	if (!all_zero (C, next))
+	{
+	    if (cur != next)
+		for (band = 0; band < C->nbands; band++)
+		    C->points[band][cur] = C->points[band][next] ;
+	    cur++;
+	}
+    }
+    return C->npoints = cur;
+}
+
+static int all_zero(struct Cluster *C, int i)
+{
+    int band;
+
+    for (band = 0; band < C->nbands; band++)
+	if (C->points[band][i])
+	    return 0;
+    return 1;
+}
+
+static int extend(struct Cluster *C, int n)
+{
+    int band;
+    while ((C->npoints+n) > C->np)
+    {
+	C->np += 128;
+	for (band = 0; band < C->nbands; band++)
+	{
+	    C->points[band] = (DCELL *) I_realloc (C->points[band], C->np * sizeof(DCELL)) ;
+	    if (C->points[band] == NULL)
+		return 0;
+	}
+    }
+    return 1;
+}

Deleted: grass/branches/develbranch_6/lib/cluster/c_reassign.c
===================================================================
--- grass/trunk/lib/cluster/c_reassign.c	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/c_reassign.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,81 +0,0 @@
-#include <math.h>
-#include <grass/cluster.h>
-
-int I_cluster_reassign(struct Cluster *C, int *interrupted)
-{
-    double min,d,z;
-    double q;
-    int c,np;
-    int old;
-    int p, band, class;
-    int changes;
-    int first;
-
-    changes = 0;
-    for (c = 0; c < C->nclasses; c++)
-    {
-	C->countdiff[c] = 0;
-	for (band = 0; band < C->nbands; band++)
-	    C->sumdiff[band][c] = 0;
-    }
-
-    min = HUGE_VAL;
-    class = 0;
-    for (p = 0; p < C->npoints; p++)
-    {
-	if (*interrupted) return 0;
-	if (C->class[p] < 0)	/* point to be ignored */
-	    continue;
-
-/* find minimum distance to center of all classes */
-	first = 1;
-	for (c = 0; c < C->nclasses; c++)
-	{
-	    d = 0;
-	    np = C->count[c];
-	    if (np == 0) continue;
-	    for (band = 0; band < C->nbands; band++)
-	    {
-		z =  C->points[band][p] * np - C->sum[band][c] ;
-		d += z*z;
-	    }
-	    d /= (np*np);
-
-	    if (first || (d < min))
-	    {
-		class = c;
-		min = d;
-		first = 0;
-	    }
-	}
-
-	if (C->class[p] != class)
-	{
-	    old = C->class[p];
-	    C->class[p] = class;
-	    changes++;
-
-	    C->countdiff[class]++;
-	    C->countdiff[old]--;
-
-	    for (band = 0; band < C->nbands; band++)
-	    {
-		q = C->points[band][p];
-		C->sumdiff[band][class] += q;
-		C->sumdiff[band][old] -= q;
-	    }
-	}
-    }
-
-    if (changes)
-    {
-	for (c=0; c < C->nclasses; c++)
-	{	
-	    C->count[c] += C->countdiff[c];
-	    for (band = 0; band < C->nbands; band++)
-		C->sum[band][c] += C->sumdiff[band][c];
-	}
-    }
-
-    return changes ;
-}

Copied: grass/branches/develbranch_6/lib/cluster/c_reassign.c (from rev 31744, grass/trunk/lib/cluster/c_reassign.c)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/c_reassign.c	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/c_reassign.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,81 @@
+#include <math.h>
+#include <grass/cluster.h>
+
+int I_cluster_reassign(struct Cluster *C, int *interrupted)
+{
+    double min,d,z;
+    double q;
+    int c,np;
+    int old;
+    int p, band, class;
+    int changes;
+    int first;
+
+    changes = 0;
+    for (c = 0; c < C->nclasses; c++)
+    {
+	C->countdiff[c] = 0;
+	for (band = 0; band < C->nbands; band++)
+	    C->sumdiff[band][c] = 0;
+    }
+
+    min = HUGE_VAL;
+    class = 0;
+    for (p = 0; p < C->npoints; p++)
+    {
+	if (*interrupted) return 0;
+	if (C->class[p] < 0)	/* point to be ignored */
+	    continue;
+
+/* find minimum distance to center of all classes */
+	first = 1;
+	for (c = 0; c < C->nclasses; c++)
+	{
+	    d = 0;
+	    np = C->count[c];
+	    if (np == 0) continue;
+	    for (band = 0; band < C->nbands; band++)
+	    {
+		z =  C->points[band][p] * np - C->sum[band][c] ;
+		d += z*z;
+	    }
+	    d /= (np*np);
+
+	    if (first || (d < min))
+	    {
+		class = c;
+		min = d;
+		first = 0;
+	    }
+	}
+
+	if (C->class[p] != class)
+	{
+	    old = C->class[p];
+	    C->class[p] = class;
+	    changes++;
+
+	    C->countdiff[class]++;
+	    C->countdiff[old]--;
+
+	    for (band = 0; band < C->nbands; band++)
+	    {
+		q = C->points[band][p];
+		C->sumdiff[band][class] += q;
+		C->sumdiff[band][old] -= q;
+	    }
+	}
+    }
+
+    if (changes)
+    {
+	for (c=0; c < C->nclasses; c++)
+	{	
+	    C->count[c] += C->countdiff[c];
+	    for (band = 0; band < C->nbands; band++)
+		C->sum[band][c] += C->sumdiff[band][c];
+	}
+    }
+
+    return changes ;
+}

Deleted: grass/branches/develbranch_6/lib/cluster/c_reclass.c
===================================================================
--- grass/trunk/lib/cluster/c_reclass.c	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/c_reclass.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,36 +0,0 @@
-#include <grass/cluster.h>
-
-int I_cluster_reclass(struct Cluster *C, int minsize)
-{
-    int band, c, hole, move, p;
-
-    for (c=0; c < C->nclasses; c++)
-	C->reclass[c] = c;
-
-/* find first `empty' class */
-    for (hole = 0; hole < C->nclasses; hole++)
-	if (C->count[hole] < minsize)
-	    break;
-
-/* if none, just return */
-    if (hole >= C->nclasses)
-	return 1;
-
-    for (move = hole; move < C->nclasses; move++)
-	if (C->count[move] >= minsize)
-	{
-	    C->reclass[move] = hole;
-	    C->count[hole] = C->count[move];
-	    for (band = 0; band < C->nbands; band++)
-		C->sum[band][hole] = C->sum[band][move];
-	    hole++;
-	}
-	else
-	    C->reclass[move] = -1;	/* eliminate this class */
-
-    for (p = 0; p < C->npoints; p++)
-	C->class[p] = C->reclass[C->class[p]];
-    C->nclasses = hole;
-
-    return 0;
-}

Copied: grass/branches/develbranch_6/lib/cluster/c_reclass.c (from rev 31744, grass/trunk/lib/cluster/c_reclass.c)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/c_reclass.c	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/c_reclass.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,36 @@
+#include <grass/cluster.h>
+
+int I_cluster_reclass(struct Cluster *C, int minsize)
+{
+    int band, c, hole, move, p;
+
+    for (c=0; c < C->nclasses; c++)
+	C->reclass[c] = c;
+
+/* find first `empty' class */
+    for (hole = 0; hole < C->nclasses; hole++)
+	if (C->count[hole] < minsize)
+	    break;
+
+/* if none, just return */
+    if (hole >= C->nclasses)
+	return 1;
+
+    for (move = hole; move < C->nclasses; move++)
+	if (C->count[move] >= minsize)
+	{
+	    C->reclass[move] = hole;
+	    C->count[hole] = C->count[move];
+	    for (band = 0; band < C->nbands; band++)
+		C->sum[band][hole] = C->sum[band][move];
+	    hole++;
+	}
+	else
+	    C->reclass[move] = -1;	/* eliminate this class */
+
+    for (p = 0; p < C->npoints; p++)
+	C->class[p] = C->reclass[C->class[p]];
+    C->nclasses = hole;
+
+    return 0;
+}

Deleted: grass/branches/develbranch_6/lib/cluster/c_sep.c
===================================================================
--- grass/trunk/lib/cluster/c_sep.c	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/c_sep.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,56 +0,0 @@
-#include <math.h>
-#include <grass/cluster.h>
-
-#define FAR ((double) -1.0)
-
-double I_cluster_separation(struct Cluster *C,int class1,int class2)
-{
-    int band;
-    double q;
-    double d;
-    double var;
-    double a1,a2;
-    double n1,n2;
-    double m1,m2;
-    double s1,s2;
-
-    if (C->count[class1] < 2) return FAR;
-    if (C->count[class2] < 2) return FAR;
-    n1 = (double) C->count[class1];
-    n2 = (double) C->count[class2];
-
-    d = 0.0;
-    a1 = a2 = 0.0;
-    for (band = 0; band < C->nbands; band++)
-    {
-	s1 = C->sum[band][class1] ;
-	s2 = C->sum[band][class2] ;
-	m1 = s1 / n1;
-	m2 = s2 / n2;
-	q = m1 - m2;
-	q = q*q;
-	d += q;
-
-
-	var = C->sum2[band][class1] - (s1 * m1) ;
-	var /= n1 - 1;
-	if (var)
-	    a1 += q/var;
-
-	var = C->sum2[band][class2] - (s2 * m2) ;
-	var /= n2 - 1;
-	if (var)
-	    a2 += q/var;
-    }
-    if (d == 0.0) return d;
-
-    if (a1 < 0 || a2 < 0) return FAR;
-    if (a1)
-	a1 = sqrt (6*d/a1);
-    if (a2)
-	a2 = sqrt (6*d/a2);
-    q = a1+a2;
-    if (q == 0.0) return FAR;
-
-    return (sqrt(d)/q) ;
-}

Copied: grass/branches/develbranch_6/lib/cluster/c_sep.c (from rev 31744, grass/trunk/lib/cluster/c_sep.c)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/c_sep.c	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/c_sep.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,56 @@
+#include <math.h>
+#include <grass/cluster.h>
+
+#define FAR ((double) -1.0)
+
+double I_cluster_separation(struct Cluster *C,int class1,int class2)
+{
+    int band;
+    double q;
+    double d;
+    double var;
+    double a1,a2;
+    double n1,n2;
+    double m1,m2;
+    double s1,s2;
+
+    if (C->count[class1] < 2) return FAR;
+    if (C->count[class2] < 2) return FAR;
+    n1 = (double) C->count[class1];
+    n2 = (double) C->count[class2];
+
+    d = 0.0;
+    a1 = a2 = 0.0;
+    for (band = 0; band < C->nbands; band++)
+    {
+	s1 = C->sum[band][class1] ;
+	s2 = C->sum[band][class2] ;
+	m1 = s1 / n1;
+	m2 = s2 / n2;
+	q = m1 - m2;
+	q = q*q;
+	d += q;
+
+
+	var = C->sum2[band][class1] - (s1 * m1) ;
+	var /= n1 - 1;
+	if (var)
+	    a1 += q/var;
+
+	var = C->sum2[band][class2] - (s2 * m2) ;
+	var /= n2 - 1;
+	if (var)
+	    a2 += q/var;
+    }
+    if (d == 0.0) return d;
+
+    if (a1 < 0 || a2 < 0) return FAR;
+    if (a1)
+	a1 = sqrt (6*d/a1);
+    if (a2)
+	a2 = sqrt (6*d/a2);
+    q = a1+a2;
+    if (q == 0.0) return FAR;
+
+    return (sqrt(d)/q) ;
+}

Deleted: grass/branches/develbranch_6/lib/cluster/c_sig.c
===================================================================
--- grass/trunk/lib/cluster/c_sig.c	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/c_sig.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,61 +0,0 @@
-#include <grass/cluster.h>
-int I_cluster_signatures ( struct Cluster *C)
-{
-    int c, p, band1, band2;
-    int n;
-    double m1,m2;
-    double p1,p2;
-    double dn;
-
-/*
-fprintf (stderr, "c_sig: 1\n");
-fprintf (stderr, "  nclasses %d\n", C->nclasses);
-fprintf (stderr, "  npoints  %d\n", C->npoints );
-fprintf (stderr, "  nbands   %d\n", C->nbands  );
-*/
-    for (n = 0; n < C->nclasses; n++)
-    {
-	I_new_signature (&C->S);
-    }
-
-    for (p = 0; p < C->npoints; p++)
-    {
-	c = C->class[p];
-	if (c < 0)
-	    continue;
-/*
-if (c >= C->nclasses)
-    fprintf (stderr, " class[%d]=%d ** illegal **\n", p, c);
-*/
-	dn = n = C->count[c];
-	if (n < 2) continue ;
-	for (band1 = 0; band1 < C->nbands; band1++)
-	{
-	    m1 = C->sum[band1][c] / dn ;
-	    p1 = C->points[band1][p];
-	    for (band2 = 0; band2 <= band1; band2++)
-	    {
-		m2 = C->sum[band2][c] / dn ;
-		p2 = C->points[band2][p];
-		C->S.sig[c].var[band1][band2] += (p1 - m1) * (p2 - m2);
-	    }
-	}
-    }
-
-    for (c = 0; c < C->nclasses; c++)
-    {
-	dn = n = C->S.sig[c].npoints = C->count[c];
-	if (n == 0) dn = 1.0;
-	for (band1 = 0; band1 < C->nbands; band1++)
-	    C->S.sig[c].mean[band1] = C->sum[band1][c] / dn;
-	dn = n = C->count[c] - 1;
-	if (n < 1)
-	    continue;
-	for (band1 = 0; band1 < C->nbands; band1++)
-	    for (band2 = 0; band2 <= band1; band2++)
-		C->S.sig[c].var[band1][band2] /= dn ;
-	C->S.sig[c].status = 1;
-    }
-
-    return 0;
-}

Copied: grass/branches/develbranch_6/lib/cluster/c_sig.c (from rev 31744, grass/trunk/lib/cluster/c_sig.c)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/c_sig.c	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/c_sig.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,61 @@
+#include <grass/cluster.h>
+int I_cluster_signatures ( struct Cluster *C)
+{
+    int c, p, band1, band2;
+    int n;
+    double m1,m2;
+    double p1,p2;
+    double dn;
+
+/*
+fprintf (stderr, "c_sig: 1\n");
+fprintf (stderr, "  nclasses %d\n", C->nclasses);
+fprintf (stderr, "  npoints  %d\n", C->npoints );
+fprintf (stderr, "  nbands   %d\n", C->nbands  );
+*/
+    for (n = 0; n < C->nclasses; n++)
+    {
+	I_new_signature (&C->S);
+    }
+
+    for (p = 0; p < C->npoints; p++)
+    {
+	c = C->class[p];
+	if (c < 0)
+	    continue;
+/*
+if (c >= C->nclasses)
+    fprintf (stderr, " class[%d]=%d ** illegal **\n", p, c);
+*/
+	dn = n = C->count[c];
+	if (n < 2) continue ;
+	for (band1 = 0; band1 < C->nbands; band1++)
+	{
+	    m1 = C->sum[band1][c] / dn ;
+	    p1 = C->points[band1][p];
+	    for (band2 = 0; band2 <= band1; band2++)
+	    {
+		m2 = C->sum[band2][c] / dn ;
+		p2 = C->points[band2][p];
+		C->S.sig[c].var[band1][band2] += (p1 - m1) * (p2 - m2);
+	    }
+	}
+    }
+
+    for (c = 0; c < C->nclasses; c++)
+    {
+	dn = n = C->S.sig[c].npoints = C->count[c];
+	if (n == 0) dn = 1.0;
+	for (band1 = 0; band1 < C->nbands; band1++)
+	    C->S.sig[c].mean[band1] = C->sum[band1][c] / dn;
+	dn = n = C->count[c] - 1;
+	if (n < 1)
+	    continue;
+	for (band1 = 0; band1 < C->nbands; band1++)
+	    for (band2 = 0; band2 <= band1; band2++)
+		C->S.sig[c].var[band1][band2] /= dn ;
+	C->S.sig[c].status = 1;
+    }
+
+    return 0;
+}

Deleted: grass/branches/develbranch_6/lib/cluster/c_sum2.c
===================================================================
--- grass/trunk/lib/cluster/c_sum2.c	2008-06-18 15:07:05 UTC (rev 31744)
+++ grass/branches/develbranch_6/lib/cluster/c_sum2.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,29 +0,0 @@
-#include <grass/cluster.h>
-
-/* compute sum of squares for each class */
-int I_cluster_sum2(struct Cluster *C)
-{
-    int p, band, class;
-    double q;
-
-/*
-fprintf (stderr, "I_cluster_sum2(npoints=%d,nclasses=%d,nbands=%d)\n", C->npoints, C->nclasses, C->nbands);
-*/
-    for (class=0; class < C->nclasses; class++)
-	for (band = 0; band < C->nbands; band++)
-	    C->sum2[band][class] = 0;
-
-    for (p = 0; p < C->npoints; p++)
-    {
-	class = C->class[p];
-	if (class < 0)
-	    continue;
-	for (band = 0; band < C->nbands; band++)
-	{
-	    q = C->points[band][p];
-	    C->sum2[band][class] += q*q;
-	}
-    }
-
-    return 0;
-}

Copied: grass/branches/develbranch_6/lib/cluster/c_sum2.c (from rev 31744, grass/trunk/lib/cluster/c_sum2.c)
===================================================================
--- grass/branches/develbranch_6/lib/cluster/c_sum2.c	                        (rev 0)
+++ grass/branches/develbranch_6/lib/cluster/c_sum2.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -0,0 +1,29 @@
+#include <grass/cluster.h>
+
+/* compute sum of squares for each class */
+int I_cluster_sum2(struct Cluster *C)
+{
+    int p, band, class;
+    double q;
+
+/*
+fprintf (stderr, "I_cluster_sum2(npoints=%d,nclasses=%d,nbands=%d)\n", C->npoints, C->nclasses, C->nbands);
+*/
+    for (class=0; class < C->nclasses; class++)
+	for (band = 0; band < C->nbands; band++)
+	    C->sum2[band][class] = 0;
+
+    for (p = 0; p < C->npoints; p++)
+    {
+	class = C->class[p];
+	if (class < 0)
+	    continue;
+	for (band = 0; band < C->nbands; band++)
+	{
+	    q = C->points[band][p];
+	    C->sum2[band][class] += q*q;
+	}
+    }
+
+    return 0;
+}

Deleted: grass/branches/develbranch_6/lib/imagery/c_assign.c
===================================================================
--- grass/branches/develbranch_6/lib/imagery/c_assign.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/imagery/c_assign.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,45 +0,0 @@
-#include <math.h>
-
-#include <grass/imagery.h>
-
-int I_cluster_assign ( struct Cluster *C, int *interrupted)
-{
-    int p, c;
-    int class, band;
-    double d,q;
-    double dmin;
-
-/*
-fprintf (stderr,"I_cluster_assign(npoints=%d,nclasses=%d,nbands=%d)\n",
-    C->npoints, C->nclasses, C->nbands);
-*/
-
-    for (p = 0; p < C->npoints; p++)
-    {
-	if (*interrupted) return -1;
-
-	dmin = HUGE_VAL;
-	class = 0;
-	for (c = 0; c < C->nclasses; c++)
-	{
-	    d = 0.0;
-	    for (band = 0; band < C->nbands; band++)
-	    {
-		q = (double) C->points[band][p];
-		q -= C->mean[band][c];
-		d += q*q;
-	    }
-	    if (c == 0 || d < dmin)
-	    {
-		class = c;
-		dmin = d;
-	    }
-	}
-	C->class[p] = class;
-	C->count[class]++;
-	for (band = 0; band < C->nbands; band++)
-	    C->sum[band][class] += (double) C->points[band][p] ;
-    }
-
-	return 0;
-}

Deleted: grass/branches/develbranch_6/lib/imagery/c_begin.c
===================================================================
--- grass/branches/develbranch_6/lib/imagery/c_begin.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/imagery/c_begin.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,78 +0,0 @@
-#include <stdlib.h>
-#include <grass/imagery.h>
-/****************************************************************
- * I_cluster_begin (C,nbands)
- *
- * initialize the cluster routines for nbands
- *
- * returns 
- *  0 ok
- * -1 out of memory
- *  1 illegal number of bands
- *
- ***************************************************************/
-
-int I_cluster_begin(struct Cluster *C,int nbands)
-{
-    int band;
-    if (C->points != NULL)
-    {
-	for (band = 0; band < C->nbands; band++)
-	    if (C->points[band] != NULL)
-		free (C->points[band]);
-	free (C->points);
-    }
-    if (C->band_sum != NULL)
-	free (C->band_sum);
-    if (C->band_sum2 != NULL)
-	free (C->band_sum2);
-
-    C->points = NULL;
-    C->band_sum = NULL;
-    C->band_sum2 = NULL;
-
-    I_free_signatures (&C->S);
-
-/* record the number of bands */
-    C->nbands = nbands;
-    if (nbands <= 0)
-	return 1;
-
-/* prepare the signatures for nbands */
-
-    I_init_signatures (&C->S, nbands);
-    sprintf (C->S.title, "produced by i.cluster");
-
-/* allocate the data (points) arrays */
-    C->points = (CELL **) malloc (C->nbands * sizeof (CELL *));
-    if (C->points == NULL)
-	return -1;
-    for (band = 0; band < C->nbands; band++)
-	C->points[band] = NULL;
-
-    C->np = 128 ;
-    for (band = 0; band < C->nbands; band++)
-    {
-	C->points[band] = (CELL *) malloc (C->np * sizeof (CELL)) ;
-	if (C->points[band] == NULL)
-	    return -1;
-    }
-
-/* initialize the count to zero */
-    C->npoints = 0;
-
-/* allocate the band sums and means */
-    C->band_sum = (double *) malloc (C->nbands * sizeof(double));
-    if (C->band_sum == NULL)
-	return -1;
-    C->band_sum2 = (double *) malloc (C->nbands * sizeof(double));
-    if (C->band_sum2 == NULL)
-	return -1;
-    for (band = 0; band < C->nbands; band++)
-    {
-	C->band_sum[band] = 0;
-	C->band_sum2[band] = 0;
-    }
-
-    return 0;
-}

Deleted: grass/branches/develbranch_6/lib/imagery/c_clear.c
===================================================================
--- grass/branches/develbranch_6/lib/imagery/c_clear.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/imagery/c_clear.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,19 +0,0 @@
-#include <grass/imagery.h>
-int I_cluster_clear (struct Cluster *C)
-{
-    C->points = NULL;
-    C->band_sum = NULL;
-    C->band_sum2 = NULL;
-    C->class = NULL;
-    C->reclass = NULL;
-    C->count = NULL;
-    C->countdiff = NULL;
-    C->sum = NULL;
-    C->sumdiff = NULL;
-    C->sum2 = NULL;
-    C->mean = NULL;
-    C->nbands = 0;
-    I_init_signatures (&C->S, 0);
-
-	return 0;
-}

Deleted: grass/branches/develbranch_6/lib/imagery/c_distinct.c
===================================================================
--- grass/branches/develbranch_6/lib/imagery/c_distinct.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/imagery/c_distinct.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,36 +0,0 @@
-#include <grass/imagery.h>
-
-int I_cluster_distinct(struct Cluster *C, double separation)
-{
-    int class1, class2;
-    int distinct;
-    double dmin;
-    double dsep;
-    double I_cluster_separation();
-
-/* compute sum of squares for each class */
-    I_cluster_sum2 (C);
-
-/* find closest classes */
-    distinct = 1;
-    dmin = separation;
-    for (class1 = 0; class1 < (C->nclasses-1); class1++)
-    {
-	if (C->count[class1] < 2) continue;
-	for (class2 = class1+1; class2 < C->nclasses; class2++)
-	{
-	    if (C->count[class2] < 2) continue;
-	    dsep = I_cluster_separation (C, class1,class2);
-
-	    if (dsep >= 0.0 && dsep < dmin)
-	    {
-		distinct = 0;
-		C->merge1 = class1;
-		C->merge2 = class2;
-		dmin = dsep ;
-	    }
-	}
-    }
-
-    return distinct;
-}

Deleted: grass/branches/develbranch_6/lib/imagery/c_exec.c
===================================================================
--- grass/branches/develbranch_6/lib/imagery/c_exec.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/imagery/c_exec.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,124 +0,0 @@
-/***************************************************************
- *
- * I_cluster_exec (C, maxclass, iterations,
- *               convergence, separation, min_class_size,
- *               checkpoint, interrupted)
- *
- *  maxclass       maximum number of classes
- *  iterations     maximum number of iterations
- *  convergence    percentage of points stable
- *  separation     minimum distance between class centroids
- *  checkpoint     routine to be called at various steps
- *  interrupted    boolean to check for interrupt
- *
- * returns:
- *   0 ok
- *  -1 out of memory
- *  -2 interrupted
- *   1 not enough data points
- *************************************************************/
-#include <grass/imagery.h>
-
-int I_cluster_exec (
-    struct Cluster *C,int maxclass,int iterations,
-    double convergence,
-    double separation,int min_class_size,
-    int (*checkpoint)(),
-    int *interrupted)
-{
-    int changes;
-
-/* set interrupted to false */
-    *interrupted = 0;
-
-/* check for valid inputs */
-    if (C->npoints < 2)
-    {
-	fprintf (stderr, "cluster: not enough data points (%d)\n",
-	    C->npoints);
-	return 1;
-    }
-
-/* check other parms */
-    if (maxclass < 0)
-	maxclass = 1;
-    C->nclasses = maxclass;
-
-    if (min_class_size <= 0)
-	min_class_size = 17;
-    if (min_class_size < 2)
-	min_class_size = 2;
-
-    if (iterations <= 0)
-	iterations = 20;
-    if (convergence <= 0.0)
-	convergence = 98.0;
-    if (separation < 0.0)
-	separation = 0.5;
-
-
-/* allocate memory */
-    if (!I_cluster_exec_allocate(C))
-	return -1;
-
-
-/* generate class means */
-    I_cluster_means (C);
-    if (checkpoint)
-    	(*checkpoint) (C,1);
-
-/* now assign points to nearest class */
-    I_cluster_assign (C,interrupted);
-    if (*interrupted) return -2;
-    I_cluster_sum2(C);
-    if (checkpoint)
-    	(*checkpoint) (C,2);
-
-/* get rid of empty classes now */
-    I_cluster_reclass (C,1);
-
-    for (C->iteration = 1; ; C->iteration++)
-    {
-	if (*interrupted) return -2;
-
-	changes = 0;
-
-/* re-assign points to nearest class */
-
-	changes = I_cluster_reassign (C,interrupted);
-	if (*interrupted) return -2;
-
-/* if too many points have changed class, re-assign points */
-	C->percent_stable = (C->npoints-changes) * 100.0;
-	C->percent_stable /= (double) C->npoints;
-
-	if (checkpoint)
-	    (*checkpoint) (C,3);
-
-	if (C->iteration >= iterations)
-	    break;
-
-	if (C->percent_stable < convergence)
-	    continue;
-
-/* otherwise merge non-distinct classes */
-
-	if (I_cluster_distinct (C,separation))
-	    break;
-
-	if (checkpoint)
-	    (*checkpoint) (C,4);
-
-	I_cluster_merge (C) ;
-    }
-
-/* get rid of small classes */
-    I_cluster_reclass (C,min_class_size);
-    I_cluster_sum2(C);
-
-/* compute the resulting signatures */
-    I_cluster_signatures (C);
-
-
-    return 0;
-}

Deleted: grass/branches/develbranch_6/lib/imagery/c_execmem.c
===================================================================
--- grass/branches/develbranch_6/lib/imagery/c_execmem.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/imagery/c_execmem.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,48 +0,0 @@
-#include <grass/imagery.h>
-
-int I_cluster_exec_allocate(struct Cluster *C)
-{
-/*
-fprintf(stderr,"I_cluster_exec_allocate(npoints=%d,nclasses=%d,nbands=%d)\n", C->npoints, C->nclasses, C->nbands);
-*/
-
-    C->class     = I_alloc_int (C->npoints);
-    C->reclass   = I_alloc_int (C->nclasses);
-    C->count     = I_alloc_int (C->nclasses);
-    C->countdiff = I_alloc_int (C->nclasses);
-    C->sum       = I_alloc_double2 (C->nbands, C->nclasses);
-    C->sumdiff   = I_alloc_double2 (C->nbands, C->nclasses);
-    C->sum2      = I_alloc_double2 (C->nbands, C->nclasses);
-    C->mean      = I_alloc_double2 (C->nbands, C->nclasses);
-    if (C->class == NULL || C->reclass == NULL   ||
-        C->sum == NULL   || C->sumdiff == NULL   ||
-        C->count == NULL || C->countdiff == NULL  ||
-        C->sum2 == NULL  || C->mean == NULL)
-    {
-	I_cluster_exec_free (C);
-	return 0;
-    }
-    return 1;
-}
-
-int I_cluster_exec_free (struct Cluster *C)
-{
-    I_free (C->class);
-    I_free (C->reclass);
-    I_free (C->count);
-    I_free (C->countdiff);
-    I_free_double2 (C->sum2);
-    I_free_double2 (C->sum);
-    I_free_double2 (C->sumdiff);
-    I_free_double2 (C->mean);
-
-    C->class     = NULL;
-    C->count     = NULL;
-    C->countdiff = NULL;
-    C->sum       = NULL;
-    C->sumdiff   = NULL;
-    C->sum2      = NULL;
-    C->mean      = NULL;
-
-	return 0;
-}

Deleted: grass/branches/develbranch_6/lib/imagery/c_means.c
===================================================================
--- grass/branches/develbranch_6/lib/imagery/c_means.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/imagery/c_means.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,29 +0,0 @@
-#include <grass/imagery.h>
-#include <math.h>
-
-int I_cluster_means (struct Cluster *C)
-{
-    int band;
-    int class;
-    double m,v; /* m=mean, v=variance then std dev */
-    double s;
-
-/*
-fprintf(stderr,"I_cluster_means(nbands=%d,nclasses=%d)\n",C->nbands, C->nclasses);
-*/
-    for (band = 0; band < C->nbands; band++)
-    {
-	s = (double) C->band_sum[band] ;
-	m = s / (double) C->npoints;
-	v = (double) C->band_sum2[band]  - s * m;
-	v = sqrt (v / (double) (C->npoints - 1));
-	for (class = 0; class < C->nclasses; class++)
-	    C->mean[band][class] = m;
-	if (C->nclasses > 1)
-	    for (class = 0; class < C->nclasses; class++)
-		C->mean[band][class] +=
-		    ((2.0 * class) / (C->nclasses-1) - 1.0) * v;
-    }
-
-    return 0;
-}

Deleted: grass/branches/develbranch_6/lib/imagery/c_merge.c
===================================================================
--- grass/branches/develbranch_6/lib/imagery/c_merge.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/imagery/c_merge.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,23 +0,0 @@
-#include <grass/imagery.h>
-
-int I_cluster_merge (struct Cluster *C)
-{
-    int band, p;
-    int c1, c2;
-
-    c1 = C->merge1;
-    c2 = C->merge2;
-
-    for (p = 0; p < C->npoints; p++)
-	if (C->class[p] == c2)
-	    C->class[p] = c1;
-    C->count[c1] += C->count[c2];
-    C->count[c2] = 0;
-    for (band = 0; band < C->nbands; band++)
-    {
-	C->sum[band][c1] += C->sum[band][c2];
-	C->sum[band][c2] = 0;
-    }
-
-    return 0;
-}

Deleted: grass/branches/develbranch_6/lib/imagery/c_nclasses.c
===================================================================
--- grass/branches/develbranch_6/lib/imagery/c_nclasses.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/imagery/c_nclasses.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,11 +0,0 @@
-#include <grass/imagery.h>
-
-int I_cluster_nclasses (struct Cluster *C,int minsize)
-{
-    int i,n;
-    n = 0;
-    for (i = 0; i < C->nclasses; i++)
-	if (C->count[i] >= minsize)
-	    n++;
-    return n;
-}

Deleted: grass/branches/develbranch_6/lib/imagery/c_point.c
===================================================================
--- grass/branches/develbranch_6/lib/imagery/c_point.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/imagery/c_point.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,115 +0,0 @@
-/****************************************************************
- * I_cluster_point (C,x)
- *     struct Cluster *C;
- *     CELL *x;
- *
- * adds the point x to the list of data points to be "clustered"
- *
- * returns
- *   0  ok
- *  -1  out of memory, point not added
- *   1  all values are zero, point not added
- *
- * the dimension of x must agree with the number of bands specified
- * in the initializing call to I_cluster_begin()
- *
- * note: if all values in x are zero, the point is rejected
- ***************************************************************/
-
-#include <grass/imagery.h>
-static int extend(struct Cluster *,int);
-static int all_zero(struct Cluster *,int);
-
-int I_cluster_point( struct Cluster *C, CELL *x)
-{
-    int band;
-
-/* reject points which contain nulls in one of the bands */
-    for (band = 0; band < C->nbands; band++)
-	if (G_is_c_null_value(&x[band])) return 1; /* fixed 11/99 Agus Carr */
-/*
-    if (band >= C->nbands)
-	return 1;
-*/
-
-/* extend the arrays for each band, if necessary */
-    if(!extend(C,1))
-	return -1;
-
-/* add the point to the points arrays */
-    for (band = 0; band < C->nbands; band++)
-    {
-	register double z;
-
- /*       if(G_is_c_null_value(&x[band])) continue;*/
-	z = C->points[band][C->npoints] = x[band];
-	C->band_sum[band]  += z;
-	C->band_sum2[band] += z*z;
-    }
-    C->npoints++;
-    return 0;
-}
-
-int I_cluster_begin_point_set (struct Cluster *C, int n)
-{
-    return extend(C,n) ? 0 : -1;
-}
-
-int I_cluster_point_part (
-    struct Cluster *C,register CELL x,int band, int n)
-{
-    CELL tmp=x;
-    if(G_is_c_null_value(&tmp)) return 1;
-    C->points[band][C->npoints+n] = x;
-    C->band_sum[band]  += (double) x;
-    C->band_sum2[band] += (double) x*x;
-
-    return 0;
-}
-
-int I_cluster_end_point_set (
-    struct Cluster *C, int n)
-{
-    int band;
-    int cur,next;
-
-    cur = C->npoints;
-    n += C->npoints;
-    for (next = cur; next < n; next++)
-    {
-	if (!all_zero (C, next))
-	{
-	    if (cur != next)
-		for (band = 0; band < C->nbands; band++)
-		    C->points[band][cur] = C->points[band][next] ;
-	    cur++;
-	}
-    }
-    return C->npoints = cur;
-}
-
-static int all_zero(struct Cluster *C, int i)
-{
-    int band;
-
-    for (band = 0; band < C->nbands; band++)
-	if (C->points[band][i])
-	    return 0;
-    return 1;
-}
-
-static int extend(struct Cluster *C, int n)
-{
-    int band;
-    while ((C->npoints+n) > C->np)
-    {
-	C->np += 128;
-	for (band = 0; band < C->nbands; band++)
-	{
-	    C->points[band] = (CELL *) I_realloc (C->points[band], C->np * sizeof (CELL)) ;
-	    if (C->points[band] == NULL)
-		return 0;
-	}
-    }
-    return 1;
-}

Deleted: grass/branches/develbranch_6/lib/imagery/c_reassign.c
===================================================================
--- grass/branches/develbranch_6/lib/imagery/c_reassign.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/imagery/c_reassign.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,81 +0,0 @@
-#include <math.h>
-#include <grass/imagery.h>
-
-int I_cluster_reassign(struct Cluster *C, int *interrupted)
-{
-    double min,d,z;
-    int q;
-    int c,np;
-    int old;
-    int p, band, class;
-    int changes;
-    int first;
-
-    changes = 0;
-    for (c = 0; c < C->nclasses; c++)
-    {
-	C->countdiff[c] = 0;
-	for (band = 0; band < C->nbands; band++)
-	    C->sumdiff[band][c] = 0;
-    }
-
-    min = HUGE_VAL;
-    class = 0;
-    for (p = 0; p < C->npoints; p++)
-    {
-	if (*interrupted) return 0;
-	if (C->class[p] < 0)	/* point to be ignored */
-	    continue;
-
-/* find minimum distance to center of all classes */
-	first = 1;
-	for (c = 0; c < C->nclasses; c++)
-	{
-	    d = 0;
-	    np = C->count[c];
-	    if (np == 0) continue;
-	    for (band = 0; band < C->nbands; band++)
-	    {
-		z =  C->points[band][p] * np - C->sum[band][c] ;
-		d += z*z;
-	    }
-	    d /= (np*np);
-
-	    if (first || (d < min))
-	    {
-		class = c;
-		min = d;
-		first = 0;
-	    }
-	}
-
-	if (C->class[p] != class)
-	{
-	    old = C->class[p];
-	    C->class[p] = class;
-	    changes++;
-
-	    C->countdiff[class]++;
-	    C->countdiff[old]--;
-
-	    for (band = 0; band < C->nbands; band++)
-	    {
-		q = (int) C->points[band][p];
-		C->sumdiff[band][class] += q;
-		C->sumdiff[band][old] -= q;
-	    }
-	}
-    }
-
-    if (changes)
-    {
-	for (c=0; c < C->nclasses; c++)
-	{	
-	    C->count[c] += C->countdiff[c];
-	    for (band = 0; band < C->nbands; band++)
-		C->sum[band][c] += C->sumdiff[band][c];
-	}
-    }
-
-    return changes ;
-}

Deleted: grass/branches/develbranch_6/lib/imagery/c_reclass.c
===================================================================
--- grass/branches/develbranch_6/lib/imagery/c_reclass.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/imagery/c_reclass.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,36 +0,0 @@
-#include <grass/imagery.h>
-
-int I_cluster_reclass(struct Cluster *C, int minsize)
-{
-    int band, c, hole, move, p;
-
-    for (c=0; c < C->nclasses; c++)
-	C->reclass[c] = c;
-
-/* find first `empty' class */
-    for (hole = 0; hole < C->nclasses; hole++)
-	if (C->count[hole] < minsize)
-	    break;
-
-/* if none, just return */
-    if (hole >= C->nclasses)
-	return 1;
-
-    for (move = hole; move < C->nclasses; move++)
-	if (C->count[move] >= minsize)
-	{
-	    C->reclass[move] = hole;
-	    C->count[hole] = C->count[move];
-	    for (band = 0; band < C->nbands; band++)
-		C->sum[band][hole] = C->sum[band][move];
-	    hole++;
-	}
-	else
-	    C->reclass[move] = -1;	/* eliminate this class */
-
-    for (p = 0; p < C->npoints; p++)
-	C->class[p] = C->reclass[C->class[p]];
-    C->nclasses = hole;
-
-    return 0;
-}

Deleted: grass/branches/develbranch_6/lib/imagery/c_sep.c
===================================================================
--- grass/branches/develbranch_6/lib/imagery/c_sep.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/imagery/c_sep.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,56 +0,0 @@
-#include <grass/imagery.h>
-
-#define FAR ((double) -1.0)
-
-double I_cluster_separation(struct Cluster *C,int class1,int class2)
-{
-    int band;
-    double q;
-    double d;
-    double var;
-    double a1,a2;
-    double n1,n2;
-    double m1,m2;
-    double s1,s2;
-    double sqrt();
-
-    if (C->count[class1] < 2) return FAR;
-    if (C->count[class2] < 2) return FAR;
-    n1 = (double) C->count[class1];
-    n2 = (double) C->count[class2];
-
-    d = 0.0;
-    a1 = a2 = 0.0;
-    for (band = 0; band < C->nbands; band++)
-    {
-	s1 = (double) C->sum[band][class1] ;
-	s2 = (double) C->sum[band][class2] ;
-	m1 = s1 / n1;
-	m2 = s2 / n2;
-	q = m1 - m2;
-	q = q*q;
-	d += q;
-
-
-	var = (double) C->sum2[band][class1] - (s1 * m1) ;
-	var /= n1 - 1;
-	if (var)
-	    a1 += q/var;
-
-	var = (double) C->sum2[band][class2] - (s2 * m2) ;
-	var /= n2 - 1;
-	if (var)
-	    a2 += q/var;
-    }
-    if (d == 0.0) return d;
-
-    if (a1 < 0 || a2 < 0) return FAR;
-    if (a1)
-	a1 = sqrt (6*d/a1);
-    if (a2)
-	a2 = sqrt (6*d/a2);
-    q = a1+a2;
-    if (q == 0.0) return FAR;
-
-    return (sqrt(d)/q) ;
-}

Deleted: grass/branches/develbranch_6/lib/imagery/c_sig.c
===================================================================
--- grass/branches/develbranch_6/lib/imagery/c_sig.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/imagery/c_sig.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,61 +0,0 @@
-#include <grass/imagery.h>
-int I_cluster_signatures ( struct Cluster *C)
-{
-    int c, p, band1, band2;
-    int n;
-    double m1,m2;
-    double p1,p2;
-    double dn;
-
-/*
-fprintf (stderr, "c_sig: 1\n");
-fprintf (stderr, "  nclasses %d\n", C->nclasses);
-fprintf (stderr, "  npoints  %d\n", C->npoints );
-fprintf (stderr, "  nbands   %d\n", C->nbands  );
-*/
-    for (n = 0; n < C->nclasses; n++)
-    {
-	I_new_signature (&C->S);
-    }
-
-    for (p = 0; p < C->npoints; p++)
-    {
-	c = C->class[p];
-	if (c < 0)
-	    continue;
-/*
-if (c >= C->nclasses)
-    fprintf (stderr, " class[%d]=%d ** illegal **\n", p, c);
-*/
-	dn = n = C->count[c];
-	if (n < 2) continue ;
-	for (band1 = 0; band1 < C->nbands; band1++)
-	{
-	    m1 = C->sum[band1][c] / dn ;
-	    p1 = C->points[band1][p];
-	    for (band2 = 0; band2 <= band1; band2++)
-	    {
-		m2 = C->sum[band2][c] / dn ;
-		p2 = C->points[band2][p];
-		C->S.sig[c].var[band1][band2] += (p1 - m1) * (p2 - m2);
-	    }
-	}
-    }
-
-    for (c = 0; c < C->nclasses; c++)
-    {
-	dn = n = C->S.sig[c].npoints = C->count[c];
-	if (n == 0) dn = 1.0;
-	for (band1 = 0; band1 < C->nbands; band1++)
-	    C->S.sig[c].mean[band1] = (double) C->sum[band1][c] / dn;
-	dn = n = C->count[c] - 1;
-	if (n < 1)
-	    continue;
-	for (band1 = 0; band1 < C->nbands; band1++)
-	    for (band2 = 0; band2 <= band1; band2++)
-		C->S.sig[c].var[band1][band2] /= dn ;
-	C->S.sig[c].status = 1;
-    }
-
-    return 0;
-}

Deleted: grass/branches/develbranch_6/lib/imagery/c_sum2.c
===================================================================
--- grass/branches/develbranch_6/lib/imagery/c_sum2.c	2008-06-21 08:31:37 UTC (rev 31773)
+++ grass/branches/develbranch_6/lib/imagery/c_sum2.c	2008-06-21 09:28:26 UTC (rev 31774)
@@ -1,29 +0,0 @@
-#include <grass/imagery.h>
-
-/* compute sum of squares for each class */
-int I_cluster_sum2(struct Cluster *C)
-{
-    int p, band, class;
-    double q;
-
-/*
-fprintf (stderr, "I_cluster_sum2(npoints=%d,nclasses=%d,nbands=%d)\n", C->npoints, C->nclasses, C->nbands);
-*/
-    for (class=0; class < C->nclasses; class++)
-	for (band = 0; band < C->nbands; band++)
-	    C->sum2[band][class] = 0;
-
-    for (p = 0; p < C->npoints; p++)
-    {
-	class = C->class[p];
-	if (class < 0)
-	    continue;
-	for (band = 0; band < C->nbands; band++)
-	{
-	    q = (double)C->points[band][p];
-	    C->sum2[band][class] += q*q;
-	}
-    }
-
-    return 0;
-}



More information about the grass-commit mailing list