// file: $isip_ifc/class/algo/MutualInformation/mi_00.cc
// version: $Id: mi_00.cc 10436 2006-02-23 20:12:47Z pannuri $
//

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

//------------------------------------------------------------------------
//
// required public methods
//
//-----------------------------------------------------------------------

// method: assign
//
// arguments:
//  const MutualInformation& arg: (input) object to assign
//
// return: a boolean value indicating status
//
// this method assigns the input object to current object
//
boolean MutualInformation::assign(const MutualInformation& arg_a) {

  // assign all protected data
  //
  algorithm_d = arg_a.algorithm_d;
  implementation_d = arg_a.implementation_d;
  normalization_d = arg_a.normalization_d;
  order_d = arg_a.order_d;
  num_bins_d = arg_a.num_bins_d;

  // call the base assign method:
  //  note that the base class assign method sets the initialization flag
  //
  return AlgorithmBase::assign(arg_a);
}

// method: eq
//
// arguments:
//  const MutualInformation& arg: (input) input object to assign
//
// return: a boolean value indicating status
//
// this method checks whether the current object is identical to the
// input object
//
boolean MutualInformation::eq(const MutualInformation& arg_a) const {

  // compare all protected data
  //
  return ((algorithm_d == arg_a.algorithm_d) &&
	  (implementation_d == arg_a.implementation_d) &&
	  (normalization_d == arg_a.normalization_d) &&
	  (order_d == arg_a.order_d) &&
	  (num_bins_d == arg_a.num_bins_d));
}

// method: clear
//
// arguments:
//  Integral::CMODE ctype: (input) clear mode
//
// return: a boolean value indicating status
//
// this method resets the data members to the default values
//
boolean MutualInformation::clear(Integral::CMODE ctype_a) {

  // reset all protected data
  //
  if (ctype_a != Integral::RETAIN) {
    algorithm_d = DEF_ALGORITHM;
    implementation_d = DEF_IMPLEMENTATION;
    normalization_d = DEF_NORMALIZATION;
    order_d = DEF_ORDER;
    num_bins_d = DEF_NUM_BINS;    
  }
  
  // call the base clear method
  //
  return AlgorithmBase::clear(ctype_a);
}

//---------------------------------------------------------------------------
//
// class-specific public methods:
//  public methods required by the AlgorithmBase interface contract
//
//---------------------------------------------------------------------------

// method: assign
//
// arguments:
//  const AlgorithmBase& arg: (input) object to be assigned
//
// return: a boolean value indicating status
//
// this method assigns the input algorithm object to the current
// MutualInformation object, if the input algorithm object is not an
// MutualInformation object, it returns an error
//
boolean MutualInformation::assign(const AlgorithmBase& arg_a) {

  // case: input is a MutualInformation object
  //
  if (typeid(arg_a) == typeid(MutualInformation)) {
    return assign((MutualInformation&)arg_a);
  }

  // case: other
  //  if the input algorithm object is not a MutualInformation object, return
  //  an error.
  //    
  else {
    return Error::handle(name(), L"assign", Error::ARG, __FILE__, __LINE__);
  }
}

// method: eq
//
// arguments:
//  const AlgorithmBase& arg: (input) object to be compared
//
// return: a boolean value indicating status
//
// this method checks whether the current MutualInformation object is identical
// to the input algorithm object, if the input algorithm object is not
// an MutualInformation object, it returns an error
//
boolean MutualInformation::eq(const AlgorithmBase& arg_a) const {
  
  // case: input is a MutualInformation object
  //
  if (typeid(arg_a) == typeid(MutualInformation)) {
    return eq((MutualInformation&)arg_a);
  }

  // case: other
  //  if the input algorithm object is not a MutualInformation object, return
  //  an error.
  //    
  else {
    return Error::handle(name(), L"eq", Error::ARG, __FILE__, __LINE__);
  }
}

//-----------------------------------------------------------------------------
//
// we define non-integral constants in the default constructor
//      
//-----------------------------------------------------------------------------

// constants: class name
//
const String MutualInformation::CLASS_NAME(L"MutualInformation");

// constants: i/o related constants
//
const String MutualInformation::DEF_PARAM(L"");
const String MutualInformation::PARAM_ALGORITHM(L"algorithm");
const String MutualInformation::PARAM_IMPLEMENTATION(L"implementation");
const String MutualInformation::PARAM_NORMALIZATION(L"normalization");
const String MutualInformation::PARAM_CMODE(L"compute_mode");
const String MutualInformation::PARAM_ORDER(L"order");
const String MutualInformation::PARAM_NUM_BINS(L"num_bins");

// constants: NameMap(s) for the enumerated values
//
const NameMap MutualInformation::ALGO_MAP(L"AUTO, CROSS");
const NameMap MutualInformation::IMPL_MAP(L"HISTOGRAM");
const NameMap MutualInformation::NORM_MAP(L"NONE");

// static instantiations: memory manager
//
MemoryManager MutualInformation::mgr_d(sizeof(MutualInformation), MutualInformation::name());


