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