📄 insert_cp.c
字号:
/*
* MATLAB Compiler: 3.0
* Date: Fri Mar 24 11:31:36 2006
* 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" "-m" "-W" "main" "-L"
* "C" "-t" "-T" "link:exe" "-h" "libmmfile.mlib"
* "adptive_bitpow_allocate_systems"
*/
#include "insert_cp.h"
#include "libmatlbm.h"
static mxArray * _mxarray0_;
static mxArray * _mxarray1_;
void InitializeModule_insert_cp(void) {
_mxarray0_ = mclInitializeDoubleVector(0, 0, (double *)NULL);
_mxarray1_ = mclInitializeDouble(1.0);
}
void TerminateModule_insert_cp(void) {
mxDestroyArray(_mxarray1_);
mxDestroyArray(_mxarray0_);
}
static mxArray * Minsert_cp(int nargout_, mxArray * input, mxArray * cp_length);
_mexLocalFunctionTable _local_function_table_insert_cp
= { 0, (mexFunctionTableEntry *)NULL };
/*
* The function "mlfInsert_cp" contains the normal interface for the
* "insert_cp" M-function from file
* "c:\matlab6p5\work\adptive_ofdm\adptive_ofdm\insert_cp.m" (lines 1-11). This
* function processes any input arguments and passes them to the implementation
* version of the function, appearing above.
*/
mxArray * mlfInsert_cp(mxArray * input, mxArray * cp_length) {
int nargout = 1;
mxArray * output = NULL;
mlfEnterNewContext(0, 2, input, cp_length);
output = Minsert_cp(nargout, input, cp_length);
mlfRestorePreviousContext(0, 2, input, cp_length);
return mlfReturnValue(output);
}
/*
* The function "mlxInsert_cp" contains the feval interface for the "insert_cp"
* M-function from file
* "c:\matlab6p5\work\adptive_ofdm\adptive_ofdm\insert_cp.m" (lines 1-11). The
* feval function calls the implementation version of insert_cp through this
* function. This function processes any input arguments and passes them to the
* implementation version of the function, appearing above.
*/
void mlxInsert_cp(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: insert_cp Line: 1 Column:"
" 1 The function \"insert_cp\" was called with m"
"ore than the declared number of outputs (1)."),
NULL);
}
if (nrhs > 2) {
mlfError(
mxCreateString(
"Run-time Error: File: insert_cp Line: 1 Column:"
" 1 The function \"insert_cp\" was called with m"
"ore than the declared number of inputs (2)."),
NULL);
}
for (i = 0; i < 1; ++i) {
mplhs[i] = NULL;
}
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] = Minsert_cp(nlhs, mprhs[0], mprhs[1]);
mlfRestorePreviousContext(0, 2, mprhs[0], mprhs[1]);
plhs[0] = mplhs[0];
}
/*
* The function "Minsert_cp" is the implementation version of the "insert_cp"
* M-function from file
* "c:\matlab6p5\work\adptive_ofdm\adptive_ofdm\insert_cp.m" (lines 1-11). 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 output=insert_cp(input,cp_length)%为ofdm符号块插入循环前缀,cp_length为循环前缀长度
*/
static mxArray * Minsert_cp(int nargout_,
mxArray * input,
mxArray * cp_length) {
mexLocalFunctionTable save_local_function_table_
= mclSetCurrentLocalFunctionTable(&_local_function_table_insert_cp);
mxArray * output = NULL;
mxArray * j = NULL;
mxArray * n = NULL;
mxArray * m = NULL;
mclCopyArray(&input);
mclCopyArray(&cp_length);
/*
* [m,n]=size(input);
*/
mlfSize(mlfVarargout(&m, &n, NULL), mclVa(input, "input"), NULL);
/*
* output=zeros(m+cp_length,n);
*/
mlfAssign(
&output,
mlfZeros(
mclPlus(mclVv(m, "m"), mclVa(cp_length, "cp_length")),
mclVv(n, "n"),
NULL));
/*
* %以下循环为各列插入循环前缀
* for j=1:n
*/
{
int v_ = mclForIntStart(1);
int e_ = mclForIntEnd(mclVv(n, "n"));
if (v_ > e_) {
mlfAssign(&j, _mxarray0_);
} else {
/*
* output(1:cp_length,j)=input((m-cp_length+1):m,j);
* output((cp_length+1):(m+cp_length),j)=input(:,j);
* end
*/
for (; ; ) {
mclArrayAssign2(
&output,
mclArrayRef2(
mclVa(input, "input"),
mlfColon(
mclPlus(
mclMinus(mclVv(m, "m"), mclVa(cp_length, "cp_length")),
_mxarray1_),
mclVv(m, "m"),
NULL),
mlfScalar(v_)),
mlfColon(_mxarray1_, mclVa(cp_length, "cp_length"), NULL),
mlfScalar(v_));
mclArrayAssign2(
&output,
mclArrayRef2(
mclVa(input, "input"),
mlfCreateColonIndex(),
mlfScalar(v_)),
mlfColon(
mclPlus(mclVa(cp_length, "cp_length"), _mxarray1_),
mclPlus(mclVv(m, "m"), mclVa(cp_length, "cp_length")),
NULL),
mlfScalar(v_));
if (v_ == e_) {
break;
}
++v_;
}
mlfAssign(&j, mlfScalar(v_));
}
}
mclValidateOutput(output, 1, nargout_, "output", "insert_cp");
mxDestroyArray(m);
mxDestroyArray(n);
mxDestroyArray(j);
mxDestroyArray(cp_length);
mxDestroyArray(input);
mclSetCurrentLocalFunctionTable(save_local_function_table_);
return output;
/*
*
*
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -