Initial import to Tizen
[profile/ivi/pocketsphinx.git] / src / libpocketsphinx / tmat.h
1 /* ====================================================================
2  * Copyright (c) 1999-2004 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  * tmat.h
38  *
39  * **********************************************
40  * CMU ARPA Speech Project
41  *
42  * Copyright (c) 1997 Carnegie Mellon University.
43  * ALL RIGHTS RESERVED.
44  * **********************************************
45  * 
46  * HISTORY
47  * $Log: tmat.h,v $
48  * Revision 1.1.1.1  2006/05/23 18:45:03  dhuggins
49  * re-importation
50  *
51  * Revision 1.1  2005/09/29 21:51:19  dhuggins
52  * Add support for Sphinx3 tmat files.  Amazingly enough, it Just Works
53  * (but it isn't terribly robust)
54  *
55  * Revision 1.9  2005/06/21 19:23:35  arthchan2003
56  * 1, Fixed doxygen documentation. 2, Added $ keyword.
57  *
58  * Revision 1.6  2005/06/13 04:02:56  archan
59  * Fixed most doxygen-style documentation under libs3decoder.
60  *
61  * Revision 1.5  2005/05/03 04:09:09  archan
62  * Implemented the heart of word copy search. For every ci-phone, every word end, a tree will be allocated to preserve its pathscore.  This is different from 3.5 or below, only the best score for a particular ci-phone, regardless of the word-ends will be preserved at every frame.  The graph propagation will not collect unused word tree at this point. srch_WST_propagate_wd_lv2 is also as the most stupid in the century.  But well, after all, everything needs a start.  I will then really get the results from the search and see how it looks.
63  *
64  * Revision 1.4  2005/04/21 23:50:26  archan
65  * Some more refactoring on the how reporting of structures inside kbcore_t is done, it is now 50% nice. Also added class-based LM test case into test-decode.sh.in.  At this moment, everything in search mode 5 is already done.  It is time to test the idea whether the search can really be used.
66  *
67  * Revision 1.3  2005/03/30 01:22:47  archan
68  * Fixed mistakes in last updates. Add
69  *
70  * 
71  * 20.Apr.2001  RAH (rhoughton@mediasite.com, ricky.houghton@cs.cmu.edu)
72  *              Added tmat_free to free allocated memory 
73  *
74  * 29-Feb-2000  M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University.
75  *              Added tmat_chk_1skip(), and made tmat_chk_uppertri() public.
76  * 
77  * 10-Dec-1999  M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University.
78  *              Added tmat_dump().
79  * 
80  * 11-Mar-97    M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University.
81  *              Started based on original S3 implementation.
82  */
83
84
85 #ifndef _S3_TMAT_H_
86 #define _S3_TMAT_H_
87
88 /* System headers. */
89 #include <stdio.h>
90
91 /* SphinxBase headers. */
92 #include <sphinxbase/logmath.h>
93
94 /** \file tmat.h
95  *  \brief Transition matrix data structure.
96  */
97 #ifdef __cplusplus
98 extern "C" {
99 #endif
100 #if 0
101 } /* Fool Emacs into not indenting things. */
102 #endif
103
104 /**
105  * \struct tmat_t
106  * \brief Transition matrix data structure.  All phone HMMs are assumed to have the same
107  * topology.
108  */
109 typedef struct {
110     uint8 ***tp;        /**< The transition matrices; kept in the same scale as acoustic scores;
111                            tp[tmatid][from-state][to-state] */
112     int16 n_tmat;       /**< Number matrices */
113     int16 n_state;      /**< Number source states in matrix (only the emitting states);
114                            Number destination states = n_state+1, it includes the exit state */
115 } tmat_t;
116
117
118 /** Initialize transition matrix */
119
120 tmat_t *tmat_init (char const *tmatfile,/**< In: input file */
121                    logmath_t *lmath,    /**< In: log math parameters */
122                    float64 tpfloor,     /**< In: floor value for each non-zero transition probability */
123                    int32 breport      /**< In: whether reporting the process of tmat_t  */
124     );
125                                             
126
127
128 /** Dumping the transition matrix for debugging */
129
130 void tmat_dump (tmat_t *tmat,  /**< In: transition matrix */
131                 FILE *fp       /**< In: file pointer */
132     );  
133
134
135 /**
136  * RAH, add code to remove memory allocated by tmat_init
137  */
138
139 void tmat_free (tmat_t *t /**< In: transition matrix */
140     );
141
142 /**
143  * Report the detail of the transition matrix structure. 
144  */
145 void tmat_report(tmat_t *t /**< In: transition matrix*/
146     );
147
148 #if 0
149 { /* Stop indent from complaining */
150 #endif
151 #ifdef __cplusplus
152 }
153 #endif
154
155 #endif