File: targmc.c

    1   /*
    2    * targmc.c
    3    *
    4    * Code generation for function 'targmc'
    5    *
    6    */
    7   
    8   /* Include files */
    9   #include "rt_nonfinite.h"
   10   #include "gjbf.h"
   11   #include "targmc.h"
   12   #include "mclms.h"
   13   #include "gjbf_emxutil.h"
   14   #include "gjbf_mexutil.h"
   15   #include "gjbf_data.h"
   16   #include "blas.h"
   17   
   18   /* Variable Definitions */
   19   static emlrtRSInfo ne_emlrtRSI = { 14, "targmc",
   20     "E:\\micro array project\\Microphone Array\\beamform test\\targmc.m" };
   21   
   22   static emlrtRSInfo oe_emlrtRSI = { 11, "targmc",
   23     "E:\\micro array project\\Microphone Array\\beamform test\\targmc.m" };
   24   
   25   static emlrtRTEInfo e_emlrtRTEI = { 1, 23, "targmc",
   26     "E:\\micro array project\\Microphone Array\\beamform test\\targmc.m" };
   27   
   28   static emlrtBCInfo l_emlrtBCI = { -1, -1, 14, 16, "y", "targmc",
   29     "E:\\micro array project\\Microphone Array\\beamform test\\targmc.m", 0 };
   30   
   31   static emlrtBCInfo m_emlrtBCI = { 1, 882, 7, 18, "z", "targmc",
   32     "E:\\micro array project\\Microphone Array\\beamform test\\targmc.m", 0 };
   33   
   34   static emlrtBCInfo n_emlrtBCI = { 1, 882, 5, 47, "z", "targmc",
   35     "E:\\micro array project\\Microphone Array\\beamform test\\targmc.m", 0 };
   36   
   37   static emlrtBCInfo o_emlrtBCI = { -1, -1, 5, 23, "zPrev", "targmc",
   38     "E:\\micro array project\\Microphone Array\\beamform test\\targmc.m", 0 };
   39   
   40   static emlrtBCInfo p_emlrtBCI = { -1, -1, 11, 8, "b", "targmc",
   41     "E:\\micro array project\\Microphone Array\\beamform test\\targmc.m", 0 };
   42   
   43   static emlrtBCInfo q_emlrtBCI = { -1, -1, 11, 1, "y", "targmc",
   44     "E:\\micro array project\\Microphone Array\\beamform test\\targmc.m", 0 };
   45   
   46   /* Function Definitions */
   47   void targmc(const emlrtStack *sp, const emxArray_real_T *zPrev, const real_T z
   48               [14112], const real_T b_data[], const int32_T b_size[1], real_T n,
   49               real_T order, const real_T w[320], real_T y_data[], int32_T y_size[1],
   50               emxArray_real_T *zWin)
   51   {
   52     real_T alpha1;
   53     int32_T j;
   54     int32_T i44;
   55     int32_T i45;
   56     int32_T loop_ub;
   57     int32_T i46;
   58     real_T a[320];
   59     real_T beta1;
   60     char_T TRANSB;
   61     char_T TRANSA;
   62     real_T y[256];
   63     ptrdiff_t m_t;
   64     ptrdiff_t n_t;
   65     ptrdiff_t k_t;
   66     ptrdiff_t lda_t;
   67     ptrdiff_t ldb_t;
   68     ptrdiff_t ldc_t;
   69     real_T d[16];
   70     const mxArray *b_y;
   71     char_T u[19];
   72     static const char_T varargin_1[19] = { 'O', 'u', 't', 'p', 'u', 't', ' ', 'h',
   73       'a', 's', ' ', 'b', 'l', 'o', 'w', 'n', ' ', 'u', 'p' };
   74   
   75     const mxArray *m29;
   76     static const int32_T iv62[2] = { 1, 19 };
   77   
   78     emlrtStack st;
   79     emlrtStack b_st;
   80     st.prev = sp;
   81     st.tls = sp->tls;
   82     b_st.prev = &st;
   83     b_st.tls = st.tls;
   84     covrtLogFcn(&emlrtCoverageInstance, 9U, 0);
   85   
   86     /*  Select the data window for this iteration */
   87     if (covrtLogIf(&emlrtCoverageInstance, 9U, 0U, 0, n <= order)) {
   88       covrtLogBasicBlock(&emlrtCoverageInstance, 9U, 0);
   89   
   90       /*  feed in supplied past values ahead of z */
   91       alpha1 = (((real_T)zPrev->size[0] - order) + n) + 1.0;
   92       if (alpha1 > zPrev->size[0]) {
   93         j = 0;
   94         i45 = 0;
   95       } else {
   96         j = zPrev->size[0];
   97         i44 = (int32_T)alpha1;
   98         if (!((i44 >= 1) && (i44 <= j))) {
   99           emlrtDynamicBoundsCheckR2012b(i44, 1, j, &o_emlrtBCI, sp);
  100         }
  101   
  102         j = i44 - 1;
  103         i44 = zPrev->size[0];
  104         i45 = zPrev->size[0];
  105         if (!((i45 >= 1) && (i45 <= i44))) {
  106           emlrtDynamicBoundsCheckR2012b(i45, 1, i44, &o_emlrtBCI, sp);
  107         }
  108       }
  109   
  110       i44 = (int32_T)n;
  111       if (!((i44 >= 1) && (i44 <= 882))) {
  112         emlrtDynamicBoundsCheckR2012b(i44, 1, 882, &n_emlrtBCI, sp);
  113       }
  114   
  115       i44 = zWin->size[0] * zWin->size[1];
  116       zWin->size[0] = (i45 - j) + (int32_T)n;
  117       zWin->size[1] = 16;
  118       emxEnsureCapacity(sp, (emxArray__common *)zWin, i44, (int32_T)sizeof(real_T),
  119                         &e_emlrtRTEI);
  120       for (i44 = 0; i44 < 16; i44++) {
  121         loop_ub = i45 - j;
  122         for (i46 = 0; i46 < loop_ub; i46++) {
  123           zWin->data[i46 + zWin->size[0] * i44] = zPrev->data[(j + i46) +
  124             zPrev->size[0] * i44];
  125         }
  126       }
  127   
  128       for (i44 = 0; i44 < 16; i44++) {
  129         loop_ub = (int32_T)n;
  130         for (i46 = 0; i46 < loop_ub; i46++) {
  131           zWin->data[((i46 + i45) - j) + zWin->size[0] * i44] = z[i46 + 882 * i44];
  132         }
  133       }
  134     } else {
  135       covrtLogBasicBlock(&emlrtCoverageInstance, 9U, 1);
  136   
  137       /*  need only data from given z */
  138       alpha1 = (n - order) + 1.0;
  139       if (alpha1 > n) {
  140         j = 0;
  141         i44 = 0;
  142       } else {
  143         j = (int32_T)alpha1;
  144         if (!((j >= 1) && (j <= 882))) {
  145           emlrtDynamicBoundsCheckR2012b(j, 1, 882, &m_emlrtBCI, sp);
  146         }
  147   
  148         j--;
  149         i44 = (int32_T)n;
  150         if (!((i44 >= 1) && (i44 <= 882))) {
  151           emlrtDynamicBoundsCheckR2012b(i44, 1, 882, &m_emlrtBCI, sp);
  152         }
  153       }
  154   
  155       i45 = zWin->size[0] * zWin->size[1];
  156       zWin->size[0] = i44 - j;
  157       zWin->size[1] = 16;
  158       emxEnsureCapacity(sp, (emxArray__common *)zWin, i45, (int32_T)sizeof(real_T),
  159                         &e_emlrtRTEI);
  160       for (i45 = 0; i45 < 16; i45++) {
  161         loop_ub = i44 - j;
  162         for (i46 = 0; i46 < loop_ub; i46++) {
  163           zWin->data[i46 + zWin->size[0] * i45] = z[(j + i46) + 882 * i45];
  164         }
  165       }
  166     }
  167   
  168     covrtLogBasicBlock(&emlrtCoverageInstance, 9U, 2);
  169   
  170     /* initial w, and calculate output y  */
  171     st.site = &oe_emlrtRSI;
  172     for (j = 0; j < 20; j++) {
  173       for (i44 = 0; i44 < 16; i44++) {
  174         a[i44 + (j << 4)] = w[j + 20 * i44];
  175       }
  176     }
  177   
  178     b_st.site = &bd_emlrtRSI;
  179     if (!(20 == zWin->size[0])) {
  180       emlrtErrorWithMessageIdR2012b(&b_st, &y_emlrtRTEI, "Coder:MATLAB:innerdim",
  181         0);
  182     }
  183   
  184     b_st.site = &ad_emlrtRSI;
  185     alpha1 = 1.0;
  186     beta1 = 0.0;
  187     TRANSB = 'N';
  188     TRANSA = 'N';
  189     memset(&y[0], 0, sizeof(real_T) << 8);
  190     m_t = (ptrdiff_t)16;
  191     n_t = (ptrdiff_t)16;
  192     k_t = (ptrdiff_t)20;
  193     lda_t = (ptrdiff_t)16;
  194     ldb_t = (ptrdiff_t)20;
  195     ldc_t = (ptrdiff_t)16;
  196     dgemm(&TRANSA, &TRANSB, &m_t, &n_t, &k_t, &alpha1, &a[0], &lda_t, &zWin->data
  197           [0], &ldb_t, &beta1, &y[0], &ldc_t);
  198     for (j = 0; j < 16; j++) {
  199       d[j] = y[j * 17];
  200     }
  201   
  202     alpha1 = d[0];
  203     for (j = 0; j < 15; j++) {
  204       alpha1 += d[j + 1];
  205     }
  206   
  207     j = (int32_T)n;
  208     if (!((j >= 1) && (j <= b_size[0]))) {
  209       emlrtDynamicBoundsCheckR2012b(j, 1, b_size[0], &p_emlrtBCI, sp);
  210     }
  211   
  212     i44 = y_size[0];
  213     i45 = (int32_T)n;
  214     if (!((i45 >= 1) && (i45 <= i44))) {
  215       emlrtDynamicBoundsCheckR2012b(i45, 1, i44, &q_emlrtBCI, sp);
  216     }
  217   
  218     y_data[i45 - 1] = b_data[j - 1] - alpha1;
  219   
  220     /* check y inf or not */
  221     j = y_size[0];
  222     i44 = (int32_T)n;
  223     if (!((i44 >= 1) && (i44 <= j))) {
  224       emlrtDynamicBoundsCheckR2012b(i44, 1, j, &l_emlrtBCI, sp);
  225     }
  226   
  227     if (covrtLogIf(&emlrtCoverageInstance, 9U, 0U, 1, covrtLogMcdc
  228                    (&emlrtCoverageInstance, 9U, 0U, 0, !covrtLogCond
  229                     (&emlrtCoverageInstance, 9U, 0U, 0, (!muDoubleScalarIsInf
  230             (y_data[(int32_T)n - 1])) && (!muDoubleScalarIsNaN(y_data[(int32_T)n -
  231              1])))))) {
  232       st.site = &ne_emlrtRSI;
  233       for (j = 0; j < 19; j++) {
  234         u[j] = varargin_1[j];
  235       }
  236   
  237       b_y = NULL;
  238       m29 = emlrtCreateCharArray(2, iv62);
  239       emlrtInitCharArrayR2013a(&st, 19, m29, &u[0]);
  240       emlrtAssign(&b_y, m29);
  241       b_st.site = &af_emlrtRSI;
  242       ab_error(&b_st, b_y, &emlrtMCI);
  243     }
  244   
  245     covrtLogBasicBlock(&emlrtCoverageInstance, 9U, 3);
  246   }
  247   
  248   /* End of code generation (targmc.c) */
  249