// file: bw_trans_2.cc
//

// isip include files
//
#include "bw_train.h"
#include "bw_train_constants.h"

// method: update_trans_cc
//
// arguments:
//  float_8***& new_trans : (output/input) the transitions matrixes
//  float_8*** den_prob : (input) the denominator of transitions
//  int_4 num_trans : (input) the number of transition matrixes
//  int_4* trans_size : (input) the size array
//
// return a logical flag to indicate success
//
// this method updates the transition matrices
//
logical_1 update_trans_cc(float_8***& new_trans_a, float_8*** den_prob_a,
			  int_4 num_trans_a, int_4* trans_size_a) {

  // local variables
  //
  int_4 num_st = (int_4)0;
  
  // update the transitions using numerator and denominator
  //
  for (int_4 i = 0; i < num_trans_a; i++) {
    num_st = trans_size_a[i];
    
    // loop over the states
    //
    for (int_4 j = 0; j < num_st; j++) {
      for (int_4 k = 0; k < num_st; k++) {
	
	if (new_trans_a[i][j][k] != BW_LOG_ZERO) {
	  new_trans_a[i][j][k] -= den_prob_a[i][j][k];
	}
      }
    }
  }
  
  // exit gracefully
  //
  return(ISIP_TRUE);
}


