libsent/src/phmm/gprune_none.c

Go to the documentation of this file.
00001 
00036 /*
00037  * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University
00038  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00039  * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology
00040  * All rights reserved
00041  */
00042 
00043 #include <sent/stddefs.h>
00044 #include <sent/htk_hmm.h>
00045 #include <sent/htk_param.h>
00046 #include <sent/hmm.h>
00047 #include <sent/hmm_calc.h>
00048 
00058 LOGPROB
00059 compute_g_base(HMMWork *wrk, HTK_HMM_Dens *binfo)
00060 {
00061   VECT tmp, x;
00062   VECT *mean;
00063   VECT *var;
00064   VECT *vec = wrk->OP_vec;
00065   short veclen = wrk->OP_veclen;
00066 
00067   if (binfo == NULL) return(LOG_ZERO);
00068   mean = binfo->mean;
00069   var = binfo->var->vec;
00070   tmp = binfo->gconst;
00071   for (; veclen > 0; veclen--) {
00072     x = *(vec++) - *(mean++);
00073     tmp += x * x * *(var++);
00074   }
00075   return(tmp * -0.5);
00076 }
00077 
00085 boolean
00086 gprune_none_init(HMMWork *wrk)
00087 {
00088   /* maximum Gaussian set size = maximum mixture size */
00089   wrk->OP_calced_maxnum = wrk->OP_hmminfo->maxmixturenum;
00090   wrk->OP_calced_score = (LOGPROB *)mymalloc(sizeof(LOGPROB) * wrk->OP_calced_maxnum);
00091   wrk->OP_calced_id = (int *)mymalloc(sizeof(int) * wrk->OP_calced_maxnum);
00092   /* force gprune_num to the max number */
00093   wrk->OP_gprune_num = wrk->OP_calced_maxnum;
00094   return TRUE;
00095 }
00096 
00103 void
00104 gprune_none_free(HMMWork *wrk)
00105 {
00106   free(wrk->OP_calced_score);
00107   free(wrk->OP_calced_id);
00108 }
00109 
00125 void
00126 gprune_none(HMMWork *wrk, HTK_HMM_Dens **g, int num, int *last_id)
00127 {
00128   int i;
00129   HTK_HMM_Dens *dens;
00130   LOGPROB *prob = wrk->OP_calced_score;
00131   int *id = wrk->OP_calced_id;
00132 
00133   for(i=0; i<num; i++) {
00134     dens = *(g++);
00135     *(prob++) = compute_g_base(wrk, dens);
00136     *(id++) = i;
00137   }
00138   wrk->OP_calced_num = num;
00139 }

Generated on Tue Dec 18 15:59:56 2007 for Julius by  doxygen 1.5.4