示例#1
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;
}
示例#2
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;
}