// file: $isip/class/pr/MaximumLikelihoodLinearRegression/mllr_05.cc
// version: $Id: mllr_05.cc 9459 2004-04-19 16:06:08Z gao $
//

// isip include files
//
#include "MaximumLikelihoodLinearRegression.h"

// method: initRegressionTree
//
// arguments:
//  Vector<StatisticalModel>& stat_models: (input) vector of statistical model
//  Vector <Boolean>& speech_tag: (input) speech tag
//
// return: a boolean value indicating status
//
// this method initilaize the regression tree root node using the
// statistical models and speech tag
//
boolean MaximumLikelihoodLinearRegression::initRegressionTree(Vector<StatisticalModel>& stat_models_a, Vector <Boolean>& speech_tag_a) {

  // keep a copy of the model in the local data field
  //
  //  stat_models_d.assign(stat_models_a);

  if (algorithm_d != REGRESSION_TREE && algorithm_d != ALL) {
    return Error::handle(name(), L"initRegressionTree", ERR_UNALG_UNIMP,
			 __FILE__, __LINE__);
  }
  // init the regression tree using the model
  //
  rdt_d.initRegressionTree(stat_models_a, speech_tag_a);

  // exit gracefully
  // 
  return true;
}


// method: createTransform
//
// arguments:
//  Vector<StatisticalModel>& stat_models: (input) vector of statistical model
//
// return: a boolean value indicating status
//
// this method initilaize the regression tree root node
//
boolean MaximumLikelihoodLinearRegression::createTransform(Vector<StatisticalModel>& stat_models_a) {

  if (algorithm_d != TRANSFORM && algorithm_d != ALL) {
     return Error::handle(name(), L"createTransform", ERR_UNALG_UNIMP,
			  __FILE__, __LINE__);
  }
  
  rdt_d.createTransform(stat_models_a);
  
  // exit gracefully
  //
  return true;
}

// method: adapt
//
// arguments:
//  Vector<StatisticalModel>& stat_models: (input) vector of statistical model
//
// return: a boolean value indicating status
//
// this method adapts the models by using the pre-calculated
// transformation matrix
//
boolean MaximumLikelihoodLinearRegression::adapt(Vector<StatisticalModel>& stat_models_a) {

  if (algorithm_d != ADAPT && algorithm_d != ALL) {
     return Error::handle(name(), L"adapt", ERR_UNALG_UNIMP,
			  __FILE__, __LINE__);
  }  
  
  sm_adapt_d.adapt(rdt_d,  stat_models_a);

  // exit gracefully
  //
  return true;
}




