doxygenify

This commit is contained in:
Jimmy O'Regan 2014-08-10 02:06:25 +01:00 committed by Jim O'Regan
parent 6941bffbd2
commit 7fd28ae6df

View File

@ -386,15 +386,16 @@ BOOL8 MultipleCharSamples(CLUSTERER *Clusterer,
double InvertMatrix(const float* input, int size, float* inv); double InvertMatrix(const float* input, int size, float* inv);
//--------------------------Public Code-------------------------------------- //--------------------------Public Code--------------------------------------
/** MakeClusterer ********************************************************** /**
Parameters: SampleSize number of dimensions in feature space * This routine creates a new clusterer data structure,
ParamDesc description of each dimension * initializes it, and returns a pointer to it.
Operation: This routine creates a new clusterer data structure, *
initializes it, and returns a pointer to it. * @param SampleSize number of dimensions in feature space
Return: pointer to the new clusterer data structure * @param ParamDesc description of each dimension
Exceptions: None * @return pointer to the new clusterer data structure
History: 5/29/89, DSJ, Created. * @note Exceptions: None
****************************************************************************/ * @note History: 5/29/89, DSJ, Created.
*/
CLUSTERER * CLUSTERER *
MakeClusterer (inT16 SampleSize, const PARAM_DESC ParamDesc[]) { MakeClusterer (inT16 SampleSize, const PARAM_DESC ParamDesc[]) {
CLUSTERER *Clusterer; CLUSTERER *Clusterer;
@ -437,20 +438,22 @@ MakeClusterer (inT16 SampleSize, const PARAM_DESC ParamDesc[]) {
} // MakeClusterer } // MakeClusterer
/** MakeSample *********************************************************** /**
Parameters: Clusterer clusterer data structure to add sample to * This routine creates a new sample data structure to hold
Feature feature to be added to clusterer * the specified feature. This sample is added to the clusterer
CharID unique ident. of char that sample came from * data structure (so that it knows which samples are to be
Operation: This routine creates a new sample data structure to hold * clustered later), and a pointer to the sample is returned to
the specified feature. This sample is added to the clusterer * the caller.
data structure (so that it knows which samples are to be *
clustered later), and a pointer to the sample is returned to * @param Clusterer clusterer data structure to add sample to
the caller. * @param Feature feature to be added to clusterer
Return: Pointer to the new sample data structure * @param CharID unique ident. of char that sample came from
Exceptions: ALREADYCLUSTERED MakeSample can't be called after *
ClusterSamples has been called * @return Pointer to the new sample data structure
History: 5/29/89, DSJ, Created. * @note Exceptions: ALREADYCLUSTERED MakeSample can't be called after
*****************************************************************************/ * ClusterSamples has been called
* @note History: 5/29/89, DSJ, Created.
*/
SAMPLE* MakeSample(CLUSTERER * Clusterer, const FLOAT32* Feature, SAMPLE* MakeSample(CLUSTERER * Clusterer, const FLOAT32* Feature,
inT32 CharID) { inT32 CharID) {
SAMPLE *Sample; SAMPLE *Sample;
@ -488,23 +491,27 @@ SAMPLE* MakeSample(CLUSTERER * Clusterer, const FLOAT32* Feature,
} // MakeSample } // MakeSample
/** ClusterSamples *********************************************************** /**
Parameters: Clusterer data struct containing samples to be clustered * This routine first checks to see if the samples in this
Config parameters which control clustering process * clusterer have already been clustered before; if so, it does
Operation: This routine first checks to see if the samples in this * not bother to recreate the cluster tree. It simply recomputes
clusterer have already been clustered before; if so, it does * the prototypes based on the new Config info.
not bother to recreate the cluster tree. It simply recomputes *
the prototypes based on the new Config info. * If the samples have not been clustered before, the
If the samples have not been clustered before, the * samples in the KD tree are formed into a cluster tree and then
samples in the KD tree are formed into a cluster tree and then * the prototypes are computed from the cluster tree.
the prototypes are computed from the cluster tree. *
In either case this routine returns a pointer to a * In either case this routine returns a pointer to a
list of prototypes that best represent the samples given * list of prototypes that best represent the samples given
the constraints specified in Config. * the constraints specified in Config.
Return: Pointer to a list of prototypes *
Exceptions: None * @param Clusterer data struct containing samples to be clustered
History: 5/29/89, DSJ, Created. * @param Config parameters which control clustering process
*******************************************************************************/ *
* @return Pointer to a list of prototypes
* @note Exceptions: None
* @note History: 5/29/89, DSJ, Created.
*/
LIST ClusterSamples(CLUSTERER *Clusterer, CLUSTERCONFIG *Config) { LIST ClusterSamples(CLUSTERER *Clusterer, CLUSTERCONFIG *Config) {
//only create cluster tree if samples have never been clustered before //only create cluster tree if samples have never been clustered before
if (Clusterer->Root == NULL) if (Clusterer->Root == NULL)
@ -520,19 +527,19 @@ LIST ClusterSamples(CLUSTERER *Clusterer, CLUSTERCONFIG *Config) {
} // ClusterSamples } // ClusterSamples
/** FreeClusterer ************************************************************* /**
Parameters: Clusterer pointer to data structure to be freed * This routine frees all of the memory allocated to the
Operation: This routine frees all of the memory allocated to the * specified data structure. It will not, however, free
specified data structure. It will not, however, free * the memory used by the prototype list. The pointers to
the memory used by the prototype list. The pointers to * the clusters for each prototype in the list will be set
the clusters for each prototype in the list will be set * to NULL to indicate that the cluster data structures no
to NULL to indicate that the cluster data structures no * longer exist. Any sample lists that have been obtained
longer exist. Any sample lists that have been obtained * via calls to GetSamples are no longer valid.
via calls to GetSamples are no longer valid. * @param Clusterer pointer to data structure to be freed
Return: None * @return None
Exceptions: None * @note Exceptions: None
History: 6/6/89, DSJ, Created. * @note History: 6/6/89, DSJ, Created.
*******************************************************************************/ */
void FreeClusterer(CLUSTERER *Clusterer) { void FreeClusterer(CLUSTERER *Clusterer) {
if (Clusterer != NULL) { if (Clusterer != NULL) {
memfree (Clusterer->ParamDesc); memfree (Clusterer->ParamDesc);
@ -552,30 +559,30 @@ void FreeClusterer(CLUSTERER *Clusterer) {
} // FreeClusterer } // FreeClusterer
/** FreeProtoList ************************************************************ /**
Parameters: ProtoList pointer to list of prototypes to be freed * This routine frees all of the memory allocated to the
Operation: This routine frees all of the memory allocated to the * specified list of prototypes. The clusters which are
specified list of prototypes. The clusters which are * pointed to by the prototypes are not freed.
pointed to by the prototypes are not freed. * @param ProtoList pointer to list of prototypes to be freed
Return: None * @return None
Exceptions: None * @note Exceptions: None
History: 6/6/89, DSJ, Created. * @note History: 6/6/89, DSJ, Created.
*****************************************************************************/ */
void FreeProtoList(LIST *ProtoList) { void FreeProtoList(LIST *ProtoList) {
destroy_nodes(*ProtoList, FreePrototype); destroy_nodes(*ProtoList, FreePrototype);
} // FreeProtoList } // FreeProtoList
/** FreePrototype ************************************************************ /**
Parameters: Prototype prototype data structure to be deallocated * This routine deallocates the memory consumed by the specified
Operation: This routine deallocates the memory consumed by the specified * prototype and modifies the corresponding cluster so that it
prototype and modifies the corresponding cluster so that it * is no longer marked as a prototype. The cluster is NOT
is no longer marked as a prototype. The cluster is NOT * deallocated by this routine.
deallocated by this routine. * @param Prototype prototype data structure to be deallocated
Return: None * @return None
Exceptions: None * @note Exceptions: None
History: 5/30/89, DSJ, Created. * @note History: 5/30/89, DSJ, Created.
*******************************************************************************/ */
void FreePrototype(void *arg) { //PROTOTYPE *Prototype) void FreePrototype(void *arg) { //PROTOTYPE *Prototype)
PROTOTYPE *Prototype = (PROTOTYPE *) arg; PROTOTYPE *Prototype = (PROTOTYPE *) arg;
@ -600,21 +607,21 @@ void FreePrototype(void *arg) { //PROTOTYPE *Prototype)
} // FreePrototype } // FreePrototype
/** NextSample ************************************************************ /**
Parameters: SearchState ptr to list containing clusters to be searched * This routine is used to find all of the samples which
Operation: This routine is used to find all of the samples which * belong to a cluster. It starts by removing the top
belong to a cluster. It starts by removing the top * cluster on the cluster list (SearchState). If this cluster is
cluster on the cluster list (SearchState). If this cluster is * a leaf it is returned. Otherwise, the right subcluster
a leaf it is returned. Otherwise, the right subcluster * is pushed on the list and we continue the search in the
is pushed on the list and we continue the search in the * left subcluster. This continues until a leaf is found.
left subcluster. This continues until a leaf is found. * If all samples have been found, NULL is returned.
If all samples have been found, NULL is returned. * InitSampleSearch() must be called
InitSampleSearch() must be called * before NextSample() to initialize the search.
before NextSample() to initialize the search. * @param SearchState ptr to list containing clusters to be searched
Return: Pointer to the next leaf cluster (sample) or NULL. * @return Pointer to the next leaf cluster (sample) or NULL.
Exceptions: None * @note Exceptions: None
History: 6/16/89, DSJ, Created. * @note History: 6/16/89, DSJ, Created.
****************************************************************************/ */
CLUSTER *NextSample(LIST *SearchState) { CLUSTER *NextSample(LIST *SearchState) {
CLUSTER *Cluster; CLUSTER *Cluster;
@ -631,29 +638,29 @@ CLUSTER *NextSample(LIST *SearchState) {
} // NextSample } // NextSample
/** Mean *********************************************************** /**
Parameters: Proto prototype to return mean of * This routine returns the mean of the specified
Dimension dimension whose mean is to be returned * prototype in the indicated dimension.
Operation: This routine returns the mean of the specified * @param Proto prototype to return mean of
prototype in the indicated dimension. * @param Dimension dimension whose mean is to be returned
Return: Mean of Prototype in Dimension * @return Mean of Prototype in Dimension
Exceptions: none * @note Exceptions: none
History: 7/6/89, DSJ, Created. * @note History: 7/6/89, DSJ, Created.
*********************************************************************/ */
FLOAT32 Mean(PROTOTYPE *Proto, uinT16 Dimension) { FLOAT32 Mean(PROTOTYPE *Proto, uinT16 Dimension) {
return (Proto->Mean[Dimension]); return (Proto->Mean[Dimension]);
} // Mean } // Mean
/** StandardDeviation ************************************************* /**
Parameters: Proto prototype to return standard deviation of * This routine returns the standard deviation of the
Dimension dimension whose stddev is to be returned * prototype in the indicated dimension.
Operation: This routine returns the standard deviation of the * @param Proto prototype to return standard deviation of
prototype in the indicated dimension. * @param Dimension dimension whose stddev is to be returned
Return: Standard deviation of Prototype in Dimension * @return Standard deviation of Prototype in Dimension
Exceptions: none * @note Exceptions: none
History: 7/6/89, DSJ, Created. * @note History: 7/6/89, DSJ, Created.
**********************************************************************/ */
FLOAT32 StandardDeviation(PROTOTYPE *Proto, uinT16 Dimension) { FLOAT32 StandardDeviation(PROTOTYPE *Proto, uinT16 Dimension) {
switch (Proto->Style) { switch (Proto->Style) {
case spherical: case spherical:
@ -2248,36 +2255,31 @@ void FreeStatistics(STATISTICS *Statistics) {
} // FreeStatistics } // FreeStatistics
//--------------------------------------------------------------------------- /**
void FreeBuckets(BUCKETS *buckets) { * This routine properly frees the memory used by a BUCKETS.
/* *
** Parameters: * @param buckets pointer to data structure to be freed
** buckets pointer to data structure to be freed
** Operation:
** This routine properly frees the memory used by a BUCKETS.
*/ */
void FreeBuckets(BUCKETS *buckets) {
Efree(buckets->Count); Efree(buckets->Count);
Efree(buckets->ExpectedCount); Efree(buckets->ExpectedCount);
Efree(buckets); Efree(buckets);
} // FreeBuckets } // FreeBuckets
//--------------------------------------------------------------------------- /**
void FreeCluster(CLUSTER *Cluster) { * This routine frees the memory consumed by the specified
/* * cluster and all of its subclusters. This is done by
** Parameters: * recursive calls to FreeCluster().
** Cluster pointer to cluster to be freed *
** Operation: * @param Cluster pointer to cluster to be freed
** This routine frees the memory consumed by the specified *
** cluster and all of its subclusters. This is done by * @return None
** recursive calls to FreeCluster(). *
** Return: * @note Exceptions: None
** None * @note History: 6/6/89, DSJ, Created.
** Exceptions:
** None
** History:
** 6/6/89, DSJ, Created.
*/ */
void FreeCluster(CLUSTER *Cluster) {
if (Cluster != NULL) { if (Cluster != NULL) {
FreeCluster (Cluster->Left); FreeCluster (Cluster->Left);
FreeCluster (Cluster->Right); FreeCluster (Cluster->Right);
@ -2521,30 +2523,27 @@ void *FunctionParams, FLOAT64 InitialGuess, FLOAT64 Accuracy)
} // Solve } // Solve
//--------------------------------------------------------------------------- /**
FLOAT64 ChiArea(CHISTRUCT *ChiParams, FLOAT64 x) { * This routine computes the area under a chi density curve
/* * from 0 to x, minus the desired area under the curve. The
** Parameters: * number of degrees of freedom of the chi curve is specified
** ChiParams contains degrees of freedom and alpha * in the ChiParams structure. The desired area is also
** x value of chi-squared to evaluate * specified in the ChiParams structure as Alpha ( or 1 minus
** Operation: * the desired area ). This routine is intended to be passed
** This routine computes the area under a chi density curve * to the Solve() function to find the value of chi-squared
** from 0 to x, minus the desired area under the curve. The * which will yield a desired area under the right tail of
** number of degrees of freedom of the chi curve is specified * the chi density curve. The function will only work for
** in the ChiParams structure. The desired area is also * even degrees of freedom. The equations are based on
** specified in the ChiParams structure as Alpha ( or 1 minus * integrating the chi density curve in parts to obtain
** the desired area ). This routine is intended to be passed * a series that can be used to compute the area under the
** to the Solve() function to find the value of chi-squared * curve.
** which will yield a desired area under the right tail of * @param ChiParams contains degrees of freedom and alpha
** the chi density curve. The function will only work for * @param x value of chi-squared to evaluate
** even degrees of freedom. The equations are based on * @return Error between actual and desired area under the chi curve.
** integrating the chi density curve in parts to obtain * @note Exceptions: none
** a series that can be used to compute the area under the * @note History: Fri Aug 4 12:48:41 1989, DSJ, Created.
** curve.
** Return: Error between actual and desired area under the chi curve.
** Exceptions: none
** History: Fri Aug 4 12:48:41 1989, DSJ, Created.
*/ */
FLOAT64 ChiArea(CHISTRUCT *ChiParams, FLOAT64 x) {
int i, N; int i, N;
FLOAT64 SeriesTotal; FLOAT64 SeriesTotal;
FLOAT64 Denominator; FLOAT64 Denominator;
@ -2564,38 +2563,36 @@ FLOAT64 ChiArea(CHISTRUCT *ChiParams, FLOAT64 x) {
} // ChiArea } // ChiArea
//--------------------------------------------------------------------------- /**
* This routine looks at all samples in the specified cluster.
* It computes a running estimate of the percentage of the
* charaters which have more than 1 sample in the cluster.
* When this percentage exceeds MaxIllegal, TRUE is returned.
* Otherwise FALSE is returned. The CharID
* fields must contain integers which identify the training
* characters which were used to generate the sample. One
* integer is used for each sample. The NumChar field in
* the Clusterer must contain the number of characters in the
* training set. All CharID fields must be between 0 and
* NumChar-1. The main function of this routine is to help
* identify clusters which need to be split further, i.e. if
* numerous training characters have 2 or more features which are
* contained in the same cluster, then the cluster should be
* split.
*
* @param Clusterer data structure holding cluster tree
* @param Cluster cluster containing samples to be tested
* @param MaxIllegal max percentage of samples allowed to have
* more than 1 feature in the cluster
* @return TRUE if the cluster should be split, FALSE otherwise.
* @note Exceptions: none
* @note History: Wed Aug 30 11:13:05 1989, DSJ, Created.
* 2/22/90, DSJ, Added MaxIllegal control rather than always
* splitting illegal clusters.
*/
BOOL8 BOOL8
MultipleCharSamples (CLUSTERER * Clusterer, MultipleCharSamples (CLUSTERER * Clusterer,
CLUSTER * Cluster, FLOAT32 MaxIllegal) CLUSTER * Cluster, FLOAT32 MaxIllegal)
/*
** Parameters:
** Clusterer data structure holding cluster tree
** Cluster cluster containing samples to be tested
** MaxIllegal max percentage of samples allowed to have
** more than 1 feature in the cluster
** Operation:
** This routine looks at all samples in the specified cluster.
** It computes a running estimate of the percentage of the
** charaters which have more than 1 sample in the cluster.
** When this percentage exceeds MaxIllegal, TRUE is returned.
** Otherwise FALSE is returned. The CharID
** fields must contain integers which identify the training
** characters which were used to generate the sample. One
** integer is used for each sample. The NumChar field in
** the Clusterer must contain the number of characters in the
** training set. All CharID fields must be between 0 and
** NumChar-1. The main function of this routine is to help
** identify clusters which need to be split further, i.e. if
** numerous training characters have 2 or more features which are
** contained in the same cluster, then the cluster should be
** split.
** Return: TRUE if the cluster should be split, FALSE otherwise.
** Exceptions: none
** History: Wed Aug 30 11:13:05 1989, DSJ, Created.
** 2/22/90, DSJ, Added MaxIllegal control rather than always
** splitting illegal clusters.
*/
#define ILLEGAL_CHAR 2 #define ILLEGAL_CHAR 2
{ {
static BOOL8 *CharFlags = NULL; static BOOL8 *CharFlags = NULL;
@ -2646,9 +2643,11 @@ CLUSTER * Cluster, FLOAT32 MaxIllegal)
} // MultipleCharSamples } // MultipleCharSamples
// Compute the inverse of a matrix using LU decomposition with partial pivoting. /**
// The return value is the sum of norms of the off-diagonal terms of the * Compute the inverse of a matrix using LU decomposition with partial pivoting.
// product of a and inv. (A measure of the error.) * The return value is the sum of norms of the off-diagonal terms of the
* product of a and inv. (A measure of the error.)
*/
double InvertMatrix(const float* input, int size, float* inv) { double InvertMatrix(const float* input, int size, float* inv) {
// Allocate memory for the 2D arrays. // Allocate memory for the 2D arrays.
GENERIC_2D_ARRAY<double> U(size, size, 0.0); GENERIC_2D_ARRAY<double> U(size, size, 0.0);