#ifndef __FILE_GSMUSR_H_SEEN__
#define __FILE_GSMUSR_H_SEEN__
/* ----------------------------------------------------------------------------

Copyright (C) 2005, 2006.

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 "libgsm.h"

namespace gsm {

  class one_dim_tinker_toy_sci_mod;
  class one_dim_tinker_toy_stat_mod;

  typedef one_dim_tinker_toy_sci_mod  sci_mod_type;
  typedef one_dim_tinker_toy_stat_mod stat_mod_type;

  class one_dim_tinker_toy_sci_mod : public libgsm::sci_mod_base {
  private:
    scl::realmat theta;
    INTEGER len_sim;
  public:
    one_dim_tinker_toy_sci_mod()
      : theta(1,1,2.0), len_sim(50000) { }
    one_dim_tinker_toy_sci_mod
      (const scl::realmat* dat_ptr, const std::vector<std::string>& pfvec,
       const std::vector<std::string>& alvec, std::ostream& detail)
      : theta(1,1,2.0), len_sim(50000) { }
    INTEGER len_parm() { return 1; }
    INTEGER len_func() { return 3; }
    void    get_parm(scl::realmat& parm) { parm = theta; }
    void    set_parm(const scl::realmat& parm) { theta = parm; }
    void    set_sim_size(INTEGER N) { len_sim = N; }
    bool    support(const scl::realmat& parm) { return (parm[1] > 0); }
    scl::den_val prior(const scl::realmat& parm, 
      const scl::realmat& func);
    bool    gen_sim(scl::realmat& sim, scl::realmat& func);
  };
  
  class one_dim_tinker_toy_stat_mod : public libgsm::stat_mod_base {
  private:
    scl::realmat  eta;
    INTEGER  len_sim;
    const scl::realmat* data_ptr;
  public:
    one_dim_tinker_toy_stat_mod ()
      : eta(2,1), len_sim(50000) {eta[1]=2.0; eta[2]=4.0;}
    one_dim_tinker_toy_stat_mod
      (const scl::realmat* dat_ptr, const std::vector<std::string>& pfvec,
       const std::vector<std::string>& alvec, std::ostream& detail)
      : eta(2,1), len_sim(50000) {eta[1]=2.0; eta[2]=2.0;}
    INTEGER len_parm() { return 2; }
    INTEGER len_func() { return 3; }
    INTEGER num_obs() { return data_ptr->get_cols(); }
    void    get_parm(scl::realmat& parm) { parm = eta; }
    void    set_parm(const scl::realmat& parm) { eta = parm; }
    void    set_data_ptr(const scl::realmat* dat_ptr) {data_ptr = dat_ptr;}
    bool    support(const scl::realmat& parm) { return (parm[2] > 0); }
    scl::den_val prior(const scl::realmat& parm, 
      const scl::realmat& func);
    bool    gen_sim(scl::realmat& sim, scl::realmat& func);
    scl::den_val loglikelihood();
    scl::den_val loglikelihood(scl::realmat& dlogl);
    REAL    penalty(scl::realmat& dpenalty);
    INTEGER mle(scl::realmat& stat_parm_mle, scl::realmat& stat_parm_V);
  };
  
}
#endif
