source: orange/source/orange/hclust.hpp @ 11338:2006c70024f2

Revision 11338:2006c70024f2, 3.4 KB checked in by astaric, 14 months ago (diff)

Fixes for compiling with clang.

export CPPFLAGS=-Wno-address-of-temporary should no longer be needed.

Line 
1/*
2    This file is part of Orange.
3   
4    Copyright 1996-2010 Faculty of Computer and Information Science, University of Ljubljana
5    Contact: janez.demsar@fri.uni-lj.si
6
7    Orange is free software: you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11
12    Orange is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with Orange.  If not, see <http://www.gnu.org/licenses/>.
19*/
20
21
22#ifndef __HCLUST_CPP
23#define __HCLUST_CPP
24
25#include "root.hpp"
26#include "orvector.hpp"
27#include "symmatrix.hpp"
28
29class TClusterW;
30WRAPPER(ProgressCallback);
31
32
33WRAPPER(HierarchicalCluster)
34
35#define THierarchicalClusterList TOrangeVector<PHierarchicalCluster>
36VWRAPPER(HierarchicalClusterList)
37
38class ORANGE_API THierarchicalCluster : public TOrange {
39public:
40    __REGISTER_CLASS
41
42    PHierarchicalClusterList branches; //P subclusters
43    float height;        //P height
44    PIntList mapping;    //P indices to the list of all elements in the clustering
45    int first;           //P the index into 'elements' to the first element of the cluster
46    int last;            //P the index into 'elements' to the one after the last element of the cluster
47
48    THierarchicalCluster();
49    THierarchicalCluster(PIntList els, const int &elementIndex);
50    THierarchicalCluster(PIntList els, PHierarchicalCluster left, PHierarchicalCluster right, const float &h, const int &f, const int &l);
51
52    void swap();
53    void permute(const TIntList &newOrder);
54
55    unsigned int size(){ return last - first; }
56
57protected:
58    void recursiveMove(const int &offset);
59};
60
61
62
63class ORANGE_API THierarchicalClustering : public TOrange {
64public:
65    __REGISTER_CLASS
66
67    CLASSCONSTANTS(Linkage) enum {Single, Average, Complete, Ward};
68    int linkage; //P(&HierarchicalClustering_Linkage) linkage
69    bool overwriteMatrix; //P if true (default is false) it will use (and destroy) the distance matrix given as argument
70
71    PProgressCallback progressCallback; //P progress callback function
72
73    THierarchicalClustering();
74    PHierarchicalCluster operator()(PSymMatrix);
75
76    TClusterW **init(const int &dim, float *distanceMatrix);
77    TClusterW *merge(TClusterW **clusters, float *callbackMilestones);
78    PHierarchicalCluster restructure(TClusterW *);
79    PHierarchicalCluster restructure(TClusterW *, PIntList elementIndices, TIntList::iterator &currentElement, int &currentIndex);
80
81private:
82    TClusterW *merge_CompleteLinkage(TClusterW **clusters, float *callbackMilestones);
83    TClusterW *merge_SingleLinkage(TClusterW **clusters, float *callbackMilestones);
84    TClusterW *merge_AverageLinkage(TClusterW **clusters, float *callbackMilestones);
85    // Average linkage also computes Ward's linkage
86
87private:
88    PHierarchicalCluster order_leaves(PHierarchicalCluster root, PSymMatrix matrix, PProgressCallback progress_callback);
89};
90
91
92/*
93 * Optimal leaf ordering.
94 */
95
96
97
98class ORANGE_API THierarchicalClusterOrdering: public TOrange {
99public:
100    __REGISTER_CLASS
101
102    PProgressCallback progress_callback; //P progress callback function
103
104    PHierarchicalCluster operator() (PHierarchicalCluster root, PSymMatrix matrix);
105
106};
107
108#endif
Note: See TracBrowser for help on using the repository browser.