//
// 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 "cla.hpp"
#include "libmatlbm.hpp"
#include "libmmfile.hpp"

static mxChar _array1_[124] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
                                'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
                                'l', 'e', ':', ' ', 'c', 'l', 'a', ' ', 'L',
                                'i', 'n', 'e', ':', ' ', '1', ' ', 'C', 'o',
                                'l', 'u', 'm', 'n', ':', ' ', '1', ' ', 'T',
                                'h', 'e', ' ', 'f', 'u', 'n', 'c', 't', 'i',
                                'o', 'n', ' ', '"', 'c', 'l', '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', ' ', '(', '1', ')', '.' };
static mwArray _mxarray0_ = mclInitializeString(124, _array1_);
static mwArray _mxarray2_ = mclInitializeDouble(1.0);

static mxChar _array4_[4] = { 'T', 'y', 'p', 'e' };
static mwArray _mxarray3_ = mclInitializeString(4, _array4_);

static mxChar _array6_[4] = { 'a', 'x', 'e', 's' };
static mwArray _mxarray5_ = mclInitializeString(4, _array6_);
static mwArray _mxarray7_ = mclInitializeDouble(2.0);

void InitializeModule_cla() {
}

void TerminateModule_cla() {
}

static mwArray Mcla(int nargout_, mwArray varargin);

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

//
// The function "Ncla" contains the nargout interface for the "cla" M-function
// from file "C:\MATLAB6p1\toolbox\matlab\graphics\cla.m" (lines 1-34). This
// interface is only produced if the M-function uses the special variable
// "nargout". The nargout interface allows the number of requested outputs to
// be specified via the nargout argument, as opposed to the normal interface
// which dynamically calculates the number of outputs based on the number of
// non-NULL inputs it receives. This function processes any input arguments and
// passes them to the implementation version of the function, appearing above.
//
mwArray Ncla(int nargout, mwVarargin varargin) {
    mwArray ret_ax(mclGetUninitializedArray());
    ret_ax = Mcla(nargout, varargin.ToArray());
    return ret_ax;
}

//
// The function "cla" contains the normal interface for the "cla" M-function
// from file "C:\MATLAB6p1\toolbox\matlab\graphics\cla.m" (lines 1-34). This
// function processes any input arguments and passes them to the implementation
// version of the function, appearing above.
//
mwArray cla(mwVarargin varargin) {
    int nargout(1);
    mwArray ret_ax(mclGetUninitializedArray());
    ret_ax = Mcla(nargout, varargin.ToArray());
    return ret_ax;
}

//
// The function "Vcla" contains the void interface for the "cla" M-function
// from file "C:\MATLAB6p1\toolbox\matlab\graphics\cla.m" (lines 1-34). The
// void interface is only produced if the M-function uses the special variable
// "nargout", and has at least one output. The void interface function
// specifies zero output arguments to the implementation version of the
// function, and in the event that the implementation version still returns an
// output (which, in MATLAB, would be assigned to the "ans" variable), it
// deallocates the output. This function processes any input arguments and
// passes them to the implementation version of the function, appearing above.
//
void Vcla(mwVarargin varargin) {
    mwArray ret_ax(mwArray::UNDEFINED);
    ret_ax = Mcla(0, varargin.ToArray());
}

//
// The function "mlxCla" contains the feval interface for the "cla" M-function
// from file "C:\MATLAB6p1\toolbox\matlab\graphics\cla.m" (lines 1-34). The
// feval function calls the implementation version of cla through this
// function. This function processes any input arguments and passes them to the
// implementation version of the function, appearing above.
//
void mlxCla(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    MW_BEGIN_MLX();
    {
        mwArray mprhs[1];
        mwArray mplhs[1];
        mclCppUninitializeArrays(1, mplhs);
        if (nlhs > 1) {
            error(_mxarray0_);
        }
        mprhs[0] = mclCreateVararginCell(nrhs, prhs);
        mplhs[0] = Mcla(nlhs, mprhs[0]);
        plhs[0] = mplhs[0].FreezeData();
    }
    MW_END_MLX();
}

