Ejemplo n.º 1
0
/*
 * function r = rank(A,tol)
 */
static mxArray * Mrank(int nargout_, mxArray * A, mxArray * tol) {
    mexLocalFunctionTable save_local_function_table_
      = mclSetCurrentLocalFunctionTable(&_local_function_table_rank);
    int nargin_ = mclNargin(2, A, tol, NULL);
    mxArray * r = mclGetUninitializedArray();
    mxArray * s = mclGetUninitializedArray();
    mclCopyArray(&A);
    mclCopyArray(&tol);
    /*
     * %RANK   Matrix rank.
     * %   RANK(A) provides an estimate of the number of linearly
     * %   independent rows or columns of a matrix A.
     * %   RANK(A,tol) is the number of singular values of A
     * %   that are larger than tol.
     * %   RANK(A) uses the default tol = max(size(A)) * norm(A) * eps.
     * 
     * %   Copyright 1984-2001 The MathWorks, Inc. 
     * %   $Revision: 5.10 $  $Date: 2001/04/15 12:01:33 $
     * 
     * s = svd(A);
     */
    mlfAssign(&s, mlfSvd(NULL, NULL, mclVa(A, "A"), NULL));
    /*
     * if nargin==1
     */
    if (nargin_ == 1) {
        /*
         * tol = max(size(A)') * max(s) * eps;
         */
        mlfAssign(
          &tol,
          mclMtimes(
            mclMtimes(
              mclVe(
                mlfMax(
                  NULL,
                  mlfCtranspose(
                    mclVe(mlfSize(mclValueVarargout(), mclVa(A, "A"), NULL))),
                  NULL,
                  NULL)),
              mclVe(mlfMax(NULL, mclVv(s, "s"), NULL, NULL))),
            _mxarray4_));
    /*
     * end
     */
    }
    /*
     * r = sum(s > tol);
     */
    mlfAssign(&r, mlfSum(mclGt(mclVv(s, "s"), mclVa(tol, "tol")), NULL));
    mclValidateOutput(r, 1, nargout_, "r", "rank");
    mxDestroyArray(s);
    mxDestroyArray(tol);
    mxDestroyArray(A);
    mclSetCurrentLocalFunctionTable(save_local_function_table_);
    return r;
}
Ejemplo n.º 2
0
/*
 * The function "mlxPrecise_step" contains the feval interface for the
 * "precise_step" M-function from file "d:\M6\work\precise_step.m" (lines 0-0).
 * The feval function calls the implementation version of precise_step through
 * this function. This function processes any input arguments and passes them
 * to the implementation version of the function, appearing above.
 */
void mlxPrecise_step(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    mxArray * mprhs[1];
    mxArray * mplhs[1];
    int i;
    if (nlhs > 1) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: precise_step Line: 1 Column"
            ": 1 The function \"precise_step\" was called with"
            " more than the declared number of outputs (1)."));
    }
    if (nrhs > 1) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: precise_step Line: 1 Column"
            ": 1 The function \"precise_step\" was called with"
            " more than the declared number of inputs (1)."));
    }
    for (i = 0; i < 1; ++i) {
        mplhs[i] = mclGetUninitializedArray();
    }
    for (i = 0; i < 1 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 1; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(0, 1, mprhs[0]);
    mplhs[0] = Mprecise_step(nlhs, mprhs[0]);
    mlfRestorePreviousContext(0, 1, mprhs[0]);
    plhs[0] = mplhs[0];
}
Ejemplo n.º 3
0
/*
 * The function "mlxD_int" contains the feval interface for the "d_int"
 * M-function from file "d:\M6\work\d_int.m" (lines 0-0). The feval function
 * calls the implementation version of d_int through this function. This
 * function processes any input arguments and passes them to the implementation
 * version of the function, appearing above.
 */
void mlxD_int(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    mxArray * mprhs[2];
    mxArray * mplhs[1];
    int i;
    if (nlhs > 1) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: d_int Line: 1 Column: 1"
            " The function \"d_int\" was called with more "
            "than the declared number of outputs (1)."));
    }
    if (nrhs > 2) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: d_int Line: 1 Column: 1 The function \"d_int"
            "\" was called with more than the declared number of inputs (2)."));
    }
    for (i = 0; i < 1; ++i) {
        mplhs[i] = mclGetUninitializedArray();
    }
    for (i = 0; i < 2 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 2; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(0, 2, mprhs[0], mprhs[1]);
    mplhs[0] = Md_int(nlhs, mprhs[0], mprhs[1]);
    mlfRestorePreviousContext(0, 2, mprhs[0], mprhs[1]);
    plhs[0] = mplhs[0];
}
Ejemplo n.º 4
0
/*
 * function out = precise_step(inargs)
 */
