⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 map_module_adp.c

📁 好东西
💻 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 "map_module_adp.h"
#include "libmatlbm.h"
#include "map_16qam.h"
#include "map_64qam.h"
#include "map_bpsk.h"
#include "map_qpsk.h"
static mxArray * _mxarray0_;
static mxArray * _mxarray1_;
static mxArray * _mxarray2_;
static mxArray * _mxarray3_;
static mxArray * _mxarray4_;
static mxArray * _mxarray5_;

void InitializeModule_map_module_adp(void) {
    _mxarray0_ = mclInitializeDouble(0.0);
    _mxarray1_ = mclInitializeDoubleVector(0, 0, (double *)NULL);
    _mxarray2_ = mclInitializeDouble(1.0);
    _mxarray3_ = mclInitializeDouble(2.0);
    _mxarray4_ = mclInitializeDouble(4.0);
    _mxarray5_ = mclInitializeDouble(6.0);
}

void TerminateModule_map_module_adp(void) {
    mxDestroyArray(_mxarray5_);
    mxDestroyArray(_mxarray4_);
    mxDestroyArray(_mxarray3_);
    mxDestroyArray(_mxarray2_);
    mxDestroyArray(_mxarray1_);
    mxDestroyArray(_mxarray0_);
}

static mxArray * Mmap_module_adp(int nargout_,
                                 mxArray * input,
                                 mxArray * map_flag);

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

/*
 * The function "mlfMap_module_adp" contains the normal interface for the
 * "map_module_adp" M-function from file
 * "c:\matlab6p5\work\adptive_ofdm\adptive_ofdm\map_module_adp.m" (lines 1-30).
 * This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfMap_module_adp(mxArray * input, mxArray * map_flag) {
    int nargout = 1;
    mxArray * output = NULL;
    mlfEnterNewContext(0, 2, input, map_flag);
    output = Mmap_module_adp(nargout, input, map_flag);
    mlfRestorePreviousContext(0, 2, input, map_flag);
    return mlfReturnValue(output);
}

/*
 * The function "mlxMap_module_adp" contains the feval interface for the
 * "map_module_adp" M-function from file
 * "c:\matlab6p5\work\adptive_ofdm\adptive_ofdm\map_module_adp.m" (lines 1-30).
 * The feval function calls the implementation version of map_module_adp
 * through this function. This function processes any input arguments and
 * passes them to the implementation version of the function, appearing above.
 */
void mlxMap_module_adp(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: map_module_adp Line: 1 Colum"
            "n: 1 The function \"map_module_adp\" was called wi"
            "th more than the declared number of outputs (1)."),
          NULL);
    }
    if (nrhs > 2) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: map_module_adp Line: 1 Colum"
            "n: 1 The function \"map_module_adp\" was called wi"
            "th more 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] = Mmap_module_adp(nlhs, mprhs[0], mprhs[1]);
    mlfRestorePreviousContext(0, 2, mprhs[0], mprhs[1]);
    plhs[0] = mplhs[0];
}

/*
 * The function "Mmap_module_adp" is the implementation version of the
 * "map_module_adp" M-function from file
 * "c:\matlab6p5\work\adptive_ofdm\adptive_ofdm\map_module_adp.m" (lines 1-30).
 * 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=map_module_adp(input,map_flag)%按照map_flag指示完成各种星座映射,input为输入比特块
 */
