00001
00019 #ifndef CLUSTER_H
00020 #define CLUSTER_H
00021
00022 #include "kdtree.h"
00023 #include "oldlist.h"
00024
00025
00026
00027
00036 typedef struct sample
00037 {
00039 unsigned Clustered:1;
00041 unsigned Prototype:1;
00043 unsigned SampleCount:30;
00045 struct sample *Left;
00047 struct sample *Right;
00048
00049 INT32 CharID;
00051 FLOAT32 Mean[1];
00052 } CLUSTER;
00053
00058 typedef CLUSTER SAMPLE;
00059
00064 typedef enum {
00065 spherical, elliptical, mixed, automatic
00066 } PROTOSTYLE;
00067
00072 typedef struct
00073 {
00075 PROTOSTYLE ProtoStyle;
00077 FLOAT32 MinSamples;
00079 FLOAT32 MaxIllegal;
00081 FLOAT32 Independence;
00083 FLOAT64 Confidence;
00084 } CLUSTERCONFIG;
00085
00090 typedef enum {
00091 normal, uniform, D_random
00092 } DISTRIBUTION;
00093
00098 typedef union
00099 {
00100 FLOAT32 Spherical;
00101 FLOAT32 *Elliptical;
00102 } FLOATUNION;
00103
00112 typedef struct proto
00113 {
00115 unsigned Significant:1;
00117 unsigned Style:2;
00119 unsigned NumSamples:29;
00121 CLUSTER *Cluster;
00123 DISTRIBUTION *Distrib;
00125 FLOAT32 *Mean;
00127 FLOAT32 TotalMagnitude;
00129 FLOAT32 LogMagnitude;
00131 FLOATUNION Variance;
00133 FLOATUNION Magnitude;
00135 FLOATUNION Weight;
00136 } PROTOTYPE;
00137
00142 typedef struct
00143 {
00145 INT16 SampleSize;
00147 PARAM_DESC *ParamDesc;
00149 INT32 NumberOfSamples;
00151 KDTREE *KDTree;
00153 CLUSTER *Root;
00155 LIST ProtoList;
00157 INT32 NumChar;
00158 } CLUSTERER;
00159
00164 typedef struct
00165 {
00167 INT32 NumSamples;
00169 INT32 MaxNumSamples;
00171 SAMPLE *Sample[1];
00172 } SAMPLELIST;
00173
00175 #define InitSampleSearch(S,C) (((C)==NULL)?(S=NIL):(S=push(NIL,(C))))
00176
00177
00178
00179
00180 CLUSTERER *MakeClusterer (INT16 SampleSize, PARAM_DESC ParamDesc[]);
00181
00182 SAMPLE *MakeSample (CLUSTERER * Clusterer, FLOAT32 Feature[], INT32 CharID);
00183
00184 LIST ClusterSamples(CLUSTERER *Clusterer, CLUSTERCONFIG *Config);
00185
00186 void FreeClusterer(CLUSTERER *Clusterer);
00187
00188 void FreeProtoList(LIST *ProtoList);
00189
00190 void FreePrototype(void *arg);
00191
00192 CLUSTER *NextSample(LIST *SearchState);
00193
00194 FLOAT32 Mean(PROTOTYPE *Proto, UINT16 Dimension);
00195
00196 FLOAT32 StandardDeviation(PROTOTYPE *Proto, UINT16 Dimension);
00197
00198
00199
00200 #define ALREADYCLUSTERED 4000
00201 #endif