PocketSphinx  5.0.0
A small speech recognizer
logmath.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 2007 Carnegie Mellon University. All rights
4  * reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * This work was supported in part by funding from the Defense Advanced
19  * Research Projects Agency and the National Science Foundation of the
20  * United States of America, and the CMU Sphinx Speech Consortium.
21  *
22  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
23  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
26  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * ====================================================================
35  *
36  */
75 #ifndef __LOGMATH_H__
76 #define __LOGMATH_H__
77 
78 #include <pocketsphinx/export.h>
79 #include <pocketsphinx/prim_type.h>
80 
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84 #if 0
85 /* Fool Emacs. */
86 }
87 #endif
88 
95 typedef struct logadd_s logadd_t;
96 struct logadd_s {
98  void *table;
100  uint32 table_size;
102  uint8 width;
104  int8 shift;
105 };
106 
111 typedef struct logmath_s logmath_t;
112 
116 #define LOGMATH_TABLE(lm) ((logadd_t *)lm)
117 
126 POCKETSPHINX_EXPORT
127 logmath_t *logmath_init(float64 base, int shift, int use_table);
128 
133 POCKETSPHINX_EXPORT
134 logmath_t *logmath_read(const char *filename);
135 
140 POCKETSPHINX_EXPORT
141 int32 logmath_write(logmath_t *lmath, const char *filename);
142 
147 POCKETSPHINX_EXPORT
148 int32 logmath_get_table_shape(logmath_t *lmath, uint32 *out_size,
149  uint32 *out_width, uint32 *out_shift);
150 
155 POCKETSPHINX_EXPORT
156 float64 logmath_get_base(logmath_t *lmath);
157 
162 POCKETSPHINX_EXPORT
163 int logmath_get_zero(logmath_t *lmath);
164 
169 POCKETSPHINX_EXPORT
170 int logmath_get_width(logmath_t *lmath);
171 
176 POCKETSPHINX_EXPORT
177 int logmath_get_shift(logmath_t *lmath);
178 
185 POCKETSPHINX_EXPORT
187 
194 POCKETSPHINX_EXPORT
195 int logmath_free(logmath_t *lmath);
196 
201 POCKETSPHINX_EXPORT
202 int logmath_add_exact(logmath_t *lmath, int logb_p, int logb_q);
203 
208 POCKETSPHINX_EXPORT
209 int logmath_add(logmath_t *lmath, int logb_p, int logb_q);
210 
215 POCKETSPHINX_EXPORT
216 int logmath_log(logmath_t *lmath, float64 p);
217 
222 POCKETSPHINX_EXPORT
223 float64 logmath_exp(logmath_t *lmath, int logb_p);
224 
229 POCKETSPHINX_EXPORT
230 int logmath_ln_to_log(logmath_t *lmath, float64 log_p);
231 
236 POCKETSPHINX_EXPORT
237 float64 logmath_log_to_ln(logmath_t *lmath, int logb_p);
238 
243 POCKETSPHINX_EXPORT
244 int logmath_log10_to_log(logmath_t *lmath, float64 log_p);
245 
250 POCKETSPHINX_EXPORT
251 float logmath_log10_to_log_float(logmath_t *lmath, float64 log_p);
252 
257 POCKETSPHINX_EXPORT
258 float64 logmath_log_to_log10(logmath_t *lmath, int logb_p);
259 
264 POCKETSPHINX_EXPORT
265 float64 logmath_log_float_to_log10(logmath_t *lmath, float log_p);
266 
267 #ifdef __cplusplus
268 }
269 #endif
270 
271 
272 #endif /* __LOGMATH_H__ */
logadd_t
Integer log math computation table.
prim_type.h
Basic type definitions used in Sphinx.
logmath_t::logmath_read
POCKETSPHINX_EXPORT logmath_t * logmath_read(const char *filename)
logmath_t::logmath_log
POCKETSPHINX_EXPORT int logmath_log(logmath_t *lmath, float64 p)
logmath_t::logmath_add_exact
POCKETSPHINX_EXPORT int logmath_add_exact(logmath_t *lmath, int logb_p, int logb_q)
logmath_t::logmath_get_table_shape
POCKETSPHINX_EXPORT int32 logmath_get_table_shape(logmath_t *lmath, uint32 *out_size, uint32 *out_width, uint32 *out_shift)
logmath_t::logmath_retain
POCKETSPHINX_EXPORT logmath_t * logmath_retain(logmath_t *lmath)
logmath_t::logmath_exp
POCKETSPHINX_EXPORT float64 logmath_exp(logmath_t *lmath, int logb_p)
logmath_t::logmath_get_shift
POCKETSPHINX_EXPORT int logmath_get_shift(logmath_t *lmath)
logmath_t::logmath_log10_to_log_float
POCKETSPHINX_EXPORT float logmath_log10_to_log_float(logmath_t *lmath, float64 log_p)
logmath_t::logmath_ln_to_log
POCKETSPHINX_EXPORT int logmath_ln_to_log(logmath_t *lmath, float64 log_p)
logmath_t::logmath_get_base
POCKETSPHINX_EXPORT float64 logmath_get_base(logmath_t *lmath)
logmath_t::logmath_log_float_to_log10
POCKETSPHINX_EXPORT float64 logmath_log_float_to_log10(logmath_t *lmath, float log_p)
logmath_t::logmath_get_width
POCKETSPHINX_EXPORT int logmath_get_width(logmath_t *lmath)
logmath_t::logmath_free
POCKETSPHINX_EXPORT int logmath_free(logmath_t *lmath)
logmath_t::logmath_log10_to_log
POCKETSPHINX_EXPORT int logmath_log10_to_log(logmath_t *lmath, float64 log_p)
logmath_t::logmath_add
POCKETSPHINX_EXPORT int logmath_add(logmath_t *lmath, int logb_p, int logb_q)
logmath_t
Integer log math computation class.
logmath_t::logmath_init
POCKETSPHINX_EXPORT logmath_t * logmath_init(float64 base, int shift, int use_table)
logmath_t::logmath_log_to_log10
POCKETSPHINX_EXPORT float64 logmath_log_to_log10(logmath_t *lmath, int logb_p)
logmath_t::logmath_write
POCKETSPHINX_EXPORT int32 logmath_write(logmath_t *lmath, const char *filename)
logmath_t::logmath_log_to_ln
POCKETSPHINX_EXPORT float64 logmath_log_to_ln(logmath_t *lmath, int logb_p)
logmath_t::logmath_get_zero
POCKETSPHINX_EXPORT int logmath_get_zero(logmath_t *lmath)