PocketSphinx  5.0.0rc5
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  */
72 #ifndef __LOGMATH_H__
73 #define __LOGMATH_H__
74 
75 #include <pocketsphinx/export.h>
76 #include <pocketsphinx/prim_type.h>
77 
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
81 #if 0
82 /* Fool Emacs. */
83 }
84 #endif
85 
91 typedef struct logadd_s logadd_t;
92 struct logadd_s {
94  void *table;
96  uint32 table_size;
98  uint8 width;
100  int8 shift;
101 };
102 
106 typedef struct logmath_s logmath_t;
107 
111 #define LOGMATH_TABLE(lm) ((logadd_t *)lm)
112 
120 POCKETSPHINX_EXPORT
121 logmath_t *logmath_init(float64 base, int shift, int use_table);
122 
126 POCKETSPHINX_EXPORT
127 logmath_t *logmath_read(const char *filename);
128 
132 POCKETSPHINX_EXPORT
133 int32 logmath_write(logmath_t *lmath, const char *filename);
134 
138 POCKETSPHINX_EXPORT
139 int32 logmath_get_table_shape(logmath_t *lmath, uint32 *out_size,
140  uint32 *out_width, uint32 *out_shift);
141 
145 POCKETSPHINX_EXPORT
146 float64 logmath_get_base(logmath_t *lmath);
147 
151 POCKETSPHINX_EXPORT
152 int logmath_get_zero(logmath_t *lmath);
153 
157 POCKETSPHINX_EXPORT
158 int logmath_get_width(logmath_t *lmath);
159 
163 POCKETSPHINX_EXPORT
164 int logmath_get_shift(logmath_t *lmath);
165 
171 POCKETSPHINX_EXPORT
173 
179 POCKETSPHINX_EXPORT
180 int logmath_free(logmath_t *lmath);
181 
185 POCKETSPHINX_EXPORT
186 int logmath_add_exact(logmath_t *lmath, int logb_p, int logb_q);
187 
191 POCKETSPHINX_EXPORT
192 int logmath_add(logmath_t *lmath, int logb_p, int logb_q);
193 
197 POCKETSPHINX_EXPORT
198 int logmath_log(logmath_t *lmath, float64 p);
199 
203 POCKETSPHINX_EXPORT
204 float64 logmath_exp(logmath_t *lmath, int logb_p);
205 
209 POCKETSPHINX_EXPORT
210 int logmath_ln_to_log(logmath_t *lmath, float64 log_p);
211 
215 POCKETSPHINX_EXPORT
216 float64 logmath_log_to_ln(logmath_t *lmath, int logb_p);
217 
221 POCKETSPHINX_EXPORT
222 int logmath_log10_to_log(logmath_t *lmath, float64 log_p);
223 
227 POCKETSPHINX_EXPORT
228 float logmath_log10_to_log_float(logmath_t *lmath, float64 log_p);
229 
233 POCKETSPHINX_EXPORT
234 float64 logmath_log_to_log10(logmath_t *lmath, int logb_p);
235 
239 POCKETSPHINX_EXPORT
240 float64 logmath_log_float_to_log10(logmath_t *lmath, float log_p);
241 
242 #ifdef __cplusplus
243 }
244 #endif
245 
246 
247 #endif /* __LOGMATH_H__ */
logmath_log_to_ln
POCKETSPHINX_EXPORT float64 logmath_log_to_ln(logmath_t *lmath, int logb_p)
logmath_t
struct logmath_s logmath_t
Definition: logmath.h:106
logmath_get_base
POCKETSPHINX_EXPORT float64 logmath_get_base(logmath_t *lmath)
logadd_s::table
void * table
Definition: logmath.h:94
prim_type.h
Basic type definitions used in Sphinx.
logmath_get_zero
POCKETSPHINX_EXPORT int logmath_get_zero(logmath_t *lmath)
logmath_log_to_log10
POCKETSPHINX_EXPORT float64 logmath_log_to_log10(logmath_t *lmath, int logb_p)
logmath_add
POCKETSPHINX_EXPORT int logmath_add(logmath_t *lmath, int logb_p, int logb_q)
logmath_log10_to_log
POCKETSPHINX_EXPORT int logmath_log10_to_log(logmath_t *lmath, float64 log_p)
logadd_s::shift
int8 shift
Definition: logmath.h:100
logmath_get_table_shape
POCKETSPHINX_EXPORT int32 logmath_get_table_shape(logmath_t *lmath, uint32 *out_size, uint32 *out_width, uint32 *out_shift)
logadd_s::width
uint8 width
Definition: logmath.h:98
logadd_s
Definition: logmath.h:92
logmath_log10_to_log_float
POCKETSPHINX_EXPORT float logmath_log10_to_log_float(logmath_t *lmath, float64 log_p)
logmath_retain
POCKETSPHINX_EXPORT logmath_t * logmath_retain(logmath_t *lmath)
logmath_get_width
POCKETSPHINX_EXPORT int logmath_get_width(logmath_t *lmath)
logmath_add_exact
POCKETSPHINX_EXPORT int logmath_add_exact(logmath_t *lmath, int logb_p, int logb_q)
logmath_log_float_to_log10
POCKETSPHINX_EXPORT float64 logmath_log_float_to_log10(logmath_t *lmath, float log_p)
logmath_read
POCKETSPHINX_EXPORT logmath_t * logmath_read(const char *filename)
logmath_init
POCKETSPHINX_EXPORT logmath_t * logmath_init(float64 base, int shift, int use_table)
logmath_log
POCKETSPHINX_EXPORT int logmath_log(logmath_t *lmath, float64 p)
logmath_exp
POCKETSPHINX_EXPORT float64 logmath_exp(logmath_t *lmath, int logb_p)
logmath_free
POCKETSPHINX_EXPORT int logmath_free(logmath_t *lmath)
logmath_get_shift
POCKETSPHINX_EXPORT int logmath_get_shift(logmath_t *lmath)
logadd_s::table_size
uint32 table_size
Definition: logmath.h:96
logmath_write
POCKETSPHINX_EXPORT int32 logmath_write(logmath_t *lmath, const char *filename)
logmath_ln_to_log
POCKETSPHINX_EXPORT int logmath_ln_to_log(logmath_t *lmath, float64 log_p)