//
// MATLAB Compiler: 2.2
// Date: Wed Mar 10 16:44:48 2004
// Arguments: "-B" "macro_default" "-O" "all" "-O" "fold_scalar_mxarrays:on"
// "-O" "fold_non_scalar_mxarrays:on" "-O" "optimize_integer_for_loops:on" "-O"
// "array_indexing:on" "-O" "optimize_conditionals:on" "-p" "-W" "main" "-L"
// "Cpp" "-t" "-T" "link:exe" "-h" "libmmfile.mlib" "-B" "sglcpp" "-p" "-W"
// "main" "-L" "Cpp" "-t" "-T" "link:exe" "-h" "libmmfile.mlib" "-W" "mainhg"
// "libmwsglm.mlib" "hier_community.m" "Default.m" "Stop_Simulation.m"
// "Call_SaveLoad_Fig.m" "SaveLoad_Fig.m" "SaveLoad.m" "Load_Population_Data.m"
// "Save_Population_Data.m" "Start_hier_community.m" "MyInline.m" "My_Eval.m"
// "isnumber.m" "Find_Var.m" "Change_Number_of_Populations.m"
// "Switch_Populations.m" "Store_Parameters.m" 
//
#include "Load_Population_Data.hpp"
#include "Change_Number_of_Populations.hpp"
#include "Switch_Populations.hpp"
#include "libmatlbm.hpp"
#include "libmmfile.hpp"

static mxChar _array1_[158] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
                                'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
                                'l', 'e', ':', ' ', 'L', 'o', 'a', 'd', '_',
                                'P', 'o', 'p', 'u', 'l', 'a', 't', 'i', 'o',
                                'n', '_', 'D', 'a', 't', 'a', ' ', 'L', 'i',
                                'n', 'e', ':', ' ', '1', ' ', 'C', 'o', 'l',
                                'u', 'm', 'n', ':', ' ', '1', ' ', 'T', 'h',
                                'e', ' ', 'f', 'u', 'n', 'c', 't', 'i', 'o',
                                'n', ' ', '"', 'L', 'o', 'a', 'd', '_', 'P',
                                'o', 'p', 'u', 'l', 'a', 't', 'i', 'o', 'n',
                                '_', 'D', 'a', 't', 'a', '"', ' ', 'w', 'a',
                                's', ' ', 'c', 'a', 'l', 'l', 'e', 'd', ' ',
                                'w', 'i', 't', 'h', ' ', 'm', 'o', 'r', 'e',
                                ' ', 't', 'h', 'a', 'n', ' ', 't', 'h', 'e',
                                ' ', 'd', 'e', 'c', 'l', 'a', 'r', 'e', 'd',
                                ' ', 'n', 'u', 'm', 'b', 'e', 'r', ' ', 'o',
                                'f', ' ', 'o', 'u', 't', 'p', 'u', 't', 's',
                                ' ', '(', '0', ')', '.' };
static mwArray _mxarray0_ = mclInitializeString(158, _array1_);

static mxChar _array3_[157] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
                                'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
                                'l', 'e', ':', ' ', 'L', 'o', 'a', 'd', '_',
                                'P', 'o', 'p', 'u', 'l', 'a', 't', 'i', 'o',
                                'n', '_', 'D', 'a', 't', 'a', ' ', 'L', 'i',
                                'n', 'e', ':', ' ', '1', ' ', 'C', 'o', 'l',
                                'u', 'm', 'n', ':', ' ', '1', ' ', 'T', 'h',
                                'e', ' ', 'f', 'u', 'n', 'c', 't', 'i', 'o',
                                'n', ' ', '"', 'L', 'o', 'a', 'd', '_', 'P',
                                'o', 'p', 'u', 'l', 'a', 't', 'i', 'o', 'n',
                                '_', 'D', 'a', 't', 'a', '"', ' ', 'w', 'a',
                                's', ' ', 'c', 'a', 'l', 'l', 'e', 'd', ' ',
                                'w', 'i', 't', 'h', ' ', 'm', 'o', 'r', 'e',
                                ' ', 't', 'h', 'a', 'n', ' ', 't', 'h', 'e',
                                ' ', 'd', 'e', 'c', 'l', 'a', 'r', 'e', 'd',
                                ' ', 'n', 'u', 'm', 'b', 'e', 'r', ' ', 'o',
                                'f', ' ', 'i', 'n', 'p', 'u', 't', 's', ' ',
                                '(', '1', ')', '.' };
