

#if !defined(ALIZE_Distrib_cpp)
#define ALIZE_Distrib_cpp

#include "Distrib.h"
#include "DistribGD.h"
#include "DistribGF.h"
#include "Exception.h"

using namespace alize;
typedef Distrib D;

//-------------------------------------------------------------------------
D::Distrib(unsigned long vectSize)
:Object(), _vectSize(vectSize), _det(0.0), _cst(0.0),
 _meanVect(vectSize, vectSize), _refCounter(0), _dictIndex(0) {}
//-------------------------------------------------------------------------
bool D::operator!=(const Distrib& d) const { return !(*this == d); }
//-------------------------------------------------------------------------
Distrib& D::duplicate(const K&) const { return clone(); }
//-------------------------------------------------------------------------
unsigned long D::getVectSize() const { return _vectSize; }
//-------------------------------------------------------------------------
real_t D::getMean(unsigned long i) const { return _meanVect[i]; }
//-------------------------------------------------------------------------
DoubleVector& D::getMeanVect() { return _meanVect; }
//-------------------------------------------------------------------------
const DoubleVector& D::getMeanVect() const { return _meanVect; }
//-------------------------------------------------------------------------
void D::setMean(const real_t v, const unsigned long i){ _meanVect[i] = v; }
//-------------------------------------------------------------------------
void D::setMeanVect(const DoubleVector& v) { _meanVect.setValues(v); }
//-------------------------------------------------------------------------
real_t D::getDet() const { return _det; }
//-------------------------------------------------------------------------
real_t D::getCst() const { return _cst; }
//-------------------------------------------------------------------------
void D::setDet(const K&, real_t v) { _det = v; }
//-------------------------------------------------------------------------
void D::setCst(const K&, real_t v) { _cst = v; }
//-------------------------------------------------------------------------
unsigned long& D::refCounter(const K&) { return _refCounter; }
//-------------------------------------------------------------------------
unsigned long& D::dictIndex(const K&) { return _dictIndex; }
//-------------------------------------------------------------------------
D::~Distrib() {}
//-------------------------------------------------------------------------
Distrib& D::create(const K&, const DistribType type,
                         unsigned long vectSize)
{
  if (type == DistribType_GD)
    return DistribGD::create(K::k, vectSize);
  if (type == DistribType_GF)
    return DistribGF::create(K::k, vectSize);
  throw Exception("Don't know how to create a distribution"
                  + getDistribTypeName(type) + "'", __FILE__, __LINE__);
  return DistribGD::create(K::k, vectSize); // never called
}
//-------------------------------------------------------------------------

#endif // !defined(ALIZE_Distrib_cpp)