static mxArray * Mprecise_step(int nargout_, mxArray * inargs) {
    mexLocalFunctionTable save_local_function_table_
      = mclSetCurrentLocalFunctionTable(&_local_function_table_precise_step);
    mxArray * out = mclGetUninitializedArray();
    mclCopyArray(&inargs);
    /*
     * % precise_step  defines precise level for my own bussniss. 
     * %
     * % out = precise_step
     * %   out always return .001 for current. 
     * 
     * if exist('FORCE_PRECISE_STEP') == 1
     */
    if (mclEqBool(mclVe(mlfExist(_mxarray4_, NULL)), _mxarray6_)) {
        /*
         * out = eval('FORCE_PRECISE_STEP'); 
         */
        mlfAssign(&out, mlfEval(mclValueVarargout(), _mxarray4_, NULL));
    /*
     * else
     */
    } else {
        /*
         * out = .0009; 
         */
        mlfAssign(&out, _mxarray7_);
    /*
     * end
     */
    }
    mclValidateOutput(out, 1, nargout_, "out", "precise_step");
    mxDestroyArray(inargs);
    mclSetCurrentLocalFunctionTable(save_local_function_table_);
    return out;
}
Ejemplo n.º 5
0
/*
 * The function "mlfRank" contains the normal interface for the "rank"
 * M-function from file
 * "/space/lyon/9/pubsw/common/matlab/6.1/toolbox/matlab/matfun/rank.m" (lines
 * 1-17). This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfRank(mxArray * A, mxArray * tol) {
    int nargout = 1;
    mxArray * r = mclGetUninitializedArray();
    mlfEnterNewContext(0, 2, A, tol);
    r = Mrank(nargout, A, tol);
    mlfRestorePreviousContext(0, 2, A, tol);
    return mlfReturnValue(r);
}
Ejemplo n.º 6
0
/*
 * The function "mlfPrecise_step" contains the normal interface for the
 * "precise_step" M-function from file "d:\M6\work\precise_step.m" (lines 0-0).
 * This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfPrecise_step(mxArray * inargs) {
    int nargout = 1;
    mxArray * out = mclGetUninitializedArray();
    mlfEnterNewContext(0, 1, inargs);
    out = Mprecise_step(nargout, inargs);
    mlfRestorePreviousContext(0, 1, inargs);
    return mlfReturnValue(out);
}
Ejemplo n.º 7
0
/*
 * The function "mlfD_int" contains the normal interface for the "d_int"
 * M-function from file "d:\M6\work\d_int.m" (lines 0-0). This function
 * processes any input arguments and passes them to the implementation version
 * of the function, appearing above.
 */
mxArray * mlfD_int(mxArray * f, mxArray * int_region) {
    int nargout = 1;
    mxArray * out = mclGetUninitializedArray();
    mlfEnterNewContext(0, 2, f, int_region);
    out = Md_int(nargout, f, int_region);
    mlfRestorePreviousContext(0, 2, f, int_region);
    return mlfReturnValue(out);
}
Ejemplo n.º 8
0
/*
 * The function "mlxRank" contains the feval interface for the "rank"
 * M-function from file
 * "/space/lyon/9/pubsw/common/matlab/6.1/toolbox/matlab/matfun/rank.m" (lines
 * 1-17). The feval function calls the implementation version of rank through
 * this function. This function processes any input arguments and passes them
 * to the implementation version of the function, appearing above.
 */
void mlxRank(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    mxArray * mprhs[2];
    mxArray * mplhs[1];
    int i;
    if (nlhs > 1) {
        mlfError(_mxarray0_);
    }
    if (nrhs > 2) {
        mlfError(_mxarray2_);
    }
    for (i = 0; i < 1; ++i) {
        mplhs[i] = mclGetUninitializedArray();
    }
    for (i = 0; i < 2 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 2; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(0, 2, mprhs[0], mprhs[1]);
    mplhs[0] = Mrank(nlhs, mprhs[0], mprhs[1]);
    mlfRestorePreviousContext(0, 2, mprhs[0], mprhs[1]);
    plhs[0] = mplhs[0];
}
Ejemplo n.º 9
0
/*
 * The function "mlxPrecise_step" contains the feval interface for the
 * "precise_step" M-function from file "d:\M6\work\precise_step.m" (lines
 * 1-12). The feval function calls the implementation version of precise_step
 * through this function. This function processes any input arguments and
 * passes them to the implementation version of the function, appearing above.
 */
void mlxPrecise_step(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    mxArray * mprhs[1];
    mxArray * mplhs[1];
    int i;
    if (nlhs > 1) {
        mlfError(_mxarray0_);
    }
    if (nrhs > 1) {
        mlfError(_mxarray2_);
    }
    for (i = 0; i < 1; ++i) {
        mplhs[i] = mclGetUninitializedArray();
    }
    for (i = 0; i < 1 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 1; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(0, 1, mprhs[0]);
    mplhs[0] = Mprecise_step(nlhs, mprhs[0]);
    mlfRestorePreviousContext(0, 1, mprhs[0]);
    plhs[0] = mplhs[0];
}
Ejemplo n.º 10
0
/*
 * The function "Md_int" is the MATLAB callback version of the "d_int" function
 * from file "d:\M6\work\d_int.m". It performs a callback to MATLAB to run the
 * "d_int" function, and passes any resulting output arguments back to its
 * calling function.
 */
static mxArray * Md_int(int nargout_, mxArray * f, mxArray * int_region) {
    mxArray * out = mclGetUninitializedArray();
    mclFevalCallMATLAB(
      mclNVarargout(nargout_, 0, &out, NULL), "d_int", f, int_region, NULL);
    return out;
}
Ejemplo n.º 11
0
/*
 * The function "Mprecise_step" is the MATLAB callback version of the
 * "precise_step" function from file "d:\M6\work\precise_step.m". It performs a
 * callback to MATLAB to run the "precise_step" function, and passes any
 * resulting output arguments back to its calling function.
 */
static mxArray * Mprecise_step(int nargout_, mxArray * inargs) {
    mxArray * out = mclGetUninitializedArray();
    mclFevalCallMATLAB(
      mclNVarargout(nargout_, 0, &out, NULL), "precise_step", inargs, NULL);
    return out;
}