// file: ih_print_1.cc
//

// isip include files
//
#include "init_hmm.h"
#include "init_hmm_constants.h"

// method: print_trans_cc
//
// arguments:
// FILE* fout : (output) the output transition file
// float_4*** trans : (input) the transition matrix (including sp)
// int_4 num_trans : (input) the number of transiton matrix
// int_4* num_st : (input) the number of states in each model
//
// return: a logical_1 flag indicating success
//
// this method dumps the transition matrix into the transition file
//
logical_1 print_trans_cc(FILE* fout_a, float_4*** trans_a, int_4 num_trans_a,
			 int_4* num_st_a) {

  // define local variables
  //
  int_4 num_dummy = 0;

  // count the number of dummy models
  //
  for (int_4 i = 1; i < num_trans_a; i++) {
    if (num_st_a[i] == 2) {
      num_dummy += 1;
    }
  }
  
  // output the number of transition
  //
  fprintf(fout_a, "\nnum_transitions = %ld\n\n", num_trans_a-num_dummy);
  
  // output the first matrix (for !s and s! and sp)
  //
  fprintf(fout_a, "0. 2\n");
  for (int_4 i = 0; i < 2; i++) {
    fprintf(fout_a, " 0.0 0.0\n");
  }
  fprintf(fout_a, "\n");
  num_dummy = 0;
  
  // output all the rest matrices 
  //
  for (int_4 i = 1; i < num_trans_a; i++) {
    if (num_st_a[i] != 2) {
      fprintf(fout_a, "%ld. %ld\n", i-num_dummy, num_st_a[i]);
      for (int_4 j = 0; j < num_st_a[i]; j++) {
	for (int_4 k = 0; k < num_st_a[i]; k++) {
	  fprintf(fout_a, " %e", trans_a[i][j][k]);
	}
	fprintf(fout_a, "\n");
      }
      fprintf(fout_a, "\n");
    }
    else {
      num_dummy++;
    }
  }

  // exit gracefully
  //
  return ISIP_TRUE;
}



 
