1 /* ====================================================================
2 * Copyright (c) 1999-2004 Carnegie Mellon University. All rights
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
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
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.
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.
33 * ====================================================================
39 * **********************************************
40 * CMU ARPA Speech Project
42 * Copyright (c) 1997 Carnegie Mellon University.
43 * ALL RIGHTS RESERVED.
44 * **********************************************
48 * Revision 1.1.1.1 2006/05/23 18:45:03 dhuggins
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)
55 * Revision 1.9 2005/06/21 19:23:35 arthchan2003
56 * 1, Fixed doxygen documentation. 2, Added $ keyword.
58 * Revision 1.6 2005/06/13 04:02:56 archan
59 * Fixed most doxygen-style documentation under libs3decoder.
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.
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.
67 * Revision 1.3 2005/03/30 01:22:47 archan
68 * Fixed mistakes in last updates. Add
71 * 20.Apr.2001 RAH (rhoughton@mediasite.com, ricky.houghton@cs.cmu.edu)
72 * Added tmat_free to free allocated memory
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.
77 * 10-Dec-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University.
80 * 11-Mar-97 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University.
81 * Started based on original S3 implementation.
91 /* SphinxBase headers. */
92 #include <sphinxbase/logmath.h>
95 * \brief Transition matrix data structure.
101 } /* Fool Emacs into not indenting things. */
106 * \brief Transition matrix data structure. All phone HMMs are assumed to have the same
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 */
118 /** Initialize transition matrix */
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 */
128 /** Dumping the transition matrix for debugging */
130 void tmat_dump (tmat_t *tmat, /**< In: transition matrix */
131 FILE *fp /**< In: file pointer */
136 * RAH, add code to remove memory allocated by tmat_init
139 void tmat_free (tmat_t *t /**< In: transition matrix */
143 * Report the detail of the transition matrix structure.
145 void tmat_report(tmat_t *t /**< In: transition matrix*/
149 { /* Stop indent from complaining */