?? mrank.c
字號:
/*
* MATLAB Compiler: 2.2
* Date: Tue Jun 25 15:00:23 2002
* 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" "-t" "-W" "lib:Templib"
* "-T" "link:exe" "-h" "fileinc.c" "mrank"
*/
#include "mrank.h"
#include "libmatlbm.h"
#include "magic.h"
#include "rank.h"
static mxChar _array1_[128] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
'l', 'e', ':', ' ', 'm', 'r', 'a', 'n', 'k',
' ', 'L', 'i', 'n', 'e', ':', ' ', '1', ' ',
'C', 'o', 'l', 'u', 'm', 'n', ':', ' ', '1',
' ', 'T', 'h', 'e', ' ', 'f', 'u', 'n', 'c',
't', 'i', 'o', 'n', ' ', '"', 'm', 'r', 'a',
'n', 'k', '"', ' ', '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 mxArray * _mxarray0_;
static mxChar _array3_[127] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
'l', 'e', ':', ' ', 'm', 'r', 'a', 'n', 'k',
' ', 'L', 'i', 'n', 'e', ':', ' ', '1', ' ',
'C', 'o', 'l', 'u', 'm', 'n', ':', ' ', '1',
' ', 'T', 'h', 'e', ' ', 'f', 'u', 'n', 'c',
't', 'i', 'o', 'n', ' ', '"', 'm', 'r', 'a',
'n', 'k', '"', ' ', '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 mxArray * _mxarray2_;
static mxArray * _mxarray4_;
static mxArray * _mxarray5_;
void InitializeModule_mrank(void) {
_mxarray0_ = mclInitializeString(128, _array1_);
_mxarray2_ = mclInitializeString(127, _array3_);
_mxarray4_ = mclInitializeDouble(1.0);
_mxarray5_ = mclInitializeDoubleVector(0, 0, (double *)NULL);
}
void TerminateModule_mrank(void) {
mxDestroyArray(_mxarray5_);
mxDestroyArray(_mxarray4_);
mxDestroyArray(_mxarray2_);
mxDestroyArray(_mxarray0_);
}
static mxArray * Mmrank(int nargout_, mxArray * n);
_mexLocalFunctionTable _local_function_table_mrank
= { 0, (mexFunctionTableEntry *)NULL };
/*
* The function "mlfMrank" contains the normal interface for the "mrank"
* M-function from file "D:\mywork\mrank.m" (lines 1-6). This function
* processes any input arguments and passes them to the implementation version
* of the function, appearing above.
*/
mxArray * mlfMrank(mxArray * n) {
int nargout = 1;
mxArray * r = mclGetUninitializedArray();
mlfEnterNewContext(0, 1, n);
r = Mmrank(nargout, n);
mlfRestorePreviousContext(0, 1, n);
return mlfReturnValue(r);
}
/*
* The function "mlxMrank" contains the feval interface for the "mrank"
* M-function from file "D:\mywork\mrank.m" (lines 1-6). The feval function
* calls the implementation version of mrank through this function. This
* function processes any input arguments and passes them to the implementation
* version of the function, appearing above.
*/
void mlxMrank(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] = Mmrank(nlhs, mprhs[0]);
mlfRestorePreviousContext(0, 1, mprhs[0]);
plhs[0] = mplhs[0];
}
/*
* The function "Mmrank" is the implementation version of the "mrank"
* M-function from file "D:\mywork\mrank.m" (lines 1-6). 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 r=mrank(n)
*/
static mxArray * Mmrank(int nargout_, mxArray * n) {
mexLocalFunctionTable save_local_function_table_
= mclSetCurrentLocalFunctionTable(&_local_function_table_mrank);
mxArray * r = mclGetUninitializedArray();
mxArray * k = mclGetUninitializedArray();
mclCopyArray(&n);
/*
* r=zeros(n,1);
*/
mlfAssign(&r, mlfZeros(mclVa(n, "n"), _mxarray4_, NULL));
/*
* for k=1:n
*/
{
int v_ = mclForIntStart(1);
int e_ = mclForIntEnd(mclVa(n, "n"));
if (v_ > e_) {
mlfAssign(&k, _mxarray5_);
} else {
/*
* r(k)=rank(magic(k));
* end
*/
for (; ; ) {
mclIntArrayAssign1(
&r, mlfRank(mclVe(mlfMagic(mlfScalar(v_))), NULL), v_);
if (v_ == e_) {
break;
}
++v_;
}
mlfAssign(&k, mlfScalar(v_));
}
}
mclValidateOutput(r, 1, nargout_, "r", "mrank");
mxDestroyArray(k);
mxDestroyArray(n);
mclSetCurrentLocalFunctionTable(save_local_function_table_);
return r;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -