-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_new_leaf.c
52 lines (40 loc) · 1.2 KB
/
create_new_leaf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "CommandLineInterface/CLIcore.h"
#include "clustering_defs.h"
#include "CFmeminit.h"
#include "get_availableCFindex.h"
// log all debug trace points to file
#define DEBUGLOG
/**
* @brief Create a new leaf
*
* @param ctree
* @param datarray
* @param ssqr
* @param CFindex
* @return errno_t
*/
errno_t create_new_leaf(CLUSTERTREE *ctree,
double *datarray,
long double ssqr,
long *CFindex)
{
DEBUG_TRACE_FSTART();
long CFi;
FUNC_CHECK_RETURN(get_availableCFindex(ctree, &CFi));
CFmeminit(ctree, CFi, CFMEMINIT_CFUPDATE);
ctree->CFarray[CFi].type = CLUSTER_CF_TYPE_LEAF;
ctree->CFarray[CFi].level = -1;
ctree->CFarray[CFi].parentindex = -1;
ctree->CFarray[CFi].N = 1;
memcpy(ctree->CFarray[CFi].datasumvec,
datarray,
sizeof(double) * ctree->npix);
ctree->CFarray[CFi].datassq = ssqr;
ctree->CFarray[CFi].sum2 = ssqr;
// cluster radius = 0 (single point)
ctree->CFarray[CFi].radius2 = 0.0;
ctree->CFarray[CFi].status |= CLUSTER_CF_STATUS_CREATE;
*CFindex = CFi;
DEBUG_TRACE_FEXIT();
return RETURN_SUCCESS;
}