ATTPCROOT
0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
AtReconstruction
AtPatternRecognition
triplclust
src
hclust
fastcluster.h
Go to the documentation of this file.
1
//
2
// C++ standalone verion of fastcluster by Daniel Muellner
3
//
4
// Copyright: Daniel Muellner, 2011
5
// Christoph Dalitz, 2018
6
// License: BSD style license
7
// (see the file LICENSE for details)
8
//
9
10
#ifndef fastclustercpp_H
11
#define fastclustercpp_H
12
13
//
14
// Assigns cluster labels (0, ..., nclust-1) to the n points such
15
// that the cluster result is split into nclust clusters.
16
//
17
// Input arguments:
18
// n = number of observables
19
// merge = clustering result in R format
20
// nclust = number of clusters
21
// Output arguments:
22
// labels = allocated integer array of size n for result
23
//
24
void
cutree_k
(
int
n,
const
int
*merge,
int
nclust,
int
*labels);
25
26
//
27
// Assigns cluster labels (0, ..., nclust-1) to the n points such
28
// that the hierarchical clsutering is stopped at cluster distance cdist
29
//
30
// Input arguments:
31
// n = number of observables
32
// merge = clustering result in R format
33
// height = cluster distance at each merge step
34
// cdist = cutoff cluster distance
35
// Output arguments:
36
// labels = allocated integer array of size n for result
37
//
38
void
cutree_cdist
(
int
n,
const
int
*merge,
double
*height,
double
cdist,
int
*labels);
39
40
//
41
// Hierarchical clustering with one of Daniel Muellner's fast algorithms
42
//
43
// Input arguments:
44
// n = number of observables
45
// distmat = condensed distance matrix, i.e. an n*(n-1)/2 array representing
46
// the upper triangle (without diagonal elements) of the distance
47
// matrix, e.g. for n=4:
48
// d00 d01 d02 d03
49
// d10 d11 d12 d13 -> d02 d02 d03 d12 d13 d23
50
// d20 d21 d22 d23
51
// d30 d31 d32 d33
52
// method = cluster metric (see enum method_code)
53
// Output arguments:
54
// merge = allocated (n-1)x2 matrix (2*(n-1) array) for storing result.
55
// Result follows R hclust convention:
56
// - observabe indices start with one
57
// - merge[i][] contains the merged nodes in step i
58
// - merge[i][j] is negative when the node is an atom
59
// height = allocated (n-1) array with distances at each merge step
60
// Return code:
61
// 0 = ok
62
// 1 = invalid method
63
//
64
int
hclust_fast
(
int
n,
double
*distmat,
int
method,
int
*merge,
double
*height);
65
enum
hclust_fast_methods
{
66
HCLUST_METHOD_SINGLE
= 0,
67
HCLUST_METHOD_COMPLETE
= 1,
68
HCLUST_METHOD_AVERAGE
= 2,
69
HCLUST_METHOD_MEDIAN
= 3
70
};
71
72
#endif
cutree_cdist
void cutree_cdist(int n, const int *merge, double *height, double cdist, int *labels)
Definition:
fastcluster.cxx:104
HCLUST_METHOD_AVERAGE
@ HCLUST_METHOD_AVERAGE
Definition:
fastcluster.h:68
HCLUST_METHOD_MEDIAN
@ HCLUST_METHOD_MEDIAN
Definition:
fastcluster.h:69
hclust_fast
int hclust_fast(int n, double *distmat, int method, int *merge, double *height)
Definition:
fastcluster.cxx:141
cutree_k
void cutree_k(int n, const int *merge, int nclust, int *labels)
Definition:
fastcluster.cxx:38
HCLUST_METHOD_COMPLETE
@ HCLUST_METHOD_COMPLETE
Definition:
fastcluster.h:67
hclust_fast_methods
hclust_fast_methods
Definition:
fastcluster.h:65
HCLUST_METHOD_SINGLE
@ HCLUST_METHOD_SINGLE
Definition:
fastcluster.h:66
Generated on Sat Nov 11 2023 15:30:38 for ATTPCROOT by
1.8.18