static mxArray * Mmap_module_adp(int nargout_,
                                 mxArray * input,
                                 mxArray * map_flag) {
    mexLocalFunctionTable save_local_function_table_
      = mclSetCurrentLocalFunctionTable(&_local_function_table_map_module_adp);
    mxArray * output = NULL;
    mxArray * map_input = NULL;
    mxArray * ic = NULL;
    mxArray * n = NULL;
    mxArray * j = NULL;
    mxArray * NL = NULL;
    mxArray * N = NULL;
    mclCopyArray(&input);
    mclCopyArray(&map_flag);
    /*
     * [N,NL]=size(input);
     */
    mlfSize(mlfVarargout(&N, &NL, NULL), mclVa(input, "input"), NULL);
    /*
     * if map_flag==0
     */
    if (mclEqBool(mclVa(map_flag, "map_flag"), _mxarray0_)) {
        /*
         * output=[];
         */
        mlfAssign(&output, _mxarray1_);
    /*
     * else
     */
    } else {
        /*
         * N=N/map_flag;
         */
        mlfAssign(&N, mclMrdivide(mclVv(N, "N"), mclVa(map_flag, "map_flag")));
        /*
         * output=zeros(N,NL);
         */
        mlfAssign(&output, mlfZeros(mclVv(N, "N"), mclVv(NL, "NL"), NULL));
        /*
         * for j=1:NL
         */
        {
            int v_ = mclForIntStart(1);
            int e_ = mclForIntEnd(mclVv(NL, "NL"));
            if (v_ > e_) {
                mlfAssign(&j, _mxarray1_);
            } else {
                /*
                 * for n=1:N
                 * for ic=1:map_flag
                 * map_input(ic)=input((n-1)*map_flag+ic,j);  %每次取map_flag个bit 
                 * end
                 * if map_flag==1
                 * output(n,j)=map_bpsk(map_input);           %output每一列为一次FFT运算的信号,与一个ofdm符号结构相似
                 * elseif map_flag==2
                 * output(n,j)=map_qpsk(map_input);
                 * %           elseif map_flag==3
                 * %               output(n,j)=map_8psk(map_input);
                 * elseif map_flag==4
                 * output(n,j)=map_16qam(map_input);  
                 * elseif map_flag==6
                 * output(n,j)=map_64qam(map_input);
                 * else 
                 * output(n,j)=0;
                 * end
                 * end
                 * end
                 */
                for (; ; ) {
                    int v_0 = mclForIntStart(1);
                    int e_0 = mclForIntEnd(mclVv(N, "N"));
                    if (v_0 > e_0) {
                        mlfAssign(&n, _mxarray1_);
                    } else {
                        for (; ; ) {
                            int v_1 = mclForIntStart(1);
                            int e_1 = mclForIntEnd(mclVa(map_flag, "map_flag"));
                            if (v_1 > e_1) {
                                mlfAssign(&ic, _mxarray1_);
                            } else {
                                for (; ; ) {
                                    mclIntArrayAssign1(
                                      &map_input,
                                      mclArrayRef2(
                                        mclVa(input, "input"),
                                        mclPlus(
                                          mclMtimes(
                                            mlfScalar(v_0 - 1),
                                            mclVa(map_flag, "map_flag")),
                                          mlfScalar(v_1)),
                                        mlfScalar(v_)),
                                      v_1);
                                    if (v_1 == e_1) {
                                        break;
                                    }
                                    ++v_1;
                                }
                                mlfAssign(&ic, mlfScalar(v_1));
                            }
                            if (mclEqBool(
                                  mclVa(map_flag, "map_flag"), _mxarray2_)) {
                                mclIntArrayAssign2(
                                  &output,
                                  mlfMap_bpsk(mclVv(map_input, "map_input")),
                                  v_0,
                                  v_);
                            } else if (mclEqBool(
                                         mclVa(map_flag, "map_flag"),
                                         _mxarray3_)) {
                                mclIntArrayAssign2(
                                  &output,
                                  mlfMap_qpsk(mclVv(map_input, "map_input")),
                                  v_0,
                                  v_);
                            } else if (mclEqBool(
                                         mclVa(map_flag, "map_flag"),
                                         _mxarray4_)) {
                                mclIntArrayAssign2(
                                  &output,
                                  mlfMap_16qam(mclVv(map_input, "map_input")),
                                  v_0,
                                  v_);
                            } else if (mclEqBool(
                                         mclVa(map_flag, "map_flag"),
                                         _mxarray5_)) {
                                mclIntArrayAssign2(
                                  &output,
                                  mlfMap_64qam(mclVv(map_input, "map_input")),
                                  v_0,
                                  v_);
                            } else {
                                mclIntArrayAssign2(
                                  &output, _mxarray0_, v_0, v_);
                            }
                            if (v_0 == e_0) {
                                break;
                            }
                            ++v_0;
                        }
                        mlfAssign(&n, mlfScalar(v_0));
                    }
                    if (v_ == e_) {
                        break;
                    }
                    ++v_;
                }
                mlfAssign(&j, mlfScalar(v_));
            }
        }
    /*
     * end   
     */
    }
    mclValidateOutput(output, 1, nargout_, "output", "map_module_adp");
    mxDestroyArray(N);
    mxDestroyArray(NL);
    mxDestroyArray(j);
    mxDestroyArray(n);
    mxDestroyArray(ic);
    mxDestroyArray(map_input);
    mxDestroyArray(map_flag);
    mxDestroyArray(input);
    mclSetCurrentLocalFunctionTable(save_local_function_table_);
    return output;
    /*
     * 
     */
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -