• Main Page
  • Related Pages
  • Data Structures
  • Files
  • File List
  • Globals

include/logmath.h

Go to the documentation of this file.
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_export.h>
00076 #include <sphinx_config.h>
00077 #include <prim_type.h>
00078 #include <cmd_ln.h>
00079 
00080 
00081 #ifdef __cplusplus
00082 extern "C" {
00083 #endif
00084 #if 0
00085 /* Fool Emacs. */
00086 }
00087 #endif
00088 
00094 typedef struct logadd_s logadd_t;
00095 struct logadd_s {
00097     void *table;
00099     uint32 table_size;
00101     uint8 width;
00103     int8 shift;
00104 };
00105 
00109 typedef struct logmath_s logmath_t;
00110 
00114 #define LOGMATH_TABLE(lm) ((logadd_t *)lm)
00115 
00123 SPHINXBASE_EXPORT
00124 logmath_t *logmath_init(float64 base, int shift, int use_table);
00125 
00129 SPHINXBASE_EXPORT
00130 logmath_t *logmath_read(const char *filename);
00131 
00135 SPHINXBASE_EXPORT
00136 int32 logmath_write(logmath_t *lmath, const char *filename);
00137 
00141 SPHINXBASE_EXPORT
00142 int32 logmath_get_table_shape(logmath_t *lmath, uint32 *out_size,
00143                               uint32 *out_width, uint32 *out_shift);
00144 
00148 SPHINXBASE_EXPORT
00149 float64 logmath_get_base(logmath_t *lmath);
00150 
00154 SPHINXBASE_EXPORT
00155 int logmath_get_zero(logmath_t *lmath);
00156 
00160 SPHINXBASE_EXPORT
00161 int logmath_get_width(logmath_t *lmath);
00162 
00166 SPHINXBASE_EXPORT
00167 int logmath_get_shift(logmath_t *lmath);
00168 
00174 SPHINXBASE_EXPORT
00175 logmath_t *logmath_retain(logmath_t *lmath);
00176 
00182 SPHINXBASE_EXPORT
00183 int logmath_free(logmath_t *lmath);
00184 
00188 SPHINXBASE_EXPORT
00189 int logmath_add_exact(logmath_t *lmath, int logb_p, int logb_q);
00190 
00194 SPHINXBASE_EXPORT
00195 int logmath_add(logmath_t *lmath, int logb_p, int logb_q);
00196 
00200 SPHINXBASE_EXPORT
00201 int logmath_log(logmath_t *lmath, float64 p);
00202 
00206 SPHINXBASE_EXPORT
00207 float64 logmath_exp(logmath_t *lmath, int logb_p);
00208 
00212 SPHINXBASE_EXPORT
00213 int logmath_ln_to_log(logmath_t *lmath, float64 log_p);
00214 
00218 SPHINXBASE_EXPORT
00219 float64 logmath_log_to_ln(logmath_t *lmath, int logb_p);
00220 
00224 SPHINXBASE_EXPORT
00225 int logmath_log10_to_log(logmath_t *lmath, float64 log_p);
00226 
00230 SPHINXBASE_EXPORT
00231 float64 logmath_log_to_log10(logmath_t *lmath, int logb_p);
00232 
00233 #ifdef __cplusplus
00234 }
00235 #endif
00236 
00237 
00238 #endif /*  __LOGMATH_H__ */

Generated on Thu Jan 6 2011 for SphinxBase by  doxygen 1.7.1