GRASS GIS 8 Programmer's Manual
8.2.2dev(2023)-3d2c704037
c_execmem.c
Go to the documentation of this file.
1
/*!
2
\file cluster/c_execmem.c
3
4
\brief Cluster library - Allocate cluster
5
6
(C) 2001-2009 by the GRASS Development Team
7
8
This program is free software under the GNU General Public License
9
(>=v2). Read the file COPYING that comes with GRASS for details.
10
11
\author Original author CERL
12
*/
13
14
#include <
grass/cluster.h
>
15
16
/*!
17
\brief Allocate Cluster structure
18
19
\param C pointer to Cluster structure
20
21
\return 1 on success
22
\return 0 on error
23
*/
24
int
I_cluster_exec_allocate
(
struct
Cluster
*C)
25
{
26
G_debug
(1,
"I_cluster_exec_allocate(npoints=%d,nclasses=%d,nbands=%d)"
,
27
C->
npoints
, C->
nclasses
, C->
nbands
);
28
29
C->
class
=
I_alloc_int
(C->
npoints
);
30
C->
reclass
=
I_alloc_int
(C->
nclasses
);
31
C->
count
=
I_alloc_int
(C->
nclasses
);
32
C->
countdiff
=
I_alloc_int
(C->
nclasses
);
33
C->
sum
=
I_alloc_double2
(C->
nbands
, C->
nclasses
);
34
C->
sumdiff
=
I_alloc_double2
(C->
nbands
, C->
nclasses
);
35
C->
sum2
=
I_alloc_double2
(C->
nbands
, C->
nclasses
);
36
C->
mean
=
I_alloc_double2
(C->
nbands
, C->
nclasses
);
37
if
(C->
class
==
NULL
|| C->
reclass
==
NULL
||
38
C->
sum
==
NULL
|| C->
sumdiff
==
NULL
||
39
C->
count
==
NULL
|| C->
countdiff
==
NULL
||
40
C->
sum2
==
NULL
|| C->
mean
==
NULL
) {
41
I_cluster_exec_free
(C);
42
return
0;
43
}
44
return
1;
45
}
46
47
/*!
48
\brief Free allocated Cluster structure
49
50
\param C pointer to Cluster structure
51
52
\return 0
53
*/
54
int
I_cluster_exec_free
(
struct
Cluster
*C)
55
{
56
I_free
(C->
class
);
57
I_free
(C->
reclass
);
58
I_free
(C->
count
);
59
I_free
(C->
countdiff
);
60
I_free_double2
(C->
sum2
);
61
I_free_double2
(C->
sum
);
62
I_free_double2
(C->
sumdiff
);
63
I_free_double2
(C->
mean
);
64
65
C->
class
=
NULL
;
66
C->
count
=
NULL
;
67
C->
countdiff
=
NULL
;
68
C->
sum
=
NULL
;
69
C->
sumdiff
=
NULL
;
70
C->
sum2
=
NULL
;
71
C->
mean
=
NULL
;
72
73
return
0;
74
}
I_free
int I_free(void *)
Definition:
imagery/alloc.c:24
I_cluster_exec_free
int I_cluster_exec_free(struct Cluster *C)
Free allocated Cluster structure.
Definition:
c_execmem.c:54
Cluster::nbands
int nbands
Definition:
cluster.h:9
Cluster::sum
double ** sum
Definition:
cluster.h:21
Cluster::mean
double ** mean
Definition:
cluster.h:24
Cluster::nclasses
int nclasses
Definition:
cluster.h:27
I_cluster_exec_allocate
int I_cluster_exec_allocate(struct Cluster *C)
Allocate Cluster structure.
Definition:
c_execmem.c:24
NULL
#define NULL
Definition:
ccmath.h:32
Cluster
Definition:
cluster.h:7
Cluster::npoints
int npoints
Definition:
cluster.h:10
Cluster::count
int * count
Definition:
cluster.h:19
Cluster::sum2
double ** sum2
Definition:
cluster.h:23
Cluster::sumdiff
double ** sumdiff
Definition:
cluster.h:22
Cluster::class
int * class
Definition:
cluster.h:17
Cluster::reclass
int * reclass
Definition:
cluster.h:18
I_alloc_int
int * I_alloc_int(int)
Definition:
imagery/alloc.c:54
cluster.h
Cluster::countdiff
int * countdiff
Definition:
cluster.h:20
I_free_double2
int I_free_double2(double **)
Definition:
imagery/alloc.c:100
G_debug
int G_debug(int, const char *,...) __attribute__((format(printf
I_alloc_double2
double ** I_alloc_double2(int, int)
Definition:
imagery/alloc.c:33
lib
cluster
c_execmem.c
Generated on Tue Feb 14 2023 05:55:58 for GRASS GIS 8 Programmer's Manual by
1.8.13