GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_execmem.c
Go to the documentation of this file.
1 #include <grass/cluster.h>
2 
3 int I_cluster_exec_allocate(struct Cluster *C)
4 {
5  /*
6  fprintf(stderr,"I_cluster_exec_allocate(npoints=%d,nclasses=%d,nbands=%d)\n", C->npoints, C->nclasses, C->nbands);
7  */
8 
9  C->class = I_alloc_int(C->npoints);
10  C->reclass = I_alloc_int(C->nclasses);
11  C->count = I_alloc_int(C->nclasses);
12  C->countdiff = I_alloc_int(C->nclasses);
13  C->sum = I_alloc_double2(C->nbands, C->nclasses);
14  C->sumdiff = I_alloc_double2(C->nbands, C->nclasses);
15  C->sum2 = I_alloc_double2(C->nbands, C->nclasses);
16  C->mean = I_alloc_double2(C->nbands, C->nclasses);
17  if (C->class == NULL || C->reclass == NULL ||
18  C->sum == NULL || C->sumdiff == NULL ||
19  C->count == NULL || C->countdiff == NULL ||
20  C->sum2 == NULL || C->mean == NULL) {
22  return 0;
23  }
24  return 1;
25 }
26 
27 int I_cluster_exec_free(struct Cluster *C)
28 {
29  I_free(C->class);
30  I_free(C->reclass);
31  I_free(C->count);
32  I_free(C->countdiff);
33  I_free_double2(C->sum2);
34  I_free_double2(C->sum);
35  I_free_double2(C->sumdiff);
36  I_free_double2(C->mean);
37 
38  C->class = NULL;
39  C->count = NULL;
40  C->countdiff = NULL;
41  C->sum = NULL;
42  C->sumdiff = NULL;
43  C->sum2 = NULL;
44  C->mean = NULL;
45 
46  return 0;
47 }
int I_cluster_exec_free(struct Cluster *C)
Definition: c_execmem.c:27
int I_free(void *b)
Definition: imagery/alloc.c:24
int I_cluster_exec_allocate(struct Cluster *C)
Definition: c_execmem.c:3
#define C
Definition: intr_char.c:17
return NULL
Definition: dbfopen.c:1394
int I_free_double2(double **x)
int * I_alloc_int(int a)
Definition: imagery/alloc.c:54
double ** I_alloc_double2(int a, int b)
Definition: imagery/alloc.c:33