#ifndef __FILE_MLEUSR_H_SEEN__
#define __FILE_MLEUSR_H_SEEN__

/*-----------------------------------------------------------------------------

Copyright (C) 2012, 2013

A. Ronald Gallant
Post Office Box 659
Chapel Hill NC 27514-0659
USA   

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

-----------------------------------------------------------------------------*/

#include "libmle.h"
#include "mle_base.h"
#include "svmnt.h"
#include "svmod.h"


namespace mle {
    
  class liml_usrmod;

  typedef liml_usrmod usrmod_type;

  const INT_32BIT fixed_seed = 100542;

  class liml_usrmod : public libmle::usrmod_base {
  private:
    scl::realmat data;
    INTEGER lrho;
    INTEGER lstats;
    INTEGER L;
    INTEGER Lhac;
    INTEGER N;
    INTEGER slen;
    INT_32BIT variable_seed;
    scl::realmat saved_particle;
    INTEGER emcount;
    INTEGER emlimit;
    INTEGER gibbs_count;
    std::vector<scl::realmat> gibbs_draws;
    scl::realmat rho;
    scl::realmat rho_old;
    svmnt* mf;
    scl::gmm* objf;
    svmod* m;
    std::vector<scl::realmat>* draws;
    std::vector<scl::realmat>* smooth;
    std::vector<scl::realmat>* filter;
  public:
    liml_usrmod (const scl::realmat& dat, INTEGER len_mod_parm, 
      INTEGER len_mod_func, const std::vector<std::string>& mod_pfvec,
      const std::vector<std::string>& mod_alvec, std::ostream& detail);
    INTEGER len_rho() {return lrho;}
    INTEGER len_stats() {return lstats;}
    bool get_stats(scl::realmat& stats);
    void get_rho(scl::realmat& parm) { parm = rho; }
    void set_rho(const scl::realmat& parm) { rho = parm; }
    void set_rho_old(const scl::realmat& parm) { rho_old = parm; }
    bool support(const scl::realmat& rho);
    scl::denval prior(const scl::realmat& rho, const scl::realmat& stats);
    scl::denval likelihood();
    void write_usrvar(const char* filename);
    ~liml_usrmod() { delete draws; delete smooth; delete filter;
      delete mf; delete objf; delete m;}
  };
  
}
#endif
