deps/kb_meme/meme-5.0.1/src/build-hmm.c
/*************************************************************************
 * Using information stored in the states of an HMM, fill in the HMM's
 * transition matrix.
 *************************************************************************/
Using information stored in the states of an HMM, fill in the HMM's
transition matrix.
Using information stored in the states of an HMM fill in the HMM ' s transition matrix .
static void build_transition_matrix
  (MHMM_T *the_hmm)
{
  int            i_state;    
  int            j_state; 
  MHMM_STATE_T * this_state; 
  int            num_out;    
  int            i_out;      
  check_sq_matrix(the_hmm->trans, the_hmm->num_states);
  for (i_state = 0; i_state < the_hmm->num_states; i_state++) {
    for (j_state = 0; j_state < the_hmm->num_states; j_state++) {
      set_matrix_cell(i_state, j_state, 0.0, the_hmm->trans);
    }
  }
  for (i_state = 0; i_state < the_hmm->num_states; i_state++) {
    this_state = &(the_hmm->states[i_state]);
    num_out = this_state->ntrans_out;
    for (i_out = 0; i_out < num_out; i_out++) {
      j_state = this_state->itrans_out[i_out];
      assert(j_state != 0);
      set_matrix_cell(i_state, j_state, 
		      get_array_item(i_out, this_state->trans_out),
		      the_hmm->trans);
    }
  }
  assert(verify_trans_matrix(false, the_hmm->num_states, the_hmm->trans));
}
static void build_transition_matrix ( MHMM_T * the_hmm ) { int i_state ; int j_state ; MHMM_STATE_T * this_state ; int num_out ; int i_out ; check_sq_matrix ( the_hmm -> trans , the_hmm -> num_states ) ; for ( i_state = 0 ; i_state < the_hmm -> num_states ; i_state ++ ) { for ( j_state = 0 ; j_state < the_hmm -> num_states ; j_state ++ ) { set_matrix_cell ( i_state , j_state , 0.0 , the_hmm -> trans ) ; } } for ( i_state = 0 ; i_state < the_hmm -> num_states ; i_state ++ ) { this_state = & ( the_hmm -> states [ i_state ] ) ; num_out = this_state -> ntrans_out ; for ( i_out = 0 ; i_out < num_out ; i_out ++ ) { j_state = this_state -> itrans_out [ i_out ] ; assert ( j_state != 0 ) ; set_matrix_cell ( i_state , j_state , get_array_item ( i_out , this_state -> trans_out ) , the_hmm -> trans ) ; } } assert ( verify_trans_matrix ( false , the_hmm -> num_states , the_hmm -> trans ) ) ; }
Using information stored in the states of an HMM, fill in the HMM's
 transition matrix.
Using information stored in the states of an HMM fill in the HMM ' s transition matrix .
/* Indices into the matrix. */ /* Pointer to the current state. */ /* No. of trans out of the current state. */ /* Index of outgoing transition. */ /* First make sure the matrix is zeroed. */ /* Look at each state in the model. */ /* Find out how many transitions out of this state there are. */ /* Get the index of the state being transitioned to. */ /* Fill in the matrix with the appropriate value. */