static mwArray _mxarray2_ = mclInitializeString(157, _array3_);

static mxChar _array5_[3] = { 'T', 'a', 'g' };
static mwArray _mxarray4_ = mclInitializeString(3, _array5_);

static mxChar _array7_[23] = { 'F', 'i', 'g', '_', 'm', 'u', 'l', 't',
                               'i', 'p', 'l', 'e', '_', 'p', 'o', 'p',
                               'u', 'l', 'a', 't', 'i', 'o', 'n' };
static mwArray _mxarray6_ = mclInitializeString(23, _array7_);

static mxChar _array9_[21] = { 'P', 'o', 'p', 'u', 'p', 'M', 'e',
                               'n', 'u', '_', 'p', 'o', 'p', 'u',
                               'l', 'a', 't', 'i', 'o', 'n', 's' };
static mwArray _mxarray8_ = mclInitializeString(21, _array9_);

static mxChar _array11_[21] = { 'E', 'd', 'i', 't', 'T', 'e', 'x',
                                't', '_', 'm', 'a', 'x', 'i', 'm',
                                'u', 'm', '_', 't', 'i', 'm', 'e' };
static mwArray _mxarray10_ = mclInitializeString(21, _array11_);

static mxChar _array13_[29] = { 'E', 'd', 'i', 't', 'T', 'e', 'x', 't',
                                '_', 'n', 'u', 'm', 'b', 'e', 'r', '_',
                                'o', 'f', '_', 't', 'i', 'm', 'e', '_',
                                's', 't', 'e', 'p', 's' };
static mwArray _mxarray12_ = mclInitializeString(29, _array13_);

static mxChar _array15_[18] = { 'E', 'd', 'i', 't', 'T', 'e', 'x', 't', '_',
                                'm', 'a', 'x', 'i', 'm', 'u', 'm', '_', 'x' };
static mwArray _mxarray14_ = mclInitializeString(18, _array15_);

static mxChar _array17_[30] = { 'E', 'd', 'i', 't', 'T', 'e', 'x', 't',
                                '_', 'n', 'u', 'm', 'b', 'e', 'r', '_',
                                'o', 'f', '_', 'x', '_', 'i', 'n', 't',
                                'e', 'r', 'v', 'a', 'l', 's' };
static mwArray _mxarray16_ = mclInitializeString(30, _array17_);

static mxChar _array19_[30] = { 'E', 'd', 'i', 't', 'T', 'e', 'x', 't',
                                '_', 'n', 'u', 'm', 'b', 'e', 'r', '_',
                                'o', 'f', '_', 'p', 'o', 'p', 'u', 'l',
                                'a', 't', 'i', 'o', 'n', 's' };
static mwArray _mxarray18_ = mclInitializeString(30, _array19_);

static mxChar _array21_[16] = { 'R', 'a', 'd', 'i', 'o', 'b', 'u', 't',
                                't', 'o', 'n', '_', 'c', 'o', 'n', 't' };
static mwArray _mxarray20_ = mclInitializeString(16, _array21_);

static mxChar _array23_[8] = { 'U', 's', 'e', 'r', 'D', 'a', 't', 'a' };
static mwArray _mxarray22_ = mclInitializeString(8, _array23_);

static mxChar _array25_[6] = { 'S', 't', 'r', 'i', 'n', 'g' };
static mwArray _mxarray24_ = mclInitializeString(6, _array25_);

static mxChar _array27_[5] = { 'V', 'a', 'l', 'u', 'e' };
static mwArray _mxarray26_ = mclInitializeString(5, _array27_);
static mwArray _mxarray28_ = mclInitializeDouble(3.0);

void InitializeModule_Load_Population_Data() {
}

void TerminateModule_Load_Population_Data() {
}

static void MLoad_Population_Data(mwArray file);

_mexLocalFunctionTable _local_function_table_Load_Population_Data
  = { 0, (mexFunctionTableEntry *)NULL };

//
// The function "Load_Population_Data" contains the normal interface for the
// "Load_Population_Data" M-function from file
// "C:\shu\hier_community_exe\Load_Population_Data.m" (lines 1-35). This
// function processes any input arguments and passes them to the implementation
// version of the function, appearing above.
//
void Load_Population_Data(mwArray file) {
    MLoad_Population_Data(file);
}

