gfsmLookup.h
Go to the documentation of this file.
1 
2 /*=============================================================================*\
3  * File: gfsmLookup.h
4  * Author: Bryan Jurish <moocow.bovine@gmail.com>
5  * Description: finite state machine library
6  *
7  * Copyright (c) 2005-2014 Bryan Jurish.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 3 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  *=============================================================================*/
23 
28 #ifndef _GFSM_LOOKUP_H
29 #define _GFSM_LOOKUP_H
30 
31 #include <gfsmAutomaton.h>
32 #include <gfsmUtils.h>
33 
34 /*======================================================================
35  * Types: lookup
36  */
37 
39 typedef struct {
42  guint32 i;
44 
45 
46 //------------------------------
47 
49 typedef GPtrArray gfsmViterbiTable;
50 
55 typedef GTree gfsmViterbiMap;
56 
59 
62 
66 typedef GSList gfsmViterbiColumn;
67 
75 
76 
77 /*======================================================================
78  * Constants
79  */
80 
83 
86 
87 /*======================================================================
88  * Methods: lookup
89  */
91 
92 
93 //------------------------------
101 #define gfsm_automaton_lookup(fst,input,result) \
102  gfsm_automaton_lookup_full((fst),(input),(result),NULL,gfsmLookupMaxResultStates)
103 
104 //------------------------------
115  gfsmLabelVector *input,
116  gfsmAutomaton *result,
117  gfsmStateIdVector *statemap,
118  gfsmStateId max_result_states);
119 
121 
122 
123 /*======================================================================
124  * Methods: Viterbi
125  */
127 
128 
129 //------------------------------
139 #define gfsm_automaton_lookup_viterbi(fst,input,trellis) \
140  gfsm_automaton_lookup_viterbi_full((fst),(input),(trellis),NULL)
141 
142 //------------------------------
157  gfsmLabelVector *input,
158  gfsmAutomaton *trellis,
159  gfsmStateIdVector *trellis2fst);
160 
162 
163 /*======================================================================
164  * Viterbi: Utilities
165  */
167 
168 
169 
170 //------------------------------
171 // expand_column()
172 
175  gfsmAutomaton *trellis,
176  gfsmViterbiColumn *col,
177  gfsmStateIdVector *trellis2fst,
178  gfsmViterbiMap *fst2trellis);
179 
180 
181 //------------------------------
182 // gfsmViterbiMap
183 
185 #define gfsm_viterbi_map_new() \
186  g_tree_new_full((GCompareDataFunc)gfsm_uint_compare, NULL, NULL, NULL)
187 
188 
190 #define gfsm_viterbi_map_free(vmap) g_tree_destroy(vmap)
191 
192 
196 #define gfsm_viterbi_map_lookup(vmap,key) g_tree_lookup((vmap),(key))
197 
199 #define gfsm_viterbi_map_insert(vmap,key,val) g_tree_insert((vmap),(gpointer)(key),(gpointer)(val))
200 
201 
202 //------------------------------
203 // gfsmViterbiNode
204 
206 //#define gfsm_viterbi_node_arc(nod) ((gfsmArc*)((nod)->arcs->data))
207 #define gfsm_viterbi_node_arc(nod) gfsm_arclist_arc((nod)->arcs)
208 
210 #define gfsm_viterbi_node_best_prevstate(nod) gfsm_viterbi_node_arc(nod)->target
211 
213 #define gfsm_viterbi_node_best_weight(nod) gfsm_viterbi_node_arc(nod)->weight
214 
216 
217 #endif /* _GFSM_LOOKUP_H */