コード例 #1
0
/* HMM_initGlobals -
 *  Given a number of states and a sequence length, allocates or reallocates
 *  memory for internal variables.
 */
void HMM_initGlobals(int uu, int tt)
{ if (g_alpha==NULL||COLUMNS(g_alpha)<tt||ROWS(g_alpha)<uu)
  { if (g_alpha!=NULL)
    { freeRMat(g_alpha);
      freeRMat(g_delta);
      freeRMat(g_deltav);	/* This could be int. */
      freeRMat(g_beta);
      freeRMat3d(g_psi);}
    g_alpha = allocRMat(uu, tt);
    g_delta = allocRMat(uu, tt);
    g_deltav = allocRMat(uu, tt); /* This could be int. */
    g_beta = allocRMat(uu, tt);
    g_psi = allocRMat3d(uu, uu, tt);}}
コード例 #2
0
/* allocHMM - Allocates space for an HMM and returns a pointer to it. */
Hmm *allocHMM(int uu)
{ Hmm *m = (Hmm *)safe_malloc(sizeof(Hmm));
  assert(uu>0);
  m->logA = allocRMat(uu, uu);
  m->logB = allocRVec(uu);
  m->uu = uu;
  return m;}
コード例 #3
0
ファイル: hmm.c プロジェクト: LinaW/sentence-training
xHmm *allocXHMM(int uu, int ii, int tt){
  assert(uu > 0 && ii > 0 && tt > 0);
  xHmm *xhmm = safe_malloc(sizeof *xhmm);
  xhmm->m = allocHMM(uu);
  xhmm->ii = ii;
  xhmm->tt = tt;
  if (tt > 1)
    xhmm->bps = allocRMat3d(tt - 1, ii, ii);
  else xhmm->bps = NULL;
  xhmm->bss = allocRMat(tt, ii);
  return xhmm;
}