//
// The function "Mcla" is the implementation version of the "cla" M-function
// from file "C:\MATLAB6p1\toolbox\matlab\graphics\cla.m" (lines 1-34). 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 ret_ax = cla(varargin)
//
static mwArray Mcla(int nargout_, mwArray varargin) {
    mwLocalFunctionTable save_local_function_table_(&_local_function_table_cla);
    int nargin_(nargin(-1, mwVarargin(varargin)));
    mwArray ret_ax(mclGetUninitializedArray());
    mwArray ans(mclGetUninitializedArray());
    mwArray extra(mclGetUninitializedArray());
    mwArray ax(mclGetUninitializedArray());
    //
    // %CLA Clear current axis.
    // %   CLA deletes all children of the current axes with visible handles.
    // %
    // %   CLA RESET deletes all objects (including ones with hidden handles)
    // %   and also resets all axes properties, except Position and Units, to
    // %   their default values.
    // %
    // %   See also CLF, RESET, HOLD.
    // 
    // %   CLA(..., HSAVE) deletes all children except those specified in
    // %   HSAVE.
    // %
    // %   CLA(AX) or CLA(AX,'RESET') clears the axes with handle AX.
    // 
    // %   Copyright 1984-2001 The MathWorks, Inc. 
    // %   $Revision: 5.16 $  $Date: 2001/04/15 11:59:49 $
    // 
    // if nargin>0 & length(varargin{1})==1 & ishandle(varargin{1}) & strcmp(get(varargin{1},'Type'),'axes')
    //
    mwArray a_(nargin_ > 0);
    if (tobool(a_)) {
        a_
          = a_
            & mwVe(
                feval(
                  mwValueVarargout(),
                  mlxLength,
                  mwVarargin(
                    mwVe(mwVsa(varargin, "varargin").cell(_mxarray2_)))))
              == _mxarray2_;
    } else {
        a_ = 0;
    }
    if (tobool(a_)) {
        a_
          = a_
            & mwVe(
                feval(
                  mwValueVarargout(),
                  mlxIshandle,
                  mwVarargin(
                    mwVe(mwVsa(varargin, "varargin").cell(_mxarray2_)))));
    } else {
        a_ = 0;
    }
    if (tobool(a_)
        && tobool(
             a_
             & mwVe(
                 strcmp(
                   mwVe(
                     Nget(
                       1,
                       mwVarargin(
                         mwVe(mwVsa(varargin, "varargin").cell(_mxarray2_)),
                         _mxarray3_))),
                   _mxarray5_)))) {
        //
        // % If first argument is a single axes handle, apply CLA to these axes
        // ax = varargin{1};
        //
        ax = mwVsa(varargin, "varargin").cell(_mxarray2_);
        //
        // extra = varargin(2:end);
        //
        extra
          = mclArrayRef(
              mwVsa(varargin, "varargin"),
              colon(
                _mxarray7_,
                end(mwVa(varargin, "varargin"), _mxarray2_, _mxarray2_)));
    //
    // else
    //
    } else {
        //
        // % Default target is current axes
        // ax = gca;
        //
        ax = gca(mwArray::DIN);
        //
        // extra = varargin;
        //
        extra = mwVsa(varargin, "varargin");
    }
    //
    // end
    // 
    // clo(ax, extra{:});
    //
    ans.EqAns(
      feval(
        mwAnsVarargout(),
        mlxGraphics_private_clo,
        mwVarargin(mwVv(ax, "ax"), mwVe(mwVsv(extra, "extra").cell(colon())))));
    //
    // 
    // if (nargout ~= 0)
    //
    if (nargout_ != 0) {
        //
        // ret_ax = ax;
        //
        ret_ax = mwVsv(ax, "ax");
    //
    // end
    //
    }
    mwValidateOutput(ret_ax, 1, nargout_, "ret_ax", "cla");
    return ret_ax;
}
