SphinxBase 0.6
|
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 00002 /* ==================================================================== 00003 * Copyright (c) 2007 Carnegie Mellon University. All rights 00004 * reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 00010 * 1. Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in 00015 * the documentation and/or other materials provided with the 00016 * distribution. 00017 * 00018 * This work was supported in part by funding from the Defense Advanced 00019 * Research Projects Agency and the National Science Foundation of the 00020 * United States of America, and the CMU Sphinx Speech Consortium. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 00023 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00024 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00025 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 00026 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00027 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00028 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00029 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00030 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00031 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00032 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * ==================================================================== 00035 * 00036 */ 00072 #ifndef __LOGMATH_H__ 00073 #define __LOGMATH_H__ 00074 00075 #include <sphinxbase/sphinxbase_export.h> 00076 #include <sphinxbase/prim_type.h> 00077 #include <sphinxbase/cmd_ln.h> 00078 00079 00080 #ifdef __cplusplus 00081 extern "C" { 00082 #endif 00083 #if 0 00084 /* Fool Emacs. */ 00085 } 00086 #endif 00087 00093 typedef struct logadd_s logadd_t; 00094 struct logadd_s { 00096 void *table; 00098 uint32 table_size; 00100 uint8 width; 00102 int8 shift; 00103 }; 00104 00108 typedef struct logmath_s logmath_t; 00109 00113 #define LOGMATH_TABLE(lm) ((logadd_t *)lm) 00114 00122 SPHINXBASE_EXPORT 00123 logmath_t *logmath_init(float64 base, int shift, int use_table); 00124 00128 SPHINXBASE_EXPORT 00129 logmath_t *logmath_read(const char *filename); 00130 00134 SPHINXBASE_EXPORT 00135 int32 logmath_write(logmath_t *lmath, const char *filename); 00136 00140 SPHINXBASE_EXPORT 00141 int32 logmath_get_table_shape(logmath_t *lmath, uint32 *out_size, 00142 uint32 *out_width, uint32 *out_shift); 00143 00147 SPHINXBASE_EXPORT 00148 float64 logmath_get_base(logmath_t *lmath); 00149 00153 SPHINXBASE_EXPORT 00154 int logmath_get_zero(logmath_t *lmath); 00155 00159 SPHINXBASE_EXPORT 00160 int logmath_get_width(logmath_t *lmath); 00161 00165 SPHINXBASE_EXPORT 00166 int logmath_get_shift(logmath_t *lmath); 00167 00173 SPHINXBASE_EXPORT 00174 logmath_t *logmath_retain(logmath_t *lmath); 00175 00181 SPHINXBASE_EXPORT 00182 int logmath_free(logmath_t *lmath); 00183 00187 SPHINXBASE_EXPORT 00188 int logmath_add_exact(logmath_t *lmath, int logb_p, int logb_q); 00189 00193 SPHINXBASE_EXPORT 00194 int logmath_add(logmath_t *lmath, int logb_p, int logb_q); 00195 00199 SPHINXBASE_EXPORT 00200 int logmath_log(logmath_t *lmath, float64 p); 00201 00205 SPHINXBASE_EXPORT 00206 float64 logmath_exp(logmath_t *lmath, int logb_p); 00207 00211 SPHINXBASE_EXPORT 00212 int logmath_ln_to_log(logmath_t *lmath, float64 log_p); 00213 00217 SPHINXBASE_EXPORT 00218 float64 logmath_log_to_ln(logmath_t *lmath, int logb_p); 00219 00223 SPHINXBASE_EXPORT 00224 int logmath_log10_to_log(logmath_t *lmath, float64 log_p); 00225 00229 SPHINXBASE_EXPORT 00230 float64 logmath_log_to_log10(logmath_t *lmath, int logb_p); 00231 00232 #ifdef __cplusplus 00233 } 00234 #endif 00235 00236 00237 #endif /* __LOGMATH_H__ */