⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gprune_common.c

📁 about sound recognition.i want to downlod
💻 C
字号:
/** * @file   gprune_common.c * @author Akinobu LEE * @date   Fri Feb 18 18:10:58 2005 *  * <JA> * @brief  寒圭ガウス尸邵纷换: Gaussian pruning (鼎奶婶) * * ここには Gaussian pruningにおいて称アルゴリズムで鼎奶に脱いられる * キャッシュ拎侯簇眶などが崔まれていますˉ * </JA> *  * <EN> * @brief  Calculate probability of a set of Gaussian densities by * Gaussian pruning: common functions * * This file contains functions concerning codebook level cache * manipulation, commonly used for the Gaussian pruning functions. * </EN> *  * $Revision: 1.3 $ *  *//* * Copyright (c) 1991-2006 Kawahara Lab., Kyoto University * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology * Copyright (c) 2005-2006 Julius project team, Nagoya Institute of Technology * All rights reserved */#include <sent/stddefs.h>#include <sent/htk_hmm.h>#include <sent/htk_param.h>#include <sent/hmm.h>#include <sent/gprune.h>#include "globalvars.h"/**  * Find where the new value should be inserted to the OP_cacled_score, * already sorted by score, using binary search. *  * @param score [in] the new score to be inserted * @param len [in] length of data in OP_calced_score *  * @return the insertion point. */static intfind_insert_point(LOGPROB score, int len){  /* binary search on score */  int left = 0;  int right = len - 1;  int mid;  while (left < right) {    mid = (left + right) / 2;    if (OP_calced_score[mid] > score) {      left = mid + 1;    } else {      right = mid;    }  }  return(left);}/**  * @brief  Store a score to the current list of computed Gaussians. *  * Store the calculated score of a Gaussian to OP_calced_score, with its * corresponding mixture id to OP_calced_id. * * The OP_calced_score and OP_calced_id always holds the * (OP_gprune_num)-best scores and ids.  If the number of stored * Gaussian from start has reached OP_gprune_num and the given score is * below the bottom, it will be dropped.  Else, the new * score will be inserted and the bottom will be dropped from the list. * * The OP_calced_score will always kept sorted by the scores. *  * @param id [in] mixture id of the Gaussian to store * @param score [in] score of the Gaussian to store * @param len [in] current number of stored scores in OP_calced_score *  * @return the resulting number of stored scores in OP_calced_score. */intcache_push(int id, LOGPROB score, int len){  int insertp;  if (len == 0) {               /* first one */    OP_calced_score[0] = score;    OP_calced_id[0] = id;    return(1);  }  if (OP_calced_score[len-1] >= score) { /* bottom */    if (len < OP_gprune_num) {          /* append to bottom */      OP_calced_score[len] = score;      OP_calced_id[len] = id;      len++;    }    return len;  }  if (OP_calced_score[0] < score) {    insertp = 0;  } else {    insertp = find_insert_point(score, len);  }  if (len < OP_gprune_num) {    memmove(&(OP_calced_score[insertp+1]), &(OP_calced_score[insertp]), sizeof(LOGPROB)*(len - insertp));    memmove(&(OP_calced_id[insertp+1]), &(OP_calced_id[insertp]), sizeof(int)*(len - insertp));      } else if (insertp < len - 1) {    memmove(&(OP_calced_score[insertp+1]), &(OP_calced_score[insertp]), sizeof(LOGPROB)*(len - insertp - 1));    memmove(&(OP_calced_id[insertp+1]), &(OP_calced_id[insertp]), sizeof(int)*(len - insertp - 1));  }  OP_calced_score[insertp] = score;  OP_calced_id[insertp] = id;  if (len < OP_gprune_num) len++;  return(len);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -