~ubuntu-branches/ubuntu/utopic/sphinxtrain/utopic

« back to all changes in this revision

Viewing changes to include/s3/kdtree.h

  • Committer: Package Import Robot
  • Author(s): Samuel Thibault
  • Date: 2013-01-02 04:10:21 UTC
  • Revision ID: package-import@ubuntu.com-20130102041021-ynsizmz33fx02hea
Tags: upstream-1.0.8
ImportĀ upstreamĀ versionĀ 1.0.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ====================================================================
 
2
 * Copyright (c) 2005 Carnegie Mellon University.  All rights 
 
3
 * reserved.
 
4
 *
 
5
 * Redistribution and use in source and binary forms, with or without
 
6
 * modification, are permitted provided that the following conditions
 
7
 * are met:
 
8
 *
 
9
 * 1. Redistributions of source code must retain the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer. 
 
11
 *
 
12
 * 2. Redistributions in binary form must reproduce the above copyright
 
13
 *    notice, this list of conditions and the following disclaimer in
 
14
 *    the documentation and/or other materials provided with the
 
15
 *    distribution.
 
16
 *
 
17
 * This work was supported in part by funding from the Defense Advanced 
 
18
 * Research Projects Agency and the National Science Foundation of the 
 
19
 * United States of America, and the CMU Sphinx Speech Consortium.
 
20
 *
 
21
 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 
 
22
 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
 
23
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
24
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
 
25
 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
26
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
 
27
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 
28
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
 
29
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 
30
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 
31
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
32
 *
 
33
 * ====================================================================
 
34
 *
 
35
 */
 
36
/*********************************************************************
 
37
 *
 
38
 * File: kdtree.h
 
39
 * 
 
40
 * Description: kd-tree implementation for mixture Gaussians
 
41
 * 
 
42
 * Author: David Huggins-Daines <dhuggins@cs.cmu.edu>
 
43
 * 
 
44
 *********************************************************************/
 
45
 
 
46
#ifndef __KDTREE_H__
 
47
#define __KDTREE_H__
 
48
 
 
49
#ifdef __cplusplus
 
50
extern "C" {
 
51
#endif
 
52
#if 0
 
53
}
 
54
#endif
 
55
 
 
56
#include "sphinxbase/prim_type.h"
 
57
#include "s3/gauden.h"
 
58
#include "s3/vector.h"
 
59
 
 
60
typedef struct kd_tree_node_s kd_tree_node_t;
 
61
struct kd_tree_node_s {
 
62
        const vector_t *means, *variances; /* Codebook of Gaussians, shared by all nodes */
 
63
        float32 **boxes;             /* Gaussian boxes for codebook, shared by all nodes */
 
64
        float32 threshold;           /* Threshold for Gaussian boxes */
 
65
        uint32 n_level;              /* Number of levels (0 for non-root) */
 
66
        uint32 n_density, n_comp;    /* Number of densities, number of components. */
 
67
        uint8 *bbi;             /* BBI vector of intersecting Gaussians */
 
68
        vector_t lower, upper;  /* Lower and upper coordinates of projection */
 
69
        uint32 split_comp;      /* Dimension in which split is done */
 
70
        float32 split_plane;    /* Hyperplane splitting this node */
 
71
        kd_tree_node_t *left, *right; /* Child nodes */
 
72
};
 
73
 
 
74
kd_tree_node_t *build_kd_tree(const vector_t *means, const vector_t *variances,
 
75
                              uint32 n_density, uint32 n_comp,
 
76
                              float32 threshold, int32 n_levels,
 
77
                              int32 absolute);
 
78
void free_kd_tree(kd_tree_node_t *tree);
 
79
 
 
80
int32 write_kd_trees(const char *outfile, kd_tree_node_t **trees, uint32 n_trees);
 
81
int32 read_kd_trees(const char *infile, kd_tree_node_t ***out_trees, uint32 *out_n_trees);
 
82
 
 
83
#ifdef __cplusplus
 
84
}
 
85
#endif
 
86
#endif /* __KDTREE_H__ */