// file: cm_read_0.cc
//
// isip include files
//
#include "create_mixtures.h"
#include "create_mixtures_constants.h"
 
// method: read_states_cc
//
// arguments:
//  int_4& num_st : (output) number of states
//  int_4& num_feat : (output) number of features in data vector
//  FILE* fp : (input) input file pointer
//  
// return: a State** pointing to a list of States
//
// this method reads the State models from file --- each mixture
// component in the states is assumed to have a diagonal covariance
// matrix
//
Train_State** read_states_cc(int_4& num_st_a, int_4& num_feat_a,
		       FILE* fp_a) {
  
  // read the number of features and number of states
  //
  fread((void_p)&num_feat_a, sizeof(int_4), 1, fp_a);
  fread((void_p)&num_st_a, sizeof(int_4), 1, fp_a);
  
  // initialize the states
  //
  Train_State::set_num_features_cc(num_feat_a);
  Train_State** states = (Train_State**)NULL;
  states = new Train_State*[num_st_a];
  
  // read state data from file
  //
  for (int_4 i = 0; i < num_st_a; i++) {

    // create state memory
    //
    states[i] = new Train_State();

    // read the parameters for this state
    //
    states[i]->read_data_cc(fp_a);
  }

  // exit gracefully
  //
  return states;
}