//
// The function "mlxLoad_Population_Data" contains the feval interface for the
// "Load_Population_Data" M-function from file
// "C:\shu\hier_community_exe\Load_Population_Data.m" (lines 1-35). The feval
// function calls the implementation version of Load_Population_Data through
// this function. This function processes any input arguments and passes them
// to the implementation version of the function, appearing above.
//
void mlxLoad_Population_Data(int nlhs,
                             mxArray * plhs[],
                             int nrhs,
                             mxArray * prhs[]) {
    MW_BEGIN_MLX();
    {
        mwArray mprhs[1];
        int i;
        if (nlhs > 0) {
            error(_mxarray0_);
        }
        if (nrhs > 1) {
            error(_mxarray2_);
        }
        for (i = 0; i < 1 && i < nrhs; ++i) {
            mprhs[i] = mwArray(prhs[i], 0);
        }
        for (; i < 1; ++i) {
            mprhs[i].MakeDIN();
        }
        MLoad_Population_Data(mprhs[0]);
    }
    MW_END_MLX();
}

//
// The function "MLoad_Population_Data" is the implementation version of the
// "Load_Population_Data" M-function from file
// "C:\shu\hier_community_exe\Load_Population_Data.m" (lines 1-35). It contains
// the actual compiled code for that M-function. It is a static function and
// must only be called from one of the interface functions, appearing below.
//
//
// function Load_Population_Data(file)
//
static void MLoad_Population_Data(mwArray file) {
    mwLocalFunctionTable save_local_function_table_
      (&_local_function_table_Load_Population_Data);
    mwArray num_pop(mclGetUninitializedArray());
    mwArray CONT(mwArray::UNDEFINED);
    mwArray xintv(mwArray::UNDEFINED);
    mwArray xmax(mwArray::UNDEFINED);
    mwArray tsteps(mwArray::UNDEFINED);
    mwArray tmax(mwArray::UNDEFINED);
    mwArray param(mwArray::UNDEFINED);
    mwArray ans(mclGetUninitializedArray());
    mwArray cont_handle(mclGetUninitializedArray());
    mwArray number_of_populations_handle(mclGetUninitializedArray());
    mwArray number_of_x_intervals_handle(mclGetUninitializedArray());
    mwArray maximum_x_handle(mclGetUninitializedArray());
    mwArray number_of_time_steps_handle(mclGetUninitializedArray());
    mwArray maximum_time_handle(mclGetUninitializedArray());
    mwArray populations_handle(mclGetUninitializedArray());
    mwArray multiple_population_handle(mclGetUninitializedArray());
    //
    // 
    // multiple_population_handle = findobj('Tag','Fig_multiple_population');
    //
    multiple_population_handle = findobj(mwVarargin(_mxarray4_, _mxarray6_));
    //
    // 
    // populations_handle = findobj(multiple_population_handle,'Tag','PopupMenu_populations');
    //
    populations_handle
      = findobj(
          mwVarargin(
            mwVv(multiple_population_handle, "multiple_population_handle"),
            _mxarray4_,
            _mxarray8_));
    //
    // maximum_time_handle = findobj(multiple_population_handle,'Tag','EditText_maximum_time');
    //
    maximum_time_handle
      = findobj(
          mwVarargin(
            mwVv(multiple_population_handle, "multiple_population_handle"),
            _mxarray4_,
            _mxarray10_));
    //
    // number_of_time_steps_handle = findobj(multiple_population_handle,'Tag','EditText_number_of_time_steps');
    //
    number_of_time_steps_handle
      = findobj(
          mwVarargin(
            mwVv(multiple_population_handle, "multiple_population_handle"),
            _mxarray4_,
            _mxarray12_));
    //
    // maximum_x_handle = findobj(multiple_population_handle,'Tag','EditText_maximum_x');
    //
    maximum_x_handle
      = findobj(
          mwVarargin(
            mwVv(multiple_population_handle, "multiple_population_handle"),
            _mxarray4_,
            _mxarray14_));
    //
    // number_of_x_intervals_handle = findobj(multiple_population_handle,'Tag','EditText_number_of_x_intervals');
    //
    number_of_x_intervals_handle
      = findobj(
          mwVarargin(
            mwVv(multiple_population_handle, "multiple_population_handle"),
            _mxarray4_,
            _mxarray16_));
    //
    // number_of_populations_handle = findobj(multiple_population_handle,'Tag','EditText_number_of_populations');
    //
    number_of_populations_handle
      = findobj(
          mwVarargin(
            mwVv(multiple_population_handle, "multiple_population_handle"),
            _mxarray4_,
            _mxarray18_));
    //
    // cont_handle = findobj(multiple_population_handle,'Tag','Radiobutton_cont');
    //
    cont_handle
      = findobj(
          mwVarargin(
            mwVv(multiple_population_handle, "multiple_population_handle"),
            _mxarray4_,
            _mxarray20_));
    //
    // 
    // load(file);
    //
    {
        mwArray name_(mwVa(file, "file"));
        loadc_(
          name_,
          "CONT",
          &CONT,
          "ans",
          &ans,
          "cont_handle",
          &cont_handle,
          "file",
          &file,
          "maximum_time_handle",
          &maximum_time_handle,
          "maximum_x_handle",
          &maximum_x_handle,
          "multiple_population_handle",
          &multiple_population_handle,
          "num_pop",
          &num_pop,
          "number_of_populations_handle",
          &number_of_populations_handle,
          "number_of_time_steps_handle",
          &number_of_time_steps_handle,
          "number_of_x_intervals_handle",
          &number_of_x_intervals_handle,
          "param",
          &param,
          "populations_handle",
          &populations_handle,
          "tmax",
          &tmax,
          "tsteps",
          &tsteps,
          NULL);
        loadc_(name_, "xintv", &xintv, "xmax", &xmax, NULL);
    }
    //
    // 
    // set(multiple_population_handle,'UserData',param);
    //
    ans.EqAns(
      Nset(
        0,
        mwVarargin(
          mwVv(multiple_population_handle, "multiple_population_handle"),
          _mxarray22_,
          mwVv(param, "param"))));
    //
    // set(maximum_time_handle,'String',tmax);
    //
    ans.EqAns(
      Nset(
        0,
        mwVarargin(
          mwVv(maximum_time_handle, "maximum_time_handle"),
          _mxarray24_,
          mwVv(tmax, "tmax"))));
    //
    // set(number_of_time_steps_handle,'String',tsteps);
    //
    ans.EqAns(
      Nset(
        0,
        mwVarargin(
          mwVv(number_of_time_steps_handle, "number_of_time_steps_handle"),
          _mxarray24_,
          mwVv(tsteps, "tsteps"))));
    //
    // set(maximum_x_handle,'String',xmax);
    //
    ans.EqAns(
      Nset(
        0,
        mwVarargin(
          mwVv(maximum_x_handle, "maximum_x_handle"),
          _mxarray24_,
          mwVv(xmax, "xmax"))));
    //
    // set(number_of_x_intervals_handle,'String',xintv);
    //
    ans.EqAns(
      Nset(
        0,
        mwVarargin(
          mwVv(number_of_x_intervals_handle, "number_of_x_intervals_handle"),
          _mxarray24_,
          mwVv(xintv, "xintv"))));
    //
    // set(cont_handle,'Value',CONT);
    //
    ans.EqAns(
      Nset(
        0,
        mwVarargin(
          mwVv(cont_handle, "cont_handle"), _mxarray26_, mwVv(CONT, "CONT"))));
    //
    // 
    // num_pop = length(param{3});
    //
    num_pop
      = feval(
          mwValueVarargout(),
          mlxLength,
          mwVarargin(mwVe(mwVsv(param, "param").cell(_mxarray28_))));
    //
    // set(number_of_populations_handle,'String',num2str(num_pop));
    //
    ans.EqAns(
      Nset(
        0,
        mwVarargin(
          mwVv(number_of_populations_handle, "number_of_populations_handle"),
          _mxarray24_,
          mwVe(num2str(mwVv(num_pop, "num_pop"))))));
    //
    // set(multiple_population_handle,'UserData',param);
    //
    ans.EqAns(
      Nset(
        0,
        mwVarargin(
          mwVv(multiple_population_handle, "multiple_population_handle"),
          _mxarray22_,
          mwVv(param, "param"))));
    //
    // 
    // Change_Number_of_Populations;
    //
    Change_Number_of_Populations();
    //
    // 
    // Switch_Populations;
    //
    Switch_Populations();
    //
    // 
    // 
    // 
    // 
    // 
    // 
    //
}
