File: NCAF.c1 /* 2 * NCAF.c 3 * 4 * Code generation for function 'NCAF' 5 * 6 */ 7 8 /* Include files */ 9 #include "rt_nonfinite.h" 10 #include "gjbf.h" 11 #include "NCAF.h" 12 #include "gjbf_emxutil.h" 13 #include "error1.h" 14 #include "eml_int_forloop_overflow_check.h" 15 #include "gjbf_data.h" 16 #include "blas.h" 17 18 /* Variable Definitions */ 19 static emlrtRSInfo se_emlrtRSI = { 5, "NCAF", 20 "E:\\micro array project\\Microphone Array\\beamform test\\NCAF.m" }; 21 22 static emlrtRSInfo te_emlrtRSI = { 12, "NCAF", 23 "E:\\micro array project\\Microphone Array\\beamform test\\NCAF.m" }; 24 25 static emlrtRSInfo ue_emlrtRSI = { 25, "indexShapeCheck", 26 "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\eml\\+coder\\+internal\\indexShapeCheck.m" 27 }; 28 29 static emlrtRSInfo ve_emlrtRSI = { 80, "indexShapeCheck", 30 "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\eml\\+coder\\+internal\\indexShapeCheck.m" 31 }; 32 33 static emlrtRSInfo we_emlrtRSI = { 23, "indexShapeCheck", 34 "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\eml\\+coder\\+internal\\indexShapeCheck.m" 35 }; 36 37 static emlrtRSInfo xe_emlrtRSI = { 15, "sqrt", 38 "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\lib\\matlab\\elfun\\sqrt.m" 39 }; 40 41 static emlrtRSInfo ye_emlrtRSI = { 24, "applyScalarFunctionInPlace", 42 "C:\\Program Files\\MATLAB\\R2016a\\toolbox\\eml\\eml\\+coder\\+internal\\applyScalarFunctionInPlace.m" 43 }; 44 45 static emlrtRTEInfo m_emlrtRTEI = { 1, 15, "NCAF", 46 "E:\\micro array project\\Microphone Array\\beamform test\\NCAF.m" }; 47 48 static emlrtRTEInfo n_emlrtRTEI = { 6, 9, "NCAF", 49 "E:\\micro array project\\Microphone Array\\beamform test\\NCAF.m" }; 50 51 static emlrtRTEInfo o_emlrtRTEI = { 9, 13, "NCAF", 52 "E:\\micro array project\\Microphone Array\\beamform test\\NCAF.m" }; 53 54 static emlrtBCInfo t_emlrtBCI = { 1, 882, 9, 49, "mcAdapt", "NCAF", 55 "E:\\micro array project\\Microphone Array\\beamform test\\NCAF.m", 0 }; 56 57 static emlrtECInfo k_emlrtECI = { 2, 10, 20, "NCAF", 58 "E:\\micro array project\\Microphone Array\\beamform test\\NCAF.m" }; 59 60 static emlrtECInfo l_emlrtECI = { -1, 12, 13, "NCAF", 61 "E:\\micro array project\\Microphone Array\\beamform test\\NCAF.m" }; 62 63 static emlrtECInfo m_emlrtECI = { -1, 12, 3, "NCAF", 64 "E:\\micro array project\\Microphone Array\\beamform test\\NCAF.m" }; 65 66 static emlrtBCInfo u_emlrtBCI = { 1, 320, 12, 13, "w", "NCAF", 67 "E:\\micro array project\\Microphone Array\\beamform test\\NCAF.m", 0 }; 68 69 static emlrtBCInfo v_emlrtBCI = { -1, -1, 12, 32, "OmegaMat", "NCAF", 70 "E:\\micro array project\\Microphone Array\\beamform test\\NCAF.m", 0 }; 71 72 static emlrtBCInfo w_emlrtBCI = { 1, 320, 12, 3, "w", "NCAF", 73 "E:\\micro array project\\Microphone Array\\beamform test\\NCAF.m", 0 }; 74 75 /* Function Definitions */ 76 void NCAF(const emlrtStack *sp, real_T K, real_T w[320], real_T order, real_T n, 77 const real_T mcAdapt[14112]) 78 { 79 real_T y[320]; 80 int32_T k; 81 real_T Omega[16]; 82 int32_T i; 83 emxArray_real_T *OmegaMat; 84 int32_T xoffset; 85 real_T s; 86 int32_T i48; 87 emxArray_real_T *amcIndMat; 88 emxArray_boolean_T *r3; 89 int32_T iv66[2]; 90 int32_T b_amcIndMat[2]; 91 emxArray_boolean_T *r4; 92 int32_T indexSize[2]; 93 boolean_T nonSingletonDimFound; 94 emxArray_int32_T *r5; 95 emxArray_real_T *x; 96 emxArray_real_T *r6; 97 emxArray_real_T *r7; 98 emlrtStack st; 99 emlrtStack b_st; 100 emlrtStack c_st; 101 emlrtStack d_st; 102 st.prev = sp; 103 st.tls = sp->tls; 104 b_st.prev = &st; 105 b_st.tls = st.tls; 106 c_st.prev = &b_st; 107 c_st.tls = b_st.tls; 108 d_st.prev = &c_st; 109 d_st.tls = c_st.tls; 110 emlrtHeapReferenceStackEnterFcnR2012b(sp); 111 covrtLogFcn(&emlrtCoverageInstance, 11U, 0); 112 covrtLogCond(&emlrtCoverageInstance, 11U, 0U, 0, false); 113 covrtLogMcdc(&emlrtCoverageInstance, 11U, 0U, 0, true); 114 covrtLogIf(&emlrtCoverageInstance, 11U, 0U, 0, true); 115 covrtLogBasicBlock(&emlrtCoverageInstance, 11U, 0); 116 117 /* Finding norm without Matlab's function lets us avoid for */ 118 st.site = &se_emlrtRSI; 119 b_st.site = &xb_emlrtRSI; 120 for (k = 0; k < 320; k++) { 121 y[k] = w[k] * w[k]; 122 } 123 124 for (i = 0; i < 16; i++) { 125 xoffset = i * 20; 126 s = y[xoffset]; 127 for (k = 0; k < 19; k++) { 128 s += y[(xoffset + k) + 1]; 129 } 130 131 Omega[i] = s; 132 } 133 134 emxInit_real_T(sp, &OmegaMat, 2, &n_emlrtRTEI, true); 135 136 /* Find norm of all columns */ 137 i48 = OmegaMat->size[0] * OmegaMat->size[1]; 138 OmegaMat->size[0] = (int32_T)order; 139 OmegaMat->size[1] = 16; 140 emxEnsureCapacity(sp, (emxArray__common *)OmegaMat, i48, (int32_T)sizeof 141 (real_T), &m_emlrtRTEI); 142 k = (int32_T)order; 143 for (i48 = 0; i48 < k; i48++) { 144 for (i = 0; i < 16; i++) { 145 OmegaMat->data[i48 + OmegaMat->size[0] * i] = Omega[i]; 146 } 147 } 148 149 emxInit_real_T(sp, &amcIndMat, 2, &o_emlrtRTEI, true); 150 151 /* Expand to a norm matrix */ 152 /* save comparison so it doesnt repeat */ 153 covrtLogCond(&emlrtCoverageInstance, 11U, 0U, 1, false); 154 covrtLogMcdc(&emlrtCoverageInstance, 11U, 0U, 1, true); 155 covrtLogIf(&emlrtCoverageInstance, 11U, 0U, 1, true); 156 covrtLogBasicBlock(&emlrtCoverageInstance, 11U, 1); 157 158 /* apply AMC SNR threshold if specified */ 159 i48 = (int32_T)n; 160 if (!((i48 >= 1) && (i48 <= 882))) { 161 emlrtDynamicBoundsCheckR2012b(i48, 1, 882, &t_emlrtBCI, sp); 162 } 163 164 i48 = amcIndMat->size[0] * amcIndMat->size[1]; 165 amcIndMat->size[0] = (int32_T)order; 166 amcIndMat->size[1] = 16; 167 emxEnsureCapacity(sp, (emxArray__common *)amcIndMat, i48, (int32_T)sizeof 168 (real_T), &m_emlrtRTEI); 169 k = (int32_T)order; 170 for (i48 = 0; i48 < k; i48++) { 171 for (i = 0; i < 16; i++) { 172 amcIndMat->data[i48 + amcIndMat->size[0] * i] = mcAdapt[((int32_T)n + 882 * 173 i) - 1]; 174 } 175 } 176 177 emxInit_boolean_T(sp, &r3, 2, &m_emlrtRTEI, true); 178 i48 = r3->size[0] * r3->size[1]; 179 r3->size[0] = OmegaMat->size[0]; 180 r3->size[1] = 16; 181 emxEnsureCapacity(sp, (emxArray__common *)r3, i48, (int32_T)sizeof(boolean_T), 182 &m_emlrtRTEI); 183 k = OmegaMat->size[0] * OmegaMat->size[1]; 184 for (i48 = 0; i48 < k; i48++) { 185 r3->data[i48] = (OmegaMat->data[i48] > K); 186 } 187 188 for (i48 = 0; i48 < 2; i48++) { 189 iv66[i48] = r3->size[i48]; 190 } 191 192 for (i48 = 0; i48 < 2; i48++) { 193 b_amcIndMat[i48] = amcIndMat->size[i48]; 194 } 195 196 emxInit_boolean_T(sp, &r4, 2, &m_emlrtRTEI, true); 197 if ((iv66[0] != b_amcIndMat[0]) || (iv66[1] != b_amcIndMat[1])) { 198 emlrtSizeEqCheckNDR2012b(&iv66[0], &b_amcIndMat[0], &k_emlrtECI, sp); 199 } 200 201 i48 = r4->size[0] * r4->size[1]; 202 r4->size[0] = amcIndMat->size[0]; 203 r4->size[1] = 16; 204 emxEnsureCapacity(sp, (emxArray__common *)r4, i48, (int32_T)sizeof(boolean_T), 205 &m_emlrtRTEI); 206 k = amcIndMat->size[0] * amcIndMat->size[1]; 207 for (i48 = 0; i48 < k; i48++) { 208 r4->data[i48] = (amcIndMat->data[i48] != 0.0); 209 } 210 211 emxFree_real_T(&amcIndMat); 212 covrtLogBasicBlock(&emlrtCoverageInstance, 11U, 2); 213 st.site = &te_emlrtRSI; 214 for (i48 = 0; i48 < 2; i48++) { 215 indexSize[i48] = r3->size[i48]; 216 } 217 218 nonSingletonDimFound = false; 219 if (indexSize[0] != 1) { 220 nonSingletonDimFound = true; 221 } 222 223 if (nonSingletonDimFound) { 224 nonSingletonDimFound = false; 225 } else { 226 nonSingletonDimFound = true; 227 } 228 229 if (nonSingletonDimFound) { 230 b_st.site = &ue_emlrtRSI; 231 c_st.site = &ve_emlrtRSI; 232 emlrtErrorWithMessageIdR2012b(&c_st, &t_emlrtRTEI, 233 "Coder:FE:PotentialMatrixMatrix", 0); 234 } 235 236 st.site = &te_emlrtRSI; 237 for (i48 = 0; i48 < 2; i48++) { 238 indexSize[i48] = r3->size[i48]; 239 } 240 241 nonSingletonDimFound = false; 242 if (OmegaMat->size[0] != 1) { 243 nonSingletonDimFound = true; 244 } 245 246 if (nonSingletonDimFound) { 247 nonSingletonDimFound = false; 248 } else { 249 nonSingletonDimFound = true; 250 } 251 252 if (nonSingletonDimFound) { 253 b_st.site = &we_emlrtRSI; 254 c_st.site = &ve_emlrtRSI; 255 emlrtErrorWithMessageIdR2012b(&c_st, &t_emlrtRTEI, 256 "Coder:FE:PotentialMatrixMatrix", 0); 257 } else { 258 nonSingletonDimFound = false; 259 if (indexSize[0] != 1) { 260 nonSingletonDimFound = true; 261 } 262 263 if (nonSingletonDimFound) { 264 nonSingletonDimFound = false; 265 } else { 266 nonSingletonDimFound = true; 267 } 268 269 if (nonSingletonDimFound) { 270 b_st.site = &ue_emlrtRSI; 271 c_st.site = &ve_emlrtRSI; 272 emlrtErrorWithMessageIdR2012b(&c_st, &t_emlrtRTEI, 273 "Coder:FE:PotentialMatrixMatrix", 0); 274 } 275 } 276 277 xoffset = r3->size[0] << 4; 278 for (i = 0; i < xoffset; i++) { 279 if (r3->data[i] && r4->data[i] && (!((i + 1 >= 1) && (i + 1 <= 320)))) { 280 emlrtDynamicBoundsCheckR2012b(i + 1, 1, 320, &u_emlrtBCI, sp); 281 } 282 } 283 284 emxInit_int32_T(sp, &r5, 1, &m_emlrtRTEI, true); 285 xoffset = (r3->size[0] << 4) - 1; 286 k = 0; 287 for (i = 0; i <= xoffset; i++) { 288 if (r3->data[i] && r4->data[i]) { 289 k++; 290 } 291 } 292 293 i48 = r5->size[0]; 294 r5->size[0] = k; 295 emxEnsureCapacity(sp, (emxArray__common *)r5, i48, (int32_T)sizeof(int32_T), 296 &m_emlrtRTEI); 297 k = 0; 298 for (i = 0; i <= xoffset; i++) { 299 if (r3->data[i] && r4->data[i]) { 300 r5->data[k] = i + 1; 301 k++; 302 } 303 } 304 305 xoffset = OmegaMat->size[0] << 4; 306 k = r5->size[0]; 307 for (i48 = 0; i48 < k; i48++) { 308 i = r5->data[i48]; 309 if (!((i >= 1) && (i <= xoffset))) { 310 emlrtDynamicBoundsCheckR2012b(i, 1, xoffset, &v_emlrtBCI, sp); 311 } 312 } 313 314 emxInit_real_T2(sp, &x, 1, &m_emlrtRTEI, true); 315 i48 = x->size[0]; 316 x->size[0] = r5->size[0]; 317 emxEnsureCapacity(sp, (emxArray__common *)x, i48, (int32_T)sizeof(real_T), 318 &m_emlrtRTEI); 319 k = r5->size[0]; 320 for (i48 = 0; i48 < k; i48++) { 321 x->data[i48] = K / OmegaMat->data[r5->data[i48] - 1]; 322 } 323 324 emxFree_int32_T(&r5); 325 emxFree_real_T(&OmegaMat); 326 st.site = &te_emlrtRSI; 327 nonSingletonDimFound = false; 328 for (k = 0; k < x->size[0]; k++) { 329 if (nonSingletonDimFound || (x->data[k] < 0.0)) { 330 nonSingletonDimFound = true; 331 } else { 332 nonSingletonDimFound = false; 333 } 334 } 335 336 if (nonSingletonDimFound) { 337 b_st.site = &ac_emlrtRSI; 338 w_error(&b_st); 339 } 340 341 emxInit_real_T2(&st, &r6, 1, &m_emlrtRTEI, true); 342 b_st.site = &xe_emlrtRSI; 343 i48 = r6->size[0]; 344 r6->size[0] = x->size[0]; 345 emxEnsureCapacity(&b_st, (emxArray__common *)r6, i48, (int32_T)sizeof(real_T), 346 &m_emlrtRTEI); 347 k = x->size[0]; 348 for (i48 = 0; i48 < k; i48++) { 349 r6->data[i48] = x->data[i48]; 350 } 351 352 c_st.site = &ye_emlrtRSI; 353 nonSingletonDimFound = ((!(1 > x->size[0])) && (x->size[0] > 2147483646)); 354 if (nonSingletonDimFound) { 355 d_st.site = &kb_emlrtRSI; 356 check_forloop_overflow_error(&d_st); 357 } 358 359 for (k = 0; k + 1 <= x->size[0]; k++) { 360 r6->data[k] = muDoubleScalarSqrt(r6->data[k]); 361 } 362 363 emxFree_real_T(&x); 364 xoffset = r3->size[0] << 4; 365 k = 0; 366 for (i = 0; i < xoffset; i++) { 367 if (r3->data[i] && r4->data[i]) { 368 k++; 369 } 370 } 371 372 i48 = r6->size[0]; 373 if (k != i48) { 374 emlrtSizeEqCheck1DR2012b(k, i48, &l_emlrtECI, sp); 375 } 376 377 xoffset = (r3->size[0] << 4) - 1; 378 k = 0; 379 for (i = 0; i <= xoffset; i++) { 380 if (r3->data[i] && r4->data[i]) { 381 k++; 382 } 383 } 384 385 emxInit_real_T2(sp, &r7, 1, &m_emlrtRTEI, true); 386 i48 = r7->size[0]; 387 r7->size[0] = k; 388 emxEnsureCapacity(sp, (emxArray__common *)r7, i48, (int32_T)sizeof(real_T), 389 &m_emlrtRTEI); 390 k = 0; 391 for (i = 0; i <= xoffset; i++) { 392 if (r3->data[i] && r4->data[i]) { 393 r7->data[k] = w[i] * r6->data[k]; 394 k++; 395 } 396 } 397 398 emxFree_real_T(&r6); 399 xoffset = r3->size[0] << 4; 400 k = 0; 401 for (i = 0; i < xoffset; i++) { 402 if (r3->data[i] && r4->data[i]) { 403 k++; 404 } 405 } 406 407 i48 = r7->size[0]; 408 if (k != i48) { 409 emlrtSizeEqCheck1DR2012b(k, i48, &m_emlrtECI, sp); 410 } 411 412 xoffset = r3->size[0] << 4; 413 k = 0; 414 for (i = 0; i < xoffset; i++) { 415 if (r3->data[i] && r4->data[i]) { 416 if (!((i + 1 >= 1) && (i + 1 <= 320))) { 417 emlrtDynamicBoundsCheckR2012b(i + 1, 1, 320, &w_emlrtBCI, sp); 418 } 419 420 w[i] = r7->data[k]; 421 k++; 422 } 423 } 424 425 emxFree_boolean_T(&r4); 426 emxFree_real_T(&r7); 427 emxFree_boolean_T(&r3); 428 covrtLogBasicBlock(&emlrtCoverageInstance, 11U, 3); 429 emlrtHeapReferenceStackLeaveFcnR2012b(sp); 430 } 431 432 /* End of code generation (NCAF.c) */ 433 |