/* Function Definitions */ real_T combine_vector_elements(const emlrtStack *sp, const emxArray_real_T *x) { real_T y; boolean_T overflow; int32_T k; emlrtStack st; emlrtStack b_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; if (x->size[1] == 0) { y = 0.0; } else { y = x->data[0]; st.site = &hc_emlrtRSI; if (2 > x->size[1]) { overflow = false; } else { overflow = (x->size[1] > 2147483646); } if (overflow) { b_st.site = &wb_emlrtRSI; check_forloop_overflow_error(&b_st); } for (k = 2; k <= x->size[1]; k++) { y += x->data[k - 1]; } } return y; }
/* Function Definitions */ void b_exp(const emlrtStack *sp, emxArray_real_T *x) { int32_T nx; boolean_T overflow; int32_T k; emlrtStack st; emlrtStack b_st; emlrtStack c_st; st.prev = sp; st.tls = sp->tls; st.site = &y_emlrtRSI; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; nx = x->size[0]; b_st.site = &ab_emlrtRSI; if (1 > x->size[0]) { overflow = false; } else { overflow = (x->size[0] > 2147483646); } if (overflow) { c_st.site = &k_emlrtRSI; check_forloop_overflow_error(&c_st); } for (k = 0; k + 1 <= nx; k++) { x->data[k] = muDoubleScalarExp(x->data[k]); } }
/* Function Definitions */ static int32_T compute_nones(const emlrtStack *sp, const boolean_T x_data[1224], int32_T n) { int32_T k; boolean_T b4; int32_T i; emlrtStack st; emlrtStack b_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; k = 0; st.site = &gr_emlrtRSI; if (1 > n) { b4 = FALSE; } else { b4 = (n > 2147483646); } if (b4) { b_st.site = &bg_emlrtRSI; check_forloop_overflow_error(&b_st); } for (i = 1; i <= n; i++) { if (x_data[i - 1]) { st.site = &hr_emlrtRSI; k++; } } return k; }
/* Function Definitions */ void b_sum(const emlrtStack *sp, const emxArray_real_T *x, emxArray_real_T *y) { uint32_T sz[2]; int32_T iy; int32_T ixstart; boolean_T overflow; int32_T j; int32_T ix; real_T s; int32_T k; emlrtStack st; emlrtStack b_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; for (iy = 0; iy < 2; iy++) { sz[iy] = (uint32_T)x->size[iy]; } iy = y->size[0]; y->size[0] = (int32_T)sz[0]; emxEnsureCapacity(sp, (emxArray__common *)y, iy, (int32_T)sizeof(real_T), &q_emlrtRTEI); if (x->size[0] == 0) { iy = y->size[0]; y->size[0] = (int32_T)sz[0]; emxEnsureCapacity(sp, (emxArray__common *)y, iy, (int32_T)sizeof(real_T), &sb_emlrtRTEI); ixstart = (int32_T)sz[0]; for (iy = 0; iy < ixstart; iy++) { y->data[iy] = 0.0; } } else { iy = -1; ixstart = -1; st.site = &be_emlrtRSI; overflow = (x->size[0] > 2147483646); if (overflow) { b_st.site = &db_emlrtRSI; check_forloop_overflow_error(&b_st); } for (j = 1; j <= x->size[0]; j++) { ixstart++; ix = ixstart; s = x->data[ixstart]; for (k = 0; k < 2; k++) { ix += x->size[0]; s += x->data[ix]; } iy++; y->data[iy] = s; } } }
void diag(const emlrtStack *sp, const emxArray_real_T *v, emxArray_real_T *d) { int32_T m; int32_T n; int32_T stride; boolean_T b1; emlrtStack st; emlrtStack b_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; if ((v->size[0] == 1) && (v->size[1] == 1)) { m = d->size[0]; d->size[0] = 1; emxEnsureCapacity(sp, (emxArray__common *)d, m, (int32_T)sizeof(real_T), &g_emlrtRTEI); d->data[0] = v->data[0]; } else { if (!((v->size[0] == 1) || (v->size[1] == 1))) { } else { emlrtErrorWithMessageIdR2012b(sp, &j_emlrtRTEI, "Coder:toolbox:diag_varsizedMatrixVector", 0); } m = v->size[0]; n = v->size[1]; if (0 < v->size[1]) { n = muIntScalarMin_sint32(m, n); stride = v->size[0] + 1; } else { n = 0; stride = 0; } m = d->size[0]; d->size[0] = n; emxEnsureCapacity(sp, (emxArray__common *)d, m, (int32_T)sizeof(real_T), &g_emlrtRTEI); st.site = &j_emlrtRSI; if (1 > n) { b1 = false; } else { b1 = (n > 2147483646); } if (b1) { b_st.site = &k_emlrtRSI; check_forloop_overflow_error(&b_st); } for (m = 0; m + 1 <= n; m++) { d->data[m] = v->data[m * stride]; } } }
/* Function Definitions */ void eml_signed_integer_colon(const emlrtStack *sp, int32_T b, emxArray_int32_T * y) { int32_T n; int32_T yk; boolean_T b1; int32_T k; emlrtStack st; emlrtStack b_st; st.prev = sp; st.tls = sp->tls; st.site = &ub_emlrtRSI; b_st.prev = &st; b_st.tls = st.tls; if (b < 1) { n = 0; } else { n = b; } yk = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = n; emxEnsureCapacity(sp, (emxArray__common *)y, yk, (int32_T)sizeof(int32_T), &l_emlrtRTEI); if (n > 0) { y->data[0] = 1; yk = 1; st.site = &vb_emlrtRSI; if (2 > n) { b1 = false; } else { b1 = (n > 2147483646); } if (b1) { b_st.site = &db_emlrtRSI; check_forloop_overflow_error(&b_st); } for (k = 2; k <= n; k++) { yk++; y->data[k - 1] = yk; } } }
/* Function Definitions */ void eml_signed_integer_colon(int32_T b, emxArray_int32_T *y) { int32_T n; int32_T yk; boolean_T b3; int32_T k; emlrtPushRtStackR2012b(&jl_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&wk_emlrtRSI, emlrtRootTLSGlobal); if (b < 1) { n = 0; } else { emlrtPushRtStackR2012b(&xk_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&xk_emlrtRSI, emlrtRootTLSGlobal); n = b; } emlrtPopRtStackR2012b(&wk_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&jl_emlrtRSI, emlrtRootTLSGlobal); yk = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = n; emxEnsureCapacity((emxArray__common *)y, yk, (int32_T)sizeof(int32_T), &mb_emlrtRTEI); if (n > 0) { y->data[0] = 1; yk = 1; emlrtPushRtStackR2012b(&kl_emlrtRSI, emlrtRootTLSGlobal); if (2 > n) { b3 = FALSE; } else { b3 = (n > 2147483646); } if (b3) { emlrtPushRtStackR2012b(&fb_emlrtRSI, emlrtRootTLSGlobal); check_forloop_overflow_error(); emlrtPopRtStackR2012b(&fb_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&kl_emlrtRSI, emlrtRootTLSGlobal); for (k = 2; k <= n; k++) { yk++; y->data[k - 1] = yk; } } }
void diag(const emlrtStack *sp, const emxArray_real_T *v, emxArray_real_T *d) { int32_T unnamed_idx_0; int32_T unnamed_idx_1; int32_T i76; boolean_T overflow; emlrtStack st; emlrtStack b_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; unnamed_idx_0 = v->size[1] + 1; unnamed_idx_1 = v->size[1] + 1; i76 = d->size[0] * d->size[1]; d->size[0] = unnamed_idx_0; emxEnsureCapacity(sp, (emxArray__common *)d, i76, (int32_T)sizeof(real_T), &ib_emlrtRTEI); i76 = d->size[0] * d->size[1]; d->size[1] = unnamed_idx_1; emxEnsureCapacity(sp, (emxArray__common *)d, i76, (int32_T)sizeof(real_T), &ib_emlrtRTEI); unnamed_idx_0 *= unnamed_idx_1; for (i76 = 0; i76 < unnamed_idx_0; i76++) { d->data[i76] = 0.0; } st.site = &lf_emlrtRSI; if (1 > v->size[1]) { overflow = false; } else { overflow = (v->size[1] > 2147483646); } if (overflow) { b_st.site = &ic_emlrtRSI; check_forloop_overflow_error(&b_st); } for (unnamed_idx_0 = 1; unnamed_idx_0 <= v->size[1]; unnamed_idx_0++) { d->data[unnamed_idx_0 + d->size[0] * (unnamed_idx_0 - 1)] = 1.0; } }
/* Function Definitions */ void b_diag(const emlrtStack *sp, const emxArray_real_T *v, emxArray_real_T *d) { int32_T j; int32_T unnamed_idx_1; int32_T i3; boolean_T overflow; emlrtStack st; emlrtStack b_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; j = v->size[0]; unnamed_idx_1 = v->size[0]; i3 = d->size[0] * d->size[1]; d->size[0] = j; emxEnsureCapacity(sp, (emxArray__common *)d, i3, (int32_T)sizeof(real_T), &g_emlrtRTEI); i3 = d->size[0] * d->size[1]; d->size[1] = unnamed_idx_1; emxEnsureCapacity(sp, (emxArray__common *)d, i3, (int32_T)sizeof(real_T), &g_emlrtRTEI); j *= unnamed_idx_1; for (i3 = 0; i3 < j; i3++) { d->data[i3] = 0.0; } st.site = &l_emlrtRSI; if (1 > v->size[0]) { overflow = false; } else { overflow = (v->size[0] > 2147483646); } if (overflow) { b_st.site = &k_emlrtRSI; check_forloop_overflow_error(&b_st); } for (j = 0; j + 1 <= v->size[0]; j++) { d->data[j + d->size[0] * j] = v->data[j]; } }
void c_sqrt(const emlrtStack *sp, emxArray_real_T *x) { boolean_T p; int32_T nx; int32_T k; emlrtStack st; emlrtStack b_st; emlrtStack c_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; p = false; nx = x->size[0] * x->size[1]; for (k = 0; k < nx; k++) { if (p || (x->data[k] < 0.0)) { p = true; } else { p = false; } } if (p) { st.site = &h_emlrtRSI; error(&st); } st.site = &i_emlrtRSI; nx = x->size[0] * x->size[1]; b_st.site = &j_emlrtRSI; if ((!(1 > nx)) && (nx > 2147483646)) { c_st.site = &k_emlrtRSI; check_forloop_overflow_error(&c_st); } for (k = 0; k + 1 <= nx; k++) { x->data[k] = muDoubleScalarSqrt(x->data[k]); } }
void mldivide(const real_T A[289], real_T B[289]) { real_T b_A[289]; int8_T ipiv[17]; int32_T jA; int32_T info; int32_T j; int32_T c; int32_T ix; real_T temp; int32_T jy; real_T s; int32_T b; int32_T b_j; boolean_T b_jA; int32_T ijA; char_T DIAGA; char_T TRANSA; char_T UPLO; char_T SIDE; ptrdiff_t m_t; ptrdiff_t n_t; ptrdiff_t lda_t; ptrdiff_t ldb_t; double * Aia0_t; double * Bib0_t; double * alpha1_t; emlrtPushRtStackR2012b(&pb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&qb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&sb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&vb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&wb_emlrtRSI, emlrtRootTLSGlobal); memcpy(&b_A[0], &A[0], 289U * sizeof(real_T)); for (jA = 0; jA < 17; jA++) { ipiv[jA] = (int8_T)(1 + jA); } info = 0; for (j = 0; j < 16; j++) { c = j * 18; emlrtPushRtStackR2012b(&xb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&bc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&cc_emlrtRSI, emlrtRootTLSGlobal); jA = 1; ix = c; temp = muDoubleScalarAbs(b_A[c]); emlrtPushRtStackR2012b(&dc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&dc_emlrtRSI, emlrtRootTLSGlobal); for (jy = 2; jy <= 17 - j; jy++) { ix++; s = muDoubleScalarAbs(b_A[ix]); if (s > temp) { jA = jy; temp = s; } } emlrtPopRtStackR2012b(&cc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&bc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&xb_emlrtRSI, emlrtRootTLSGlobal); if (b_A[(c + jA) - 1] != 0.0) { if (jA - 1 != 0) { ipiv[j] = (int8_T)(j + jA); eml_xswap(b_A, j + 1, j + jA); } b = (c - j) + 17; emlrtPushRtStackR2012b(&yb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&yb_emlrtRSI, emlrtRootTLSGlobal); for (jA = c + 1; jA + 1 <= b; jA++) { b_A[jA] /= b_A[c]; } } else { info = j + 1; } emlrtPushRtStackR2012b(&ac_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ec_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&fc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&gc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hc_emlrtRSI, emlrtRootTLSGlobal); jA = c; jy = c + 17; emlrtPushRtStackR2012b(&jc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&jc_emlrtRSI, emlrtRootTLSGlobal); for (b_j = 1; b_j <= 16 - j; b_j++) { temp = b_A[jy]; if (b_A[jy] != 0.0) { ix = c + 1; b = (jA - j) + 34; emlrtPushRtStackR2012b(&ic_emlrtRSI, emlrtRootTLSGlobal); if (jA + 19 > b) { b_jA = FALSE; } else { b_jA = (b > 2147483646); } if (b_jA) { emlrtPushRtStackR2012b(&g_emlrtRSI, emlrtRootTLSGlobal); check_forloop_overflow_error(); emlrtPopRtStackR2012b(&g_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&ic_emlrtRSI, emlrtRootTLSGlobal); for (ijA = jA + 18; ijA + 1 <= b; ijA++) { b_A[ijA] += b_A[ix] * -temp; ix++; } } jy += 17; jA += 17; } emlrtPopRtStackR2012b(&hc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&gc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&fc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&ec_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&ac_emlrtRSI, emlrtRootTLSGlobal); } if ((info == 0) && (!(b_A[288] != 0.0))) { info = 17; } emlrtPopRtStackR2012b(&wb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&vb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&sb_emlrtRSI, emlrtRootTLSGlobal); if (info > 0) { emlrtPushRtStackR2012b(&rb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&kc_emlrtRSI, emlrtRootTLSGlobal); eml_warning(); emlrtPopRtStackR2012b(&kc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&rb_emlrtRSI, emlrtRootTLSGlobal); } for (jA = 0; jA < 17; jA++) { if (ipiv[jA] != jA + 1) { for (j = 0; j < 17; j++) { temp = B[jA + 17 * j]; B[jA + 17 * j] = B[(ipiv[jA] + 17 * j) - 1]; B[(ipiv[jA] + 17 * j) - 1] = temp; } } } emlrtPushRtStackR2012b(&tb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&mc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&nc_emlrtRSI, emlrtRootTLSGlobal); temp = 1.0; DIAGA = 'U'; TRANSA = 'N'; UPLO = 'L'; SIDE = 'L'; emlrtPushRtStackR2012b(&oc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); m_t = (ptrdiff_t)(17); emlrtPopRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&oc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&pc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); n_t = (ptrdiff_t)(17); emlrtPopRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&pc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&qc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); lda_t = (ptrdiff_t)(17); emlrtPopRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&qc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&rc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); ldb_t = (ptrdiff_t)(17); emlrtPopRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&rc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&sc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); Aia0_t = (double *)(&b_A[0]); emlrtPopRtStackR2012b(&sc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&tc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); Bib0_t = (double *)(&B[0]); emlrtPopRtStackR2012b(&tc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&uc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); alpha1_t = (double *)(&temp); emlrtPopRtStackR2012b(&uc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&vc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); dtrsm(&SIDE, &UPLO, &TRANSA, &DIAGA, &m_t, &n_t, alpha1_t, Aia0_t, &lda_t, Bib0_t, &ldb_t); emlrtPopRtStackR2012b(&vc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&nc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&mc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&tb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ub_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&mc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&nc_emlrtRSI, emlrtRootTLSGlobal); temp = 1.0; DIAGA = 'N'; TRANSA = 'N'; UPLO = 'U'; SIDE = 'L'; emlrtPushRtStackR2012b(&oc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); m_t = (ptrdiff_t)(17); emlrtPopRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&oc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&pc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); n_t = (ptrdiff_t)(17); emlrtPopRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&pc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&qc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); lda_t = (ptrdiff_t)(17); emlrtPopRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&qc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&rc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); ldb_t = (ptrdiff_t)(17); emlrtPopRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&rc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&sc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); Aia0_t = (double *)(&b_A[0]); emlrtPopRtStackR2012b(&sc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&tc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); Bib0_t = (double *)(&B[0]); emlrtPopRtStackR2012b(&tc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&uc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); alpha1_t = (double *)(&temp); emlrtPopRtStackR2012b(&uc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&vc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); dtrsm(&SIDE, &UPLO, &TRANSA, &DIAGA, &m_t, &n_t, alpha1_t, Aia0_t, &lda_t, Bib0_t, &ldb_t); emlrtPopRtStackR2012b(&vc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&nc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&mc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&ub_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&qb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&pb_emlrtRSI, emlrtRootTLSGlobal); }
/* Function Definitions */ void bsxfun(const emlrtStack *sp, const emxArray_real_T *a, const emxArray_real_T *b, emxArray_real_T *c) { int32_T na1; boolean_T overflow; int32_T b_c; int32_T i0; int32_T a_idx_0; emxArray_real_T *av; int32_T k; int32_T asub; int32_T bsub; int32_T ak; int32_T bk; int32_T ck; emxArray_real_T *cv; boolean_T b1; real_T b_b; emlrtStack st; emlrtStack b_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; emlrtHeapReferenceStackEnterFcnR2012b(sp); na1 = a->size[0]; if ((a->size[1] != 1) && (b->size[1] != 1) && (a->size[1] != b->size[1])) { overflow = false; } else { overflow = true; } if (overflow) { } else { emlrtErrorWithMessageIdR2012b(sp, &n_emlrtRTEI, "MATLAB:bsxfun:arrayDimensionsMustMatch", 0); } overflow = !(a->size[1] != b->size[1]); if (overflow) { } else { emlrtErrorWithMessageIdR2012b(sp, &m_emlrtRTEI, "Coder:toolbox:bsxfun_dynamicExpansion", 0); } if (a->size[1] <= b->size[1]) { b_c = a->size[1]; } else { b_c = b->size[1]; } i0 = c->size[0] * c->size[1]; c->size[0] = a->size[0]; c->size[1] = b_c; emxEnsureCapacity(sp, (emxArray__common *)c, i0, (int32_T)sizeof(real_T), &g_emlrtRTEI); a_idx_0 = a->size[0]; if ((a_idx_0 == 0) || (b_c == 0)) { } else { b_emxInit_real_T(sp, &av, 1, &h_emlrtRTEI, true); k = a->size[0]; i0 = av->size[0]; av->size[0] = k; emxEnsureCapacity(sp, (emxArray__common *)av, i0, (int32_T)sizeof(real_T), &g_emlrtRTEI); asub = 1; bsub = 1; ak = 0; bk = 0; a_idx_0 = a->size[0]; ck = a->size[0]; k = a->size[0]; b_c = ck * b_c - k; st.site = &d_emlrtRSI; ck = a->size[0]; if ((ck == 0) || (0 > b_c)) { overflow = false; } else { ck = a->size[0]; overflow = (b_c > MAX_int32_T - ck); } if (overflow) { b_st.site = &g_emlrtRSI; check_forloop_overflow_error(&b_st); } ck = 0; b_emxInit_real_T(sp, &cv, 1, &i_emlrtRTEI, true); while ((a_idx_0 > 0) && (ck <= b_c)) { st.site = &e_emlrtRSI; if (1 > na1) { b1 = false; } else { b1 = (na1 > 2147483646); } if (b1) { b_st.site = &g_emlrtRSI; check_forloop_overflow_error(&b_st); } for (k = 0; k + 1 <= na1; k++) { av->data[k] = a->data[ak + k]; } b_b = b->data[bk]; i0 = cv->size[0]; cv->size[0] = av->size[0]; emxEnsureCapacity(sp, (emxArray__common *)cv, i0, (int32_T)sizeof(real_T), &g_emlrtRTEI); k = av->size[0]; for (i0 = 0; i0 < k; i0++) { cv->data[i0] = av->data[i0] - b_b; } st.site = &f_emlrtRSI; if (a_idx_0 > 2147483646) { b_st.site = &g_emlrtRSI; check_forloop_overflow_error(&b_st); } for (k = 0; k + 1 <= a_idx_0; k++) { c->data[ck + k] = cv->data[k]; } if (asub < a->size[1]) { ak += na1; bk++; bsub++; asub++; } else if (bsub < b->size[1]) { bk++; bsub++; } else { asub = 1; bsub = 1; } ck += a_idx_0; } emxFree_real_T(&cv); emxFree_real_T(&av); } emlrtHeapReferenceStackLeaveFcnR2012b(sp); }
/* Function Definitions */ boolean_T all(const emlrtStack *sp, const emxArray_boolean_T *x) { boolean_T y; boolean_T overflow; const mxArray *b_y; static const int32_T iv20[2] = { 1, 51 }; const mxArray *m7; char_T cv22[51]; int32_T i; static const char_T cv23[51] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 'e', 'm', 'l', '_', 'a', 'l', 'l', '_', 'o', 'r', '_', 'a', 'n', 'y', '_', 'a', 'u', 't', 'o', 'D', 'i', 'm', 'I', 'n', 'c', 'o', 'm', 'p', 'a', 't', 'i', 'b', 'i', 'l', 'i', 't', 'y' }; boolean_T exitg1; int32_T i66; emlrtStack st; emlrtStack b_st; emlrtStack c_st; st.prev = sp; st.tls = sp->tls; st.site = &ve_emlrtRSI; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; b_st.site = &we_emlrtRSI; if ((x->size[1] == 1) || (x->size[1] != 1)) { overflow = true; } else { overflow = false; } b_st.site = &xe_emlrtRSI; if (overflow) { } else { b_y = NULL; m7 = emlrtCreateCharArray(2, iv20); for (i = 0; i < 51; i++) { cv22[i] = cv23[i]; } emlrtInitCharArrayR2013a(&b_st, 51, m7, cv22); emlrtAssign(&b_y, m7); c_st.site = &dh_emlrtRSI; b_error(&c_st, message(&c_st, b_y, &n_emlrtMCI), &n_emlrtMCI); } y = true; b_st.site = &ye_emlrtRSI; if (1 > x->size[1]) { overflow = false; } else { overflow = (x->size[1] > 2147483646); } if (overflow) { c_st.site = &ic_emlrtRSI; check_forloop_overflow_error(&c_st); } i = 1; exitg1 = false; while ((!exitg1) && (i <= x->size[1])) { i66 = x->size[1]; if (x->data[emlrtDynamicBoundsCheckFastR2012b(i, 1, i66, &re_emlrtBCI, &st) - 1] == 0) { y = false; exitg1 = true; } else { i++; } } return y; }
/* Function Definitions */ void any(const emxArray_boolean_T *x, emxArray_boolean_T *y) { boolean_T overflow; boolean_T p; int32_T i; int32_T exitg2; const mxArray *b_y; static const int32_T iv33[2] = { 1, 41 }; const mxArray *m9; char_T cv35[41]; static const char_T cv36[41] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 'e', 'm', 'l', '_', 'a', 'l', 'l', '_', 'o', 'r', '_', 'a', 'n', 'y', '_', 's', 'p', 'e', 'c', 'i', 'a', 'l', 'E', 'm', 'p', 't', 'y' }; const mxArray *c_y; static const int32_T iv34[2] = { 1, 51 }; char_T cv37[51]; static const char_T cv38[51] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 'e', 'm', 'l', '_', 'a', 'l', 'l', '_', 'o', 'r', '_', 'a', 'n', 'y', '_', 'a', 'u', 't', 'o', 'D', 'i', 'm', 'I', 'n', 'c', 'o', 'm', 'p', 'a', 't', 'i', 'b', 'i', 'l', 'i', 't', 'y' }; uint32_T outsize[2]; int32_T i2; int32_T iy; int32_T i1; boolean_T b_i1; boolean_T exitg1; emlrtPushRtStackR2012b(&gj_emlrtRSI, emlrtRootTLSGlobal); overflow = FALSE; p = FALSE; i = 0; do { exitg2 = 0; if (i < 2) { if (x->size[i] != 0) { exitg2 = 1; } else { i++; } } else { p = TRUE; exitg2 = 1; } } while (exitg2 == 0); if (!p) { } else { overflow = TRUE; } if (!overflow) { } else { emlrtPushRtStackR2012b(&hj_emlrtRSI, emlrtRootTLSGlobal); emlrt_synchGlobalsToML(); b_y = NULL; m9 = mxCreateCharArray(2, iv33); for (i = 0; i < 41; i++) { cv35[i] = cv36[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 41, m9, cv35); emlrtAssign(&b_y, m9); error(message(b_y, &bb_emlrtMCI), &cb_emlrtMCI); emlrt_synchGlobalsFromML(); emlrtPopRtStackR2012b(&hj_emlrtRSI, emlrtRootTLSGlobal); } if (((x->size[0] == 1) && (x->size[1] == 1)) || (x->size[0] != 1)) { overflow = TRUE; } else { overflow = FALSE; } if (overflow) { } else { emlrtPushRtStackR2012b(&ij_emlrtRSI, emlrtRootTLSGlobal); emlrt_synchGlobalsToML(); c_y = NULL; m9 = mxCreateCharArray(2, iv34); for (i = 0; i < 51; i++) { cv37[i] = cv38[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 51, m9, cv37); emlrtAssign(&c_y, m9); error(message(c_y, &db_emlrtMCI), &eb_emlrtMCI); emlrt_synchGlobalsFromML(); emlrtPopRtStackR2012b(&ij_emlrtRSI, emlrtRootTLSGlobal); } for (i = 0; i < 2; i++) { outsize[i] = (uint32_T)x->size[i]; } i = y->size[0] * y->size[1]; y->size[0] = 1; emxEnsureCapacity((emxArray__common *)y, i, (int32_T)sizeof(boolean_T), &hb_emlrtRTEI); i = y->size[0] * y->size[1]; y->size[1] = (int32_T)outsize[1]; emxEnsureCapacity((emxArray__common *)y, i, (int32_T)sizeof(boolean_T), &hb_emlrtRTEI); i2 = (int32_T)outsize[1]; for (i = 0; i < i2; i++) { y->data[i] = FALSE; } i2 = 0; iy = -1; emlrtPushRtStackR2012b(&oj_emlrtRSI, emlrtRootTLSGlobal); if (1 > x->size[1]) { overflow = FALSE; } else { overflow = (x->size[1] > 2147483646); } if (overflow) { emlrtPushRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal); check_forloop_overflow_error(); emlrtPopRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&oj_emlrtRSI, emlrtRootTLSGlobal); for (i = 1; i <= x->size[1]; i++) { i1 = i2 + 1; i2 += x->size[0]; iy++; emlrtPushRtStackR2012b(&jj_emlrtRSI, emlrtRootTLSGlobal); if (i1 > i2) { b_i1 = FALSE; } else { b_i1 = (i2 > 2147483646); } if (b_i1) { emlrtPushRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal); check_forloop_overflow_error(); emlrtPopRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&jj_emlrtRSI, emlrtRootTLSGlobal); exitg1 = FALSE; while ((exitg1 == FALSE) && (i1 <= i2)) { overflow = (x->data[i1 - 1] == 0); if (!overflow) { y->data[iy] = TRUE; exitg1 = TRUE; } else { i1++; } } } emlrtPopRtStackR2012b(&gj_emlrtRSI, emlrtRootTLSGlobal); }
/* Function Definitions */ void compmat(const emlrtStack *sp, const emxArray_uint8_T *x, real_T dims, emxArray_real_T *y) { int32_T i1; real_T d3; int32_T ii; int32_T i; emxArray_boolean_T *b_x; emxArray_int32_T *b_ii; int32_T nx; int32_T idx; boolean_T overflow; boolean_T exitg1; boolean_T guard1 = false; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; d_st.prev = &c_st; d_st.tls = c_st.tls; emlrtHeapReferenceStackEnterFcnR2012b(sp); /* UNTITLED Summary of this function goes here */ /* Detailed explanation goes here */ i1 = y->size[0] * y->size[1]; y->size[0] = 1; if (!(dims >= 0.0)) { emlrtNonNegativeCheckR2012b(dims, (emlrtDCInfo *)&j_emlrtDCI, sp); } d3 = dims; if (d3 != (int32_T)muDoubleScalarFloor(d3)) { emlrtIntegerCheckR2012b(d3, (emlrtDCInfo *)&i_emlrtDCI, sp); } y->size[1] = (int32_T)d3; emxEnsureCapacity(sp, (emxArray__common *)y, i1, (int32_T)sizeof(real_T), &f_emlrtRTEI); if (!(dims >= 0.0)) { emlrtNonNegativeCheckR2012b(dims, (emlrtDCInfo *)&j_emlrtDCI, sp); } if (d3 != (int32_T)muDoubleScalarFloor(d3)) { emlrtIntegerCheckR2012b(d3, (emlrtDCInfo *)&i_emlrtDCI, sp); } ii = (int32_T)d3; for (i1 = 0; i1 < ii; i1++) { y->data[i1] = 0.0; } emlrtForLoopVectorCheckR2012b(1.0, 1.0, dims, mxDOUBLE_CLASS, (int32_T)dims, (emlrtRTEInfo *)&n_emlrtRTEI, sp); i = 0; emxInit_boolean_T(sp, &b_x, 2, &f_emlrtRTEI, true); emxInit_int32_T(sp, &b_ii, 2, &g_emlrtRTEI, true); while (i <= (int32_T)dims - 1) { st.site = &k_emlrtRSI; i1 = b_x->size[0] * b_x->size[1]; b_x->size[0] = 1; b_x->size[1] = x->size[1]; emxEnsureCapacity(&st, (emxArray__common *)b_x, i1, (int32_T)sizeof (boolean_T), &f_emlrtRTEI); ii = x->size[0] * x->size[1]; for (i1 = 0; i1 < ii; i1++) { b_x->data[i1] = (x->data[i1] == 1.0 + (real_T)i); } b_st.site = &h_emlrtRSI; nx = b_x->size[1]; idx = 0; i1 = b_ii->size[0] * b_ii->size[1]; b_ii->size[0] = 1; b_ii->size[1] = b_x->size[1]; emxEnsureCapacity(&b_st, (emxArray__common *)b_ii, i1, (int32_T)sizeof (int32_T), &f_emlrtRTEI); c_st.site = &i_emlrtRSI; overflow = ((!(1 > b_x->size[1])) && (b_x->size[1] > 2147483646)); if (overflow) { d_st.site = &j_emlrtRSI; check_forloop_overflow_error(&d_st); } ii = 1; exitg1 = false; while ((!exitg1) && (ii <= nx)) { guard1 = false; if (b_x->data[ii - 1]) { idx++; b_ii->data[idx - 1] = ii; if (idx >= nx) { exitg1 = true; } else { guard1 = true; } } else { guard1 = true; } if (guard1) { ii++; } } if (idx <= b_x->size[1]) { } else { emlrtErrorWithMessageIdR2012b(&b_st, &k_emlrtRTEI, "Coder:builtins:AssertionFailed", 0); } if (b_x->size[1] == 1) { if (idx == 0) { i1 = b_ii->size[0] * b_ii->size[1]; b_ii->size[0] = 1; b_ii->size[1] = 0; emxEnsureCapacity(&b_st, (emxArray__common *)b_ii, i1, (int32_T)sizeof (int32_T), &f_emlrtRTEI); } } else { i1 = b_ii->size[0] * b_ii->size[1]; if (1 > idx) { b_ii->size[1] = 0; } else { b_ii->size[1] = idx; } emxEnsureCapacity(&b_st, (emxArray__common *)b_ii, i1, (int32_T)sizeof (int32_T), &b_emlrtRTEI); } i1 = y->size[1]; if (!((i + 1 >= 1) && (i + 1 <= i1))) { emlrtDynamicBoundsCheckR2012b(i + 1, 1, i1, (emlrtBCInfo *)&w_emlrtBCI, sp); } y->data[i] = b_ii->size[1]; i++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } emxFree_int32_T(&b_ii); emxFree_boolean_T(&b_x); emlrtHeapReferenceStackLeaveFcnR2012b(sp); }
/* Function Definitions */ static void b_eml_lusolve(const emlrtStack *sp, const emxArray_real_T *A, emxArray_real_T *B) { emxArray_real_T *b_A; int32_T i58; int32_T iy; emxArray_int32_T *ipiv; int32_T info; int32_T i59; int32_T b; int32_T j; int32_T mmj; int32_T c; ptrdiff_t n_t; ptrdiff_t incx_t; double * xix0_t; int32_T ix; boolean_T overflow; int32_T k; real_T temp; int32_T i60; boolean_T b_c; ptrdiff_t m_t; ptrdiff_t incy_t; ptrdiff_t lda_t; double * alpha1_t; double * Aia0_t; double * Aiy0_t; char_T DIAGA; char_T TRANSA; char_T UPLO; char_T SIDE; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; emlrtStack e_st; emlrtStack f_st; emlrtStack g_st; emlrtStack h_st; emlrtStack i_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; d_st.prev = &c_st; d_st.tls = c_st.tls; e_st.prev = &d_st; e_st.tls = d_st.tls; f_st.prev = &e_st; f_st.tls = e_st.tls; g_st.prev = &f_st; g_st.tls = f_st.tls; h_st.prev = &g_st; h_st.tls = g_st.tls; i_st.prev = &h_st; i_st.tls = h_st.tls; emlrtHeapReferenceStackEnterFcnR2012b(sp); emxInit_real_T(sp, &b_A, 2, &ob_emlrtRTEI, true); st.site = &ib_emlrtRSI; b_st.site = &lb_emlrtRSI; c_st.site = &nb_emlrtRSI; d_st.site = &ob_emlrtRSI; i58 = b_A->size[0] * b_A->size[1]; b_A->size[0] = A->size[0]; b_A->size[1] = A->size[1]; emxEnsureCapacity(&d_st, (emxArray__common *)b_A, i58, (int32_T)sizeof(real_T), &ob_emlrtRTEI); iy = A->size[0] * A->size[1]; for (i58 = 0; i58 < iy; i58++) { b_A->data[i58] = A->data[i58]; } b_emxInit_int32_T(&d_st, &ipiv, 2, &ob_emlrtRTEI, true); e_st.site = &qb_emlrtRSI; f_st.site = &rb_emlrtRSI; g_st.site = &sb_emlrtRSI; h_st.site = &tb_emlrtRSI; eml_signed_integer_colon(&h_st, muIntScalarMin_sint32(A->size[1], A->size[1]), ipiv); info = 0; if (A->size[1] < 1) { } else { i59 = A->size[1] - 1; b = muIntScalarMin_sint32(i59, A->size[1]); e_st.site = &pb_emlrtRSI; for (j = 1; j <= b; j++) { mmj = A->size[1] - j; c = (j - 1) * (A->size[1] + 1) + 1; e_st.site = &if_emlrtRSI; f_st.site = &yb_emlrtRSI; if (mmj + 1 < 1) { iy = -1; } else { g_st.site = &ac_emlrtRSI; h_st.site = &ac_emlrtRSI; n_t = (ptrdiff_t)(mmj + 1); h_st.site = &ac_emlrtRSI; incx_t = (ptrdiff_t)(1); i58 = b_A->size[0] * b_A->size[1]; xix0_t = (double *)(&b_A->data[emlrtDynamicBoundsCheckFastR2012b(c, 1, i58, &je_emlrtBCI, &g_st) - 1]); incx_t = idamax(&n_t, xix0_t, &incx_t); iy = (int32_T)incx_t - 1; } if (b_A->data[(c + iy) - 1] != 0.0) { if (iy != 0) { ipiv->data[j - 1] = j + iy; e_st.site = &jf_emlrtRSI; f_st.site = &bc_emlrtRSI; g_st.site = &cc_emlrtRSI; ix = j; iy += j; h_st.site = &dc_emlrtRSI; overflow = (A->size[1] > 2147483646); if (overflow) { i_st.site = &db_emlrtRSI; check_forloop_overflow_error(&i_st); } for (k = 1; k <= A->size[1]; k++) { i58 = b_A->size[0] * b_A->size[1]; temp = b_A->data[emlrtDynamicBoundsCheckFastR2012b(ix, 1, i58, &le_emlrtBCI, &g_st) - 1]; i58 = b_A->size[0] * b_A->size[1]; i60 = b_A->size[0] * b_A->size[1]; b_A->data[emlrtDynamicBoundsCheckFastR2012b(ix, 1, i58, &le_emlrtBCI, &g_st) - 1] = b_A->data[emlrtDynamicBoundsCheckFastR2012b(iy, 1, i60, &le_emlrtBCI, &g_st) - 1]; i58 = b_A->size[0] * b_A->size[1]; b_A->data[emlrtDynamicBoundsCheckFastR2012b(iy, 1, i58, &le_emlrtBCI, &g_st) - 1] = temp; ix += A->size[1]; iy += A->size[1]; } } iy = c + mmj; e_st.site = &kf_emlrtRSI; if (c + 1 > iy) { b_c = false; } else { b_c = (iy > 2147483646); } if (b_c) { f_st.site = &db_emlrtRSI; check_forloop_overflow_error(&f_st); } for (k = c; k + 1 <= iy; k++) { b_A->data[k] /= b_A->data[c - 1]; } } else { info = j; } iy = A->size[1] - j; e_st.site = &lf_emlrtRSI; f_st.site = &ec_emlrtRSI; g_st.site = &fc_emlrtRSI; if ((mmj < 1) || (iy < 1)) { } else { h_st.site = &gc_emlrtRSI; temp = -1.0; m_t = (ptrdiff_t)(mmj); n_t = (ptrdiff_t)(iy); incx_t = (ptrdiff_t)(1); incy_t = (ptrdiff_t)(A->size[1]); lda_t = (ptrdiff_t)(A->size[1]); alpha1_t = (double *)(&temp); i58 = b_A->size[0] * b_A->size[1]; i60 = (c + A->size[1]) + 1; Aia0_t = (double *)(&b_A->data[emlrtDynamicBoundsCheckFastR2012b(i60, 1, i58, &ke_emlrtBCI, &h_st) - 1]); i58 = b_A->size[0] * b_A->size[1]; xix0_t = (double *)(&b_A->data[emlrtDynamicBoundsCheckFastR2012b(c + 1, 1, i58, &ke_emlrtBCI, &h_st) - 1]); i58 = b_A->size[0] * b_A->size[1]; i60 = c + A->size[1]; Aiy0_t = (double *)(&b_A->data[emlrtDynamicBoundsCheckFastR2012b(i60, 1, i58, &ke_emlrtBCI, &h_st) - 1]); dger(&m_t, &n_t, alpha1_t, xix0_t, &incx_t, Aiy0_t, &incy_t, Aia0_t, &lda_t); } } if ((info == 0) && (!(b_A->data[(A->size[1] + b_A->size[0] * (A->size[1] - 1)) - 1] != 0.0))) { info = A->size[1]; } } if (info > 0) { b_st.site = &mb_emlrtRSI; warn_singular(&b_st); } b_st.site = &yf_emlrtRSI; for (iy = 0; iy + 1 < A->size[1]; iy++) { if (ipiv->data[iy] != iy + 1) { temp = B->data[iy]; B->data[iy] = B->data[ipiv->data[iy] - 1]; B->data[ipiv->data[iy] - 1] = temp; } } emxFree_int32_T(&ipiv); b_st.site = &ag_emlrtRSI; c_st.site = &ic_emlrtRSI; if (A->size[1] < 1) { } else { d_st.site = &jc_emlrtRSI; temp = 1.0; DIAGA = 'U'; TRANSA = 'N'; UPLO = 'L'; SIDE = 'L'; e_st.site = &jc_emlrtRSI; m_t = (ptrdiff_t)(A->size[1]); e_st.site = &jc_emlrtRSI; n_t = (ptrdiff_t)(1); e_st.site = &jc_emlrtRSI; lda_t = (ptrdiff_t)(A->size[1]); e_st.site = &jc_emlrtRSI; incx_t = (ptrdiff_t)(A->size[1]); i58 = b_A->size[0] * b_A->size[1]; emlrtDynamicBoundsCheckFastR2012b(1, 1, i58, &ie_emlrtBCI, &d_st); Aia0_t = (double *)(&b_A->data[0]); xix0_t = (double *)(&B->data[0]); alpha1_t = (double *)(&temp); dtrsm(&SIDE, &UPLO, &TRANSA, &DIAGA, &m_t, &n_t, alpha1_t, Aia0_t, &lda_t, xix0_t, &incx_t); } b_st.site = &bg_emlrtRSI; c_st.site = &ic_emlrtRSI; if (A->size[1] < 1) { } else { d_st.site = &jc_emlrtRSI; temp = 1.0; DIAGA = 'N'; TRANSA = 'N'; UPLO = 'U'; SIDE = 'L'; e_st.site = &jc_emlrtRSI; m_t = (ptrdiff_t)(A->size[1]); e_st.site = &jc_emlrtRSI; n_t = (ptrdiff_t)(1); e_st.site = &jc_emlrtRSI; lda_t = (ptrdiff_t)(A->size[1]); e_st.site = &jc_emlrtRSI; incx_t = (ptrdiff_t)(A->size[1]); i58 = b_A->size[0] * b_A->size[1]; emlrtDynamicBoundsCheckFastR2012b(1, 1, i58, &ie_emlrtBCI, &d_st); Aia0_t = (double *)(&b_A->data[0]); xix0_t = (double *)(&B->data[0]); alpha1_t = (double *)(&temp); dtrsm(&SIDE, &UPLO, &TRANSA, &DIAGA, &m_t, &n_t, alpha1_t, Aia0_t, &lda_t, xix0_t, &incx_t); } emxFree_real_T(&b_A); emlrtHeapReferenceStackLeaveFcnR2012b(sp); }
/* Function Definitions */ void repmat(const real_T a_data[2201], const int32_T a_size[2], real_T m, emxArray_real_T *b) { boolean_T p; const mxArray *y; static const int32_T iv27[2] = { 1, 28 }; const mxArray *m7; char_T cv27[28]; int32_T i; static const char_T cv28[28] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T', 'L', 'A', 'B', ':', 'N', 'o', 'n', 'I', 'n', 't', 'e', 'g', 'e', 'r', 'I', 'n', 'p', 'u', 't' }; real_T b_m; const mxArray *b_y; static const int32_T iv28[2] = { 1, 21 }; char_T cv29[21]; static const char_T cv30[21] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T', 'L', 'A', 'B', ':', 'p', 'm', 'a', 'x', 's', 'i', 'z', 'e' }; int32_T mv[2]; int32_T outsize[2]; int32_T ib; int32_T iacol; int32_T jcol; boolean_T b2; int32_T itilerow; emlrtPushRtStackR2012b(&ki_emlrtRSI, emlrtRootTLSGlobal); if ((m != m) || muDoubleScalarIsInf(m)) { p = FALSE; } else { p = TRUE; } if (p) { } else { emlrtPushRtStackR2012b(&oi_emlrtRSI, emlrtRootTLSGlobal); emlrt_synchGlobalsToML(); y = NULL; m7 = mxCreateCharArray(2, iv27); for (i = 0; i < 28; i++) { cv27[i] = cv28[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 28, m7, cv27); emlrtAssign(&y, m7); error(message(y, &s_emlrtMCI), &t_emlrtMCI); emlrt_synchGlobalsFromML(); emlrtPopRtStackR2012b(&oi_emlrtRSI, emlrtRootTLSGlobal); } if (m <= 0.0) { b_m = 0.0; } else { b_m = m; } if (2.147483647E+9 >= b_m) { } else { emlrtPushRtStackR2012b(&pi_emlrtRSI, emlrtRootTLSGlobal); emlrt_synchGlobalsToML(); b_y = NULL; m7 = mxCreateCharArray(2, iv28); for (i = 0; i < 21; i++) { cv29[i] = cv30[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m7, cv29); emlrtAssign(&b_y, m7); error(message(b_y, &u_emlrtMCI), &v_emlrtMCI); emlrt_synchGlobalsFromML(); emlrtPopRtStackR2012b(&pi_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&ki_emlrtRSI, emlrtRootTLSGlobal); mv[0] = (int32_T)m; mv[1] = 1; for (i = 0; i < 2; i++) { outsize[i] = a_size[i] * mv[i]; } i = b->size[0] * b->size[1]; b->size[0] = outsize[0]; b->size[1] = outsize[1]; emxEnsureCapacity((emxArray__common *)b, i, (int32_T)sizeof(real_T), &y_emlrtRTEI); if (outsize[0] == 0) { } else { i = 0; ib = 0; emlrtPushRtStackR2012b(&li_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&li_emlrtRSI, emlrtRootTLSGlobal); iacol = 0; emlrtPushRtStackR2012b(&mi_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&mi_emlrtRSI, emlrtRootTLSGlobal); for (jcol = 1; jcol <= a_size[1]; jcol++) { emlrtPushRtStackR2012b(&ni_emlrtRSI, emlrtRootTLSGlobal); if (1 > (int32_T)m) { b2 = FALSE; } else { b2 = ((int32_T)m > 2147483646); } if (b2) { emlrtPushRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal); check_forloop_overflow_error(); emlrtPopRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&ni_emlrtRSI, emlrtRootTLSGlobal); for (itilerow = 1; itilerow <= (int32_T)m; itilerow++) { b->data[ib] = a_data[iacol]; i = iacol + 1; ib++; } iacol = i; } } }
/* Function Definitions */ void occflow(const emlrtStack *sp, const emxArray_real_T *cgridvec, emxArray_real_T *cgridvecprev, emxArray_real_T *context, const emxArray_real_T *nei_idx, const emxArray_real_T *nei_weight, real_T nei_filter_n, const emxArray_real_T *nei4u_idx, const emxArray_real_T *nei4u_weight, real_T nei4u_filter_n, real_T occval, real_T minthreshold, real_T maxthreshold, real_T reinitval, real_T intensifyrate, real_T nocc_attenuaterate, real_T unknown_attenuaterate, real_T sigm_coef, real_T do_attenuation_first, emxArray_real_T *predvec, emxArray_real_T *maxvec) { emxArray_boolean_T *x; int32_T ix; int32_T idx; emxArray_boolean_T *r0; int32_T nx; emxArray_int32_T *ii; boolean_T overflow; int32_T iy; boolean_T exitg6; boolean_T guard3 = false; boolean_T guard4 = false; emxArray_real_T *newlyoccidx; boolean_T exitg5; boolean_T guard2 = false; boolean_T b_guard3 = false; emxArray_real_T *occidx; boolean_T exitg4; boolean_T guard1 = false; boolean_T b_guard2 = false; emxArray_real_T *noccidx; int32_T nrnocc; int32_T j; emxArray_real_T *curr_col; emxArray_real_T *updt_col; emxArray_real_T *z; int32_T coccidx; boolean_T b_guard1 = false; int32_T ixstart; int32_T n; real_T mtmp; boolean_T exitg3; int32_T varargin_1[2]; int32_T k; int32_T iv3[2]; int32_T iv4[2]; real_T d0; emxArray_real_T *tempcontext; emxArray_real_T *b_nei4u_weight; real_T sumval; int32_T m; int32_T iv5[2]; boolean_T b_ix; boolean_T exitg2; boolean_T b_ixstart; int32_T varargin_2[2]; boolean_T p; boolean_T exitg1; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; emlrtStack e_st; emlrtStack f_st; (void)unknown_attenuaterate; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; d_st.prev = &c_st; d_st.tls = c_st.tls; e_st.prev = &d_st; e_st.tls = d_st.tls; f_st.prev = &e_st; f_st.tls = e_st.tls; emlrtHeapReferenceStackEnterFcnR2012b(sp); emxInit_boolean_T(sp, &x, 1, &emlrtRTEI, true); /* */ /* Occupancy flow with vector input */ /* */ /* Compute indices first */ ix = x->size[0]; x->size[0] = cgridvec->size[0]; emxEnsureCapacity(sp, (emxArray__common *)x, ix, (int32_T)sizeof(boolean_T), &emlrtRTEI); idx = cgridvec->size[0]; for (ix = 0; ix < idx; ix++) { x->data[ix] = (cgridvec->data[ix] == occval); } emxInit_boolean_T(sp, &r0, 1, &emlrtRTEI, true); ix = r0->size[0]; r0->size[0] = cgridvecprev->size[0]; emxEnsureCapacity(sp, (emxArray__common *)r0, ix, (int32_T)sizeof(boolean_T), &emlrtRTEI); idx = cgridvecprev->size[0]; for (ix = 0; ix < idx; ix++) { r0->data[ix] = (cgridvecprev->data[ix] != occval); } ix = x->size[0]; nx = r0->size[0]; if (ix != nx) { emlrtSizeEqCheck1DR2012b(ix, nx, &emlrtECI, sp); } st.site = &emlrtRSI; ix = x->size[0]; emxEnsureCapacity(&st, (emxArray__common *)x, ix, (int32_T)sizeof(boolean_T), &emlrtRTEI); idx = x->size[0]; for (ix = 0; ix < idx; ix++) { x->data[ix] = (x->data[ix] && r0->data[ix]); } emxFree_boolean_T(&r0); emxInit_int32_T(&st, &ii, 1, &l_emlrtRTEI, true); b_st.site = &i_emlrtRSI; nx = x->size[0]; idx = 0; ix = ii->size[0]; ii->size[0] = x->size[0]; emxEnsureCapacity(&b_st, (emxArray__common *)ii, ix, (int32_T)sizeof(int32_T), &emlrtRTEI); c_st.site = &j_emlrtRSI; if (1 > x->size[0]) { overflow = false; } else { overflow = (x->size[0] > 2147483646); } if (overflow) { d_st.site = &l_emlrtRSI; check_forloop_overflow_error(&d_st); } iy = 1; exitg6 = false; while ((!exitg6) && (iy <= nx)) { guard3 = false; if (x->data[iy - 1]) { idx++; ii->data[idx - 1] = iy; if (idx >= nx) { exitg6 = true; } else { guard3 = true; } } else { guard3 = true; } if (guard3) { iy++; } } if (idx <= x->size[0]) { } else { emlrtErrorWithMessageIdR2012b(&b_st, &s_emlrtRTEI, "Coder:builtins:AssertionFailed", 0); } if (x->size[0] == 1) { if (idx == 0) { ix = ii->size[0]; ii->size[0] = 0; emxEnsureCapacity(&b_st, (emxArray__common *)ii, ix, (int32_T)sizeof (int32_T), &emlrtRTEI); } } else { if (1 > idx) { ix = 0; } else { ix = idx; } c_st.site = &k_emlrtRSI; overflow = !(ii->size[0] != 1); guard4 = false; if (overflow) { overflow = false; if (ix != 1) { overflow = true; } if (overflow) { overflow = true; } else { guard4 = true; } } else { guard4 = true; } if (guard4) { overflow = false; } d_st.site = &m_emlrtRSI; if (!overflow) { } else { emlrtErrorWithMessageIdR2012b(&d_st, &t_emlrtRTEI, "Coder:FE:PotentialVectorVector", 0); } nx = ii->size[0]; ii->size[0] = ix; emxEnsureCapacity(&b_st, (emxArray__common *)ii, nx, (int32_T)sizeof(int32_T), &c_emlrtRTEI); } emxInit_real_T(&b_st, &newlyoccidx, 1, &f_emlrtRTEI, true); ix = newlyoccidx->size[0]; newlyoccidx->size[0] = ii->size[0]; emxEnsureCapacity(&st, (emxArray__common *)newlyoccidx, ix, (int32_T)sizeof (real_T), &emlrtRTEI); idx = ii->size[0]; for (ix = 0; ix < idx; ix++) { newlyoccidx->data[ix] = ii->data[ix]; } st.site = &b_emlrtRSI; ix = x->size[0]; x->size[0] = cgridvec->size[0]; emxEnsureCapacity(&st, (emxArray__common *)x, ix, (int32_T)sizeof(boolean_T), &emlrtRTEI); idx = cgridvec->size[0]; for (ix = 0; ix < idx; ix++) { x->data[ix] = (cgridvec->data[ix] == occval); } b_st.site = &i_emlrtRSI; nx = x->size[0]; idx = 0; ix = ii->size[0]; ii->size[0] = x->size[0]; emxEnsureCapacity(&b_st, (emxArray__common *)ii, ix, (int32_T)sizeof(int32_T), &emlrtRTEI); c_st.site = &j_emlrtRSI; if (1 > x->size[0]) { overflow = false; } else { overflow = (x->size[0] > 2147483646); } if (overflow) { d_st.site = &l_emlrtRSI; check_forloop_overflow_error(&d_st); } iy = 1; exitg5 = false; while ((!exitg5) && (iy <= nx)) { guard2 = false; if (x->data[iy - 1]) { idx++; ii->data[idx - 1] = iy; if (idx >= nx) { exitg5 = true; } else { guard2 = true; } } else { guard2 = true; } if (guard2) { iy++; } } if (idx <= x->size[0]) { } else { emlrtErrorWithMessageIdR2012b(&b_st, &s_emlrtRTEI, "Coder:builtins:AssertionFailed", 0); } if (x->size[0] == 1) { if (idx == 0) { ix = ii->size[0]; ii->size[0] = 0; emxEnsureCapacity(&b_st, (emxArray__common *)ii, ix, (int32_T)sizeof (int32_T), &emlrtRTEI); } } else { if (1 > idx) { ix = 0; } else { ix = idx; } c_st.site = &k_emlrtRSI; overflow = !(ii->size[0] != 1); b_guard3 = false; if (overflow) { overflow = false; if (ix != 1) { overflow = true; } if (overflow) { overflow = true; } else { b_guard3 = true; } } else { b_guard3 = true; } if (b_guard3) { overflow = false; } d_st.site = &m_emlrtRSI; if (!overflow) { } else { emlrtErrorWithMessageIdR2012b(&d_st, &t_emlrtRTEI, "Coder:FE:PotentialVectorVector", 0); } nx = ii->size[0]; ii->size[0] = ix; emxEnsureCapacity(&b_st, (emxArray__common *)ii, nx, (int32_T)sizeof(int32_T), &c_emlrtRTEI); } emxInit_real_T(&b_st, &occidx, 1, &g_emlrtRTEI, true); ix = occidx->size[0]; occidx->size[0] = ii->size[0]; emxEnsureCapacity(&st, (emxArray__common *)occidx, ix, (int32_T)sizeof(real_T), &emlrtRTEI); idx = ii->size[0]; for (ix = 0; ix < idx; ix++) { occidx->data[ix] = ii->data[ix]; } st.site = &c_emlrtRSI; ix = x->size[0]; x->size[0] = cgridvec->size[0]; emxEnsureCapacity(&st, (emxArray__common *)x, ix, (int32_T)sizeof(boolean_T), &emlrtRTEI); idx = cgridvec->size[0]; for (ix = 0; ix < idx; ix++) { x->data[ix] = (cgridvec->data[ix] != occval); } b_st.site = &i_emlrtRSI; nx = x->size[0]; idx = 0; ix = ii->size[0]; ii->size[0] = x->size[0]; emxEnsureCapacity(&b_st, (emxArray__common *)ii, ix, (int32_T)sizeof(int32_T), &emlrtRTEI); c_st.site = &j_emlrtRSI; if (1 > x->size[0]) { overflow = false; } else { overflow = (x->size[0] > 2147483646); } if (overflow) { d_st.site = &l_emlrtRSI; check_forloop_overflow_error(&d_st); } iy = 1; exitg4 = false; while ((!exitg4) && (iy <= nx)) { guard1 = false; if (x->data[iy - 1]) { idx++; ii->data[idx - 1] = iy; if (idx >= nx) { exitg4 = true; } else { guard1 = true; } } else { guard1 = true; } if (guard1) { iy++; } } if (idx <= x->size[0]) { } else { emlrtErrorWithMessageIdR2012b(&b_st, &s_emlrtRTEI, "Coder:builtins:AssertionFailed", 0); } if (x->size[0] == 1) { if (idx == 0) { ix = ii->size[0]; ii->size[0] = 0; emxEnsureCapacity(&b_st, (emxArray__common *)ii, ix, (int32_T)sizeof (int32_T), &emlrtRTEI); } } else { if (1 > idx) { ix = 0; } else { ix = idx; } c_st.site = &k_emlrtRSI; overflow = !(ii->size[0] != 1); b_guard2 = false; if (overflow) { overflow = false; if (ix != 1) { overflow = true; } if (overflow) { overflow = true; } else { b_guard2 = true; } } else { b_guard2 = true; } if (b_guard2) { overflow = false; } d_st.site = &m_emlrtRSI; if (!overflow) { } else { emlrtErrorWithMessageIdR2012b(&d_st, &t_emlrtRTEI, "Coder:FE:PotentialVectorVector", 0); } nx = ii->size[0]; ii->size[0] = ix; emxEnsureCapacity(&b_st, (emxArray__common *)ii, nx, (int32_T)sizeof(int32_T), &c_emlrtRTEI); } emxFree_boolean_T(&x); emxInit_real_T(&b_st, &noccidx, 1, &h_emlrtRTEI, true); ix = noccidx->size[0]; noccidx->size[0] = ii->size[0]; emxEnsureCapacity(&st, (emxArray__common *)noccidx, ix, (int32_T)sizeof(real_T), &emlrtRTEI); idx = ii->size[0]; for (ix = 0; ix < idx; ix++) { noccidx->data[ix] = ii->data[ix]; } nrnocc = noccidx->size[0] - 1; /* 1 Intensify newly occupied cells */ j = 0; emxInit_real_T1(sp, &curr_col, 2, &i_emlrtRTEI, true); emxInit_real_T1(sp, &updt_col, 2, &j_emlrtRTEI, true); emxInit_real_T1(sp, &z, 2, &emlrtRTEI, true); while (j <= newlyoccidx->size[0] - 1) { /* For newly occupied cells */ ix = newlyoccidx->size[0]; if (!((j + 1 >= 1) && (j + 1 <= ix))) { emlrtDynamicBoundsCheckR2012b(j + 1, 1, ix, &eb_emlrtBCI, sp); } coccidx = (int32_T)newlyoccidx->data[j] - 1; ix = context->size[0]; nx = (int32_T)newlyoccidx->data[j]; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &emlrtBCI, sp); } st.site = &d_emlrtRSI; b_st.site = &n_emlrtRSI; c_st.site = &o_emlrtRSI; ix = context->size[1]; b_guard1 = false; if (ix == 1) { b_guard1 = true; } else { ix = context->size[1]; if (ix != 1) { b_guard1 = true; } else { overflow = false; } } if (b_guard1) { overflow = true; } if (overflow) { } else { emlrtErrorWithMessageIdR2012b(&c_st, &u_emlrtRTEI, "Coder:toolbox:autoDimIncompatibility", 0); } ix = context->size[1]; if (ix > 0) { } else { emlrtErrorWithMessageIdR2012b(&c_st, &v_emlrtRTEI, "Coder:toolbox:eml_min_or_max_varDimZero", 0); } d_st.site = &p_emlrtRSI; ixstart = 1; n = context->size[1]; nx = (int32_T)newlyoccidx->data[j]; mtmp = context->data[nx - 1]; ix = context->size[1]; if (ix > 1) { if (muDoubleScalarIsNaN(mtmp)) { e_st.site = &r_emlrtRSI; ix = context->size[1]; if (2 > ix) { overflow = false; } else { ix = context->size[1]; overflow = (ix > 2147483646); } if (overflow) { f_st.site = &l_emlrtRSI; check_forloop_overflow_error(&f_st); } ix = 2; exitg3 = false; while ((!exitg3) && (ix <= n)) { ixstart = ix; if (!muDoubleScalarIsNaN(context->data[coccidx + context->size[0] * (ix - 1)])) { mtmp = context->data[coccidx + context->size[0] * (ix - 1)]; exitg3 = true; } else { ix++; } } } ix = context->size[1]; if (ixstart < ix) { e_st.site = &q_emlrtRSI; ix = context->size[1]; if (ixstart + 1 > ix) { overflow = false; } else { ix = context->size[1]; overflow = (ix > 2147483646); } if (overflow) { f_st.site = &l_emlrtRSI; check_forloop_overflow_error(&f_st); } for (ix = ixstart + 1; ix <= n; ix++) { if (context->data[coccidx + context->size[0] * (ix - 1)] > mtmp) { mtmp = context->data[coccidx + context->size[0] * (ix - 1)]; } } } } if (mtmp < minthreshold) { idx = context->size[1]; iy = context->size[0]; nx = (int32_T)newlyoccidx->data[j]; if (!((nx >= 1) && (nx <= iy))) { emlrtDynamicBoundsCheckR2012b(nx, 1, iy, &b_emlrtBCI, sp); } for (ix = 0; ix < idx; ix++) { context->data[(nx + context->size[0] * ix) - 1] = reinitval; } /* Reinitialize */ } else { idx = context->size[1]; nx = (int32_T)newlyoccidx->data[j]; ix = updt_col->size[0] * updt_col->size[1]; updt_col->size[0] = 1; updt_col->size[1] = idx; emxEnsureCapacity(sp, (emxArray__common *)updt_col, ix, (int32_T)sizeof (real_T), &emlrtRTEI); for (ix = 0; ix < idx; ix++) { updt_col->data[updt_col->size[0] * ix] = intensifyrate * context->data [(nx + context->size[0] * ix) - 1]; } /* Intensify */ st.site = &e_emlrtRSI; b_st.site = &s_emlrtRSI; c_st.site = &o_emlrtRSI; d_st.site = &t_emlrtRSI; ix = curr_col->size[0] * curr_col->size[1]; curr_col->size[0] = 1; curr_col->size[1] = updt_col->size[1]; emxEnsureCapacity(&d_st, (emxArray__common *)curr_col, ix, (int32_T)sizeof (real_T), &emlrtRTEI); idx = updt_col->size[0] * updt_col->size[1]; for (ix = 0; ix < idx; ix++) { curr_col->data[ix] = updt_col->data[ix]; } e_st.site = &u_emlrtRSI; for (ix = 0; ix < 2; ix++) { varargin_1[ix] = updt_col->size[ix]; } ix = z->size[0] * z->size[1]; z->size[0] = 1; z->size[1] = updt_col->size[1]; emxEnsureCapacity(&e_st, (emxArray__common *)z, ix, (int32_T)sizeof(real_T), &d_emlrtRTEI); iy = updt_col->size[1]; ix = updt_col->size[0] * updt_col->size[1]; updt_col->size[0] = 1; updt_col->size[1] = varargin_1[1]; emxEnsureCapacity(&e_st, (emxArray__common *)updt_col, ix, (int32_T)sizeof (real_T), &e_emlrtRTEI); if (dimagree(updt_col, curr_col)) { } else { emlrtErrorWithMessageIdR2012b(&e_st, &x_emlrtRTEI, "MATLAB:dimagree", 0); } e_st.site = &v_emlrtRSI; if (1 > z->size[1]) { overflow = false; } else { overflow = (z->size[1] > 2147483646); } if (overflow) { f_st.site = &l_emlrtRSI; check_forloop_overflow_error(&f_st); } for (k = 0; k + 1 <= iy; k++) { updt_col->data[k] = muDoubleScalarMin(curr_col->data[k], maxthreshold); } /* Max-thesholding */ ix = context->size[0]; nx = (int32_T)newlyoccidx->data[j]; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &c_emlrtBCI, sp); } idx = context->size[1]; ix = ii->size[0]; ii->size[0] = idx; emxEnsureCapacity(sp, (emxArray__common *)ii, ix, (int32_T)sizeof(int32_T), &emlrtRTEI); for (ix = 0; ix < idx; ix++) { ii->data[ix] = ix; } iv3[0] = 1; iv3[1] = ii->size[0]; emlrtSubAssignSizeCheckR2012b(iv3, 2, *(int32_T (*)[2])updt_col->size, 2, &b_emlrtECI, sp); nx = (int32_T)newlyoccidx->data[j]; idx = updt_col->size[1]; for (ix = 0; ix < idx; ix++) { context->data[(nx + context->size[0] * ii->data[ix]) - 1] = updt_col->data[updt_col->size[0] * ix]; } } j++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } emxFree_real_T(&z); /* 2 Attenuate unoccupied cells */ if (do_attenuation_first == 1.0) { j = 0; while (j <= nrnocc) { /* For unoccupied cells */ ix = noccidx->size[0]; nx = j + 1; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &d_emlrtBCI, sp); } ix = context->size[0]; nx = (int32_T)noccidx->data[j]; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &e_emlrtBCI, sp); } idx = context->size[1]; iy = (int32_T)noccidx->data[j]; ix = updt_col->size[0] * updt_col->size[1]; updt_col->size[0] = 1; updt_col->size[1] = idx; emxEnsureCapacity(sp, (emxArray__common *)updt_col, ix, (int32_T)sizeof (real_T), &emlrtRTEI); for (ix = 0; ix < idx; ix++) { updt_col->data[updt_col->size[0] * ix] = context->data[(iy + context->size[0] * ix) - 1] * nocc_attenuaterate; } /* Attenuate */ ix = context->size[0]; nx = (int32_T)noccidx->data[j]; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &f_emlrtBCI, sp); } idx = context->size[1]; ix = ii->size[0]; ii->size[0] = idx; emxEnsureCapacity(sp, (emxArray__common *)ii, ix, (int32_T)sizeof(int32_T), &emlrtRTEI); for (ix = 0; ix < idx; ix++) { ii->data[ix] = ix; } iv4[0] = 1; iv4[1] = ii->size[0]; emlrtSubAssignSizeCheckR2012b(iv4, 2, *(int32_T (*)[2])updt_col->size, 2, &c_emlrtECI, sp); iy = (int32_T)noccidx->data[j]; idx = updt_col->size[1]; for (ix = 0; ix < idx; ix++) { context->data[(iy + context->size[0] * ii->data[ix]) - 1] = updt_col->data[updt_col->size[0] * ix]; } j++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } } /* 4 Propagation */ j = 0; while (j <= occidx->size[0] - 1) { /* For occupied cells */ ix = occidx->size[0]; if (!((j + 1 >= 1) && (j + 1 <= ix))) { emlrtDynamicBoundsCheckR2012b(j + 1, 1, ix, &bb_emlrtBCI, sp); } idx = context->size[1]; ix = context->size[0]; iy = (int32_T)occidx->data[j]; if (!((iy >= 1) && (iy <= ix))) { emlrtDynamicBoundsCheckR2012b(iy, 1, ix, &g_emlrtBCI, sp); } ix = curr_col->size[0] * curr_col->size[1]; curr_col->size[0] = 1; curr_col->size[1] = idx; emxEnsureCapacity(sp, (emxArray__common *)curr_col, ix, (int32_T)sizeof (real_T), &emlrtRTEI); for (ix = 0; ix < idx; ix++) { curr_col->data[curr_col->size[0] * ix] = context->data[(iy + context-> size[0] * ix) - 1]; } ix = nei_idx->size[0]; nx = (int32_T)occidx->data[j]; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &h_emlrtBCI, sp); } ix = nei_weight->size[0]; nx = (int32_T)occidx->data[j]; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &i_emlrtBCI, sp); } emlrtForLoopVectorCheckR2012b(1.0, 1.0, nei_filter_n, mxDOUBLE_CLASS, (int32_T)nei_filter_n, &p_emlrtRTEI, sp); k = 0; while (k <= (int32_T)nei_filter_n - 1) { /* For all neighbor cells */ ix = curr_col->size[1]; nx = k + 1; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &j_emlrtBCI, sp); } ix = nei_idx->size[1]; nx = k + 1; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &k_emlrtBCI, sp); } ix = nei_weight->size[1]; nx = k + 1; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &l_emlrtBCI, sp); } iy = (int32_T)occidx->data[j]; if (nei_idx->data[(iy + nei_idx->size[0] * k) - 1] != 0.0) { /* If properly connected, propagate */ iy = (int32_T)occidx->data[j]; d0 = nei_idx->data[(iy + nei_idx->size[0] * k) - 1]; if (d0 != (int32_T)muDoubleScalarFloor(d0)) { emlrtIntegerCheckR2012b(d0, &emlrtDCI, sp); } ix = context->size[0]; nx = (int32_T)d0; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &m_emlrtBCI, sp); } ix = context->size[1]; nx = k + 1; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &n_emlrtBCI, sp); } /* Maximum value thresholding */ iy = (int32_T)occidx->data[j]; idx = (int32_T)occidx->data[j]; nx = (int32_T)occidx->data[j]; ix = context->size[0]; nx = (int32_T)nei_idx->data[(nx + nei_idx->size[0] * k) - 1]; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &cb_emlrtBCI, sp); } ix = context->size[1]; if (!((k + 1 >= 1) && (k + 1 <= ix))) { emlrtDynamicBoundsCheckR2012b(k + 1, 1, ix, &db_emlrtBCI, sp); } context->data[(nx + context->size[0] * k) - 1] = muDoubleScalarMax (context->data[((int32_T)nei_idx->data[(iy + nei_idx->size[0] * k) - 1] + context->size[0] * k) - 1], muDoubleScalarMin (nei_weight->data[(idx + nei_weight->size[0] * k) - 1] * curr_col->data[k], maxthreshold)); /* Make sure current context propagation does not weaken the flow information */ } k++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } j++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } emxFree_real_T(&occidx); emxInit_real_T1(sp, &tempcontext, 2, &k_emlrtRTEI, true); /* 5 Uncertainty in acceleration */ ix = tempcontext->size[0] * tempcontext->size[1]; tempcontext->size[0] = context->size[0]; tempcontext->size[1] = context->size[1]; emxEnsureCapacity(sp, (emxArray__common *)tempcontext, ix, (int32_T)sizeof (real_T), &emlrtRTEI); idx = context->size[0] * context->size[1]; for (ix = 0; ix < idx; ix++) { tempcontext->data[ix] = context->data[ix]; } emlrtForLoopVectorCheckR2012b(1.0, 1.0, nei_filter_n, mxDOUBLE_CLASS, (int32_T) nei_filter_n, &q_emlrtRTEI, sp); j = 0; emxInit_real_T1(sp, &b_nei4u_weight, 2, &emlrtRTEI, true); while (j <= (int32_T)nei_filter_n - 1) { /* For all context level */ k = 0; while (k <= nei_idx->size[0] - 1) { /* For all cells */ sumval = 0.0; emlrtForLoopVectorCheckR2012b(1.0, 1.0, nei4u_filter_n, mxDOUBLE_CLASS, (int32_T)nei4u_filter_n, &r_emlrtRTEI, sp); m = 0; while (m <= (int32_T)nei4u_filter_n - 1) { ix = nei4u_idx->size[0]; nx = k + 1; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &o_emlrtBCI, sp); } ix = nei4u_idx->size[1]; nx = m + 1; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &p_emlrtBCI, sp); } ix = nei4u_weight->size[0]; nx = k + 1; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &q_emlrtBCI, sp); } ix = nei4u_weight->size[1]; nx = m + 1; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &r_emlrtBCI, sp); } idx = nei4u_weight->size[1]; ix = nei4u_weight->size[0]; nx = 1 + k; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &s_emlrtBCI, sp); } ix = b_nei4u_weight->size[0] * b_nei4u_weight->size[1]; b_nei4u_weight->size[0] = 1; b_nei4u_weight->size[1] = idx; emxEnsureCapacity(sp, (emxArray__common *)b_nei4u_weight, ix, (int32_T) sizeof(real_T), &emlrtRTEI); for (ix = 0; ix < idx; ix++) { b_nei4u_weight->data[b_nei4u_weight->size[0] * ix] = nei4u_weight->data[(nx + nei4u_weight->size[0] * ix) - 1]; } st.site = &f_emlrtRSI; mtmp = sum(&st, b_nei4u_weight); if (nei4u_idx->data[k + nei4u_idx->size[0] * m] != 0.0) { d0 = nei4u_idx->data[k + nei4u_idx->size[0] * m]; if (d0 != (int32_T)muDoubleScalarFloor(d0)) { emlrtIntegerCheckR2012b(d0, &b_emlrtDCI, sp); } ix = context->size[0]; nx = (int32_T)d0; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &t_emlrtBCI, sp); } ix = context->size[1]; nx = j + 1; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &u_emlrtBCI, sp); } sumval += nei4u_weight->data[k + nei4u_weight->size[0] * m] / mtmp * context->data[((int32_T)nei4u_idx->data[k + nei4u_idx->size[0] * m] + context->size[0] * j) - 1]; } m++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } ix = tempcontext->size[0]; nx = 1 + k; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &y_emlrtBCI, sp); } ix = tempcontext->size[1]; if (!((j + 1 >= 1) && (j + 1 <= ix))) { emlrtDynamicBoundsCheckR2012b(j + 1, 1, ix, &ab_emlrtBCI, sp); } tempcontext->data[(nx + tempcontext->size[0] * j) - 1] = sumval; k++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } j++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } emxFree_real_T(&b_nei4u_weight); ix = context->size[0] * context->size[1]; context->size[0] = tempcontext->size[0]; context->size[1] = tempcontext->size[1]; emxEnsureCapacity(sp, (emxArray__common *)context, ix, (int32_T)sizeof(real_T), &emlrtRTEI); idx = tempcontext->size[1]; for (ix = 0; ix < idx; ix++) { iy = tempcontext->size[0]; for (nx = 0; nx < iy; nx++) { context->data[nx + context->size[0] * ix] = tempcontext->data[nx + tempcontext->size[0] * ix]; } } if (do_attenuation_first == 0.0) { /* 2 Attenuate unoccupied cells */ j = 0; while (j <= nrnocc) { /* For unoccupied cells, attenuate */ ix = noccidx->size[0]; nx = j + 1; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &v_emlrtBCI, sp); } ix = context->size[0]; nx = (int32_T)noccidx->data[j]; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &w_emlrtBCI, sp); } idx = context->size[1]; iy = (int32_T)noccidx->data[j]; ix = updt_col->size[0] * updt_col->size[1]; updt_col->size[0] = 1; updt_col->size[1] = idx; emxEnsureCapacity(sp, (emxArray__common *)updt_col, ix, (int32_T)sizeof (real_T), &emlrtRTEI); for (ix = 0; ix < idx; ix++) { updt_col->data[updt_col->size[0] * ix] = context->data[(iy + context->size[0] * ix) - 1] * nocc_attenuaterate; } ix = context->size[0]; nx = (int32_T)noccidx->data[j]; if (!((nx >= 1) && (nx <= ix))) { emlrtDynamicBoundsCheckR2012b(nx, 1, ix, &x_emlrtBCI, sp); } idx = context->size[1]; ix = ii->size[0]; ii->size[0] = idx; emxEnsureCapacity(sp, (emxArray__common *)ii, ix, (int32_T)sizeof(int32_T), &emlrtRTEI); for (ix = 0; ix < idx; ix++) { ii->data[ix] = ix; } iv5[0] = 1; iv5[1] = ii->size[0]; emlrtSubAssignSizeCheckR2012b(iv5, 2, *(int32_T (*)[2])updt_col->size, 2, &d_emlrtECI, sp); iy = (int32_T)noccidx->data[j]; idx = updt_col->size[1]; for (ix = 0; ix < idx; ix++) { context->data[(iy + context->size[0] * ii->data[ix]) - 1] = updt_col->data[updt_col->size[0] * ix]; } j++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } } emxFree_int32_T(&ii); emxFree_real_T(&updt_col); emxFree_real_T(&noccidx); /* 6 Prediction */ st.site = &g_emlrtRSI; ix = tempcontext->size[0] * tempcontext->size[1]; tempcontext->size[0] = context->size[1]; tempcontext->size[1] = context->size[0]; emxEnsureCapacity(&st, (emxArray__common *)tempcontext, ix, (int32_T)sizeof (real_T), &emlrtRTEI); idx = context->size[0]; for (ix = 0; ix < idx; ix++) { iy = context->size[1]; for (nx = 0; nx < iy; nx++) { tempcontext->data[nx + tempcontext->size[0] * ix] = context->data[ix + context->size[0] * nx]; } } b_st.site = &n_emlrtRSI; c_st.site = &o_emlrtRSI; if (((tempcontext->size[0] == 1) && (tempcontext->size[1] == 1)) || (tempcontext->size[0] != 1)) { overflow = true; } else { overflow = false; } if (overflow) { } else { emlrtErrorWithMessageIdR2012b(&c_st, &u_emlrtRTEI, "Coder:toolbox:autoDimIncompatibility", 0); } if (tempcontext->size[0] > 0) { } else { emlrtErrorWithMessageIdR2012b(&c_st, &v_emlrtRTEI, "Coder:toolbox:eml_min_or_max_varDimZero", 0); } ix = curr_col->size[0] * curr_col->size[1]; curr_col->size[0] = 1; curr_col->size[1] = tempcontext->size[1]; emxEnsureCapacity(&c_st, (emxArray__common *)curr_col, ix, (int32_T)sizeof (real_T), &emlrtRTEI); n = tempcontext->size[0]; ix = 0; iy = -1; d_st.site = &ab_emlrtRSI; if (1 > tempcontext->size[1]) { overflow = false; } else { overflow = (tempcontext->size[1] > 2147483646); } if (overflow) { e_st.site = &l_emlrtRSI; check_forloop_overflow_error(&e_st); } for (nx = 1; nx <= tempcontext->size[1]; nx++) { d_st.site = &bb_emlrtRSI; ixstart = ix; idx = ix + n; mtmp = tempcontext->data[ix]; if (n > 1) { if (muDoubleScalarIsNaN(tempcontext->data[ix])) { e_st.site = &r_emlrtRSI; if (ix + 2 > idx) { b_ix = false; } else { b_ix = (idx > 2147483646); } if (b_ix) { f_st.site = &l_emlrtRSI; check_forloop_overflow_error(&f_st); } k = ix + 1; exitg2 = false; while ((!exitg2) && (k + 1 <= idx)) { ixstart = k; if (!muDoubleScalarIsNaN(tempcontext->data[k])) { mtmp = tempcontext->data[k]; exitg2 = true; } else { k++; } } } if (ixstart + 1 < idx) { e_st.site = &q_emlrtRSI; if (ixstart + 2 > idx) { b_ixstart = false; } else { b_ixstart = (idx > 2147483646); } if (b_ixstart) { f_st.site = &l_emlrtRSI; check_forloop_overflow_error(&f_st); } for (k = ixstart + 1; k + 1 <= idx; k++) { if (tempcontext->data[k] > mtmp) { mtmp = tempcontext->data[k]; } } } } iy++; curr_col->data[iy] = mtmp; ix += n; } emxFree_real_T(&tempcontext); ix = maxvec->size[0]; maxvec->size[0] = curr_col->size[1]; emxEnsureCapacity(sp, (emxArray__common *)maxvec, ix, (int32_T)sizeof(real_T), &emlrtRTEI); idx = curr_col->size[1]; for (ix = 0; ix < idx; ix++) { maxvec->data[ix] = curr_col->data[curr_col->size[0] * ix]; } emxFree_real_T(&curr_col); st.site = &h_emlrtRSI; /* sigm_a <= if we increase the value, than the sigm function gets peaky! */ b_st.site = &cb_emlrtRSI; ix = predvec->size[0]; predvec->size[0] = maxvec->size[0]; emxEnsureCapacity(&b_st, (emxArray__common *)predvec, ix, (int32_T)sizeof (real_T), &emlrtRTEI); idx = maxvec->size[0]; for (ix = 0; ix < idx; ix++) { predvec->data[ix] = -sigm_coef * maxvec->data[ix]; } c_st.site = &cb_emlrtRSI; b_exp(&c_st, predvec); ix = predvec->size[0]; emxEnsureCapacity(&b_st, (emxArray__common *)predvec, ix, (int32_T)sizeof (real_T), &emlrtRTEI); idx = predvec->size[0]; for (ix = 0; ix < idx; ix++) { predvec->data[ix] = 1.0 - predvec->data[ix]; } ix = newlyoccidx->size[0]; newlyoccidx->size[0] = maxvec->size[0]; emxEnsureCapacity(&b_st, (emxArray__common *)newlyoccidx, ix, (int32_T)sizeof (real_T), &emlrtRTEI); idx = maxvec->size[0]; for (ix = 0; ix < idx; ix++) { newlyoccidx->data[ix] = -sigm_coef * maxvec->data[ix]; } c_st.site = &cb_emlrtRSI; b_exp(&c_st, newlyoccidx); ix = newlyoccidx->size[0]; emxEnsureCapacity(&b_st, (emxArray__common *)newlyoccidx, ix, (int32_T)sizeof (real_T), &emlrtRTEI); idx = newlyoccidx->size[0]; for (ix = 0; ix < idx; ix++) { newlyoccidx->data[ix]++; } varargin_1[0] = predvec->size[0]; varargin_1[1] = 1; varargin_2[0] = newlyoccidx->size[0]; varargin_2[1] = 1; overflow = false; p = true; k = 0; exitg1 = false; while ((!exitg1) && (k < 2)) { if (!(varargin_1[k] == varargin_2[k])) { p = false; exitg1 = true; } else { k++; } } if (!p) { } else { overflow = true; } if (overflow) { } else { emlrtErrorWithMessageIdR2012b(&b_st, &w_emlrtRTEI, "MATLAB:dimagree", 0); } ix = predvec->size[0]; emxEnsureCapacity(&b_st, (emxArray__common *)predvec, ix, (int32_T)sizeof (real_T), &emlrtRTEI); idx = predvec->size[0]; for (ix = 0; ix < idx; ix++) { predvec->data[ix] /= newlyoccidx->data[ix]; } emxFree_real_T(&newlyoccidx); /* 7 Save previous grid */ ix = cgridvecprev->size[0]; cgridvecprev->size[0] = cgridvec->size[0]; emxEnsureCapacity(sp, (emxArray__common *)cgridvecprev, ix, (int32_T)sizeof (real_T), &emlrtRTEI); idx = cgridvec->size[0]; for (ix = 0; ix < idx; ix++) { cgridvecprev->data[ix] = cgridvec->data[ix]; } emlrtHeapReferenceStackLeaveFcnR2012b(sp); }
/* Function Definitions */ real_T compressedindex(const emlrtStack *sp, const emxArray_real_T *x, const emxArray_real_T *ctable, real_T range, real_T dims) { real_T y; real_T py; int32_T i; int32_T i2; int32_T i3; real_T d4; int32_T k; int32_T vlen; boolean_T p; boolean_T b_p; int32_T exitg1; int32_T b_k; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; emlrtStack e_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; d_st.prev = &c_st; d_st.tls = c_st.tls; e_st.prev = &d_st; e_st.tls = d_st.tls; /* for a given vector, find its index within the transition space matrix */ /* workspace; */ py = 1.0; range++; emlrtForLoopVectorCheckR2012b(1.0, 1.0, dims - 2.0, mxDOUBLE_CLASS, (int32_T) (dims - 2.0), (emlrtRTEInfo *)&o_emlrtRTEI, sp); i = 0; while (i <= (int32_T)(dims - 2.0) - 1) { i2 = x->size[1]; if (!((i + 1 >= 1) && (i + 1 <= i2))) { emlrtDynamicBoundsCheckR2012b(i + 1, 1, i2, (emlrtBCInfo *)&bb_emlrtBCI, sp); } if (x->data[i] == 0.0) { } else { i2 = x->size[1]; if (!((i + 1 >= 1) && (i + 1 <= i2))) { emlrtDynamicBoundsCheckR2012b(i + 1, 1, i2, (emlrtBCInfo *)&cb_emlrtBCI, sp); } d4 = range - (x->data[i] - 1.0); if (d4 > range) { i3 = 1; i2 = 1; } else { if (d4 != (int32_T)muDoubleScalarFloor(d4)) { emlrtIntegerCheckR2012b(d4, (emlrtDCInfo *)&k_emlrtDCI, sp); } i2 = ctable->size[0]; i3 = (int32_T)d4; if (!((i3 >= 1) && (i3 <= i2))) { emlrtDynamicBoundsCheckR2012b(i3, 1, i2, (emlrtBCInfo *)&x_emlrtBCI, sp); } if (range != (int32_T)muDoubleScalarFloor(range)) { emlrtIntegerCheckR2012b(range, (emlrtDCInfo *)&k_emlrtDCI, sp); } i2 = ctable->size[0]; k = (int32_T)range; if (!((k >= 1) && (k <= i2))) { emlrtDynamicBoundsCheckR2012b(k, 1, i2, (emlrtBCInfo *)&x_emlrtBCI, sp); } i2 = k + 1; } st.site = &l_emlrtRSI; d4 = dims - (1.0 + (real_T)i); if (d4 != (int32_T)muDoubleScalarFloor(d4)) { emlrtIntegerCheckR2012b(d4, (emlrtDCInfo *)&l_emlrtDCI, &st); } k = ctable->size[1]; vlen = (int32_T)d4; if (!((vlen >= 1) && (vlen <= k))) { emlrtDynamicBoundsCheckR2012b(vlen, 1, k, (emlrtBCInfo *)&y_emlrtBCI, &st); } b_st.site = &m_emlrtRSI; if ((i2 - i3 == 1) || (i2 - i3 != 1)) { p = true; } else { p = false; } if (p) { } else { emlrtErrorWithMessageIdR2012b(&b_st, &p_emlrtRTEI, "Coder:toolbox:autoDimIncompatibility", 0); } p = false; b_p = false; k = 0; do { exitg1 = 0; if (k < 2) { if (k + 1 <= 1) { b_k = i2 - i3; } else { b_k = 1; } if (b_k != 0) { exitg1 = 1; } else { k++; } } else { b_p = true; exitg1 = 1; } } while (exitg1 == 0); if (!b_p) { } else { p = true; } if (!p) { } else { emlrtErrorWithMessageIdR2012b(&b_st, &q_emlrtRTEI, "Coder:toolbox:UnsupportedSpecialEmpty", 0); } c_st.site = &n_emlrtRSI; if (i2 - i3 == 0) { y = 0.0; } else { vlen = i2 - i3; y = ctable->data[(i3 + ctable->size[0] * ((int32_T)(dims - (1.0 + (real_T)i)) - 1)) - 1]; d_st.site = &o_emlrtRSI; if ((!(2 > i2 - i3)) && (i2 - i3 > 2147483646)) { e_st.site = &j_emlrtRSI; check_forloop_overflow_error(&e_st); } for (k = 0; k + 2 <= vlen; k++) { y += ctable->data[(i3 + k) + ctable->size[0] * ((int32_T)(dims - (1.0 + (real_T)i)) - 1)]; } } py += y; i2 = x->size[1]; if (!((i + 1 >= 1) && (i + 1 <= i2))) { emlrtDynamicBoundsCheckR2012b(i + 1, 1, i2, (emlrtBCInfo *)&db_emlrtBCI, sp); } range -= x->data[i]; } i++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } i2 = x->size[1]; i3 = x->size[1] - 1; if (!((i3 >= 1) && (i3 <= i2))) { emlrtDynamicBoundsCheckR2012b(i3, 1, i2, (emlrtBCInfo *)&ab_emlrtBCI, sp); } return py + x->data[i3 - 1]; }
/* Function Definitions */ void MechanicalPointForce(const emlrtStack *sp, const emxArray_real_T *particlePosition, const emxArray_real_T *pointSourcePosition, real_T forceDirection, real_T forceMagnitude, real_T cutoff, emxArray_real_T *force) { uint32_T sz[2]; int32_T ix; emxArray_real_T *forceTemp; int32_T loop_ub; emxArray_real_T *forceMag; int32_T vlen; int32_T sIdx; emxArray_real_T *forceDir; emxArray_real_T *distToSource; emxArray_int32_T *r0; emxArray_boolean_T *r1; emxArray_int32_T *r2; emxArray_real_T *x; emxArray_real_T *b_x; emxArray_real_T *r3; emxArray_real_T *r4; emxArray_real_T *b_pointSourcePosition; emxArray_real_T *b_forceDir; emxArray_real_T *c_forceDir; int32_T k; int32_T vstride; int32_T iy; int32_T ixstart; boolean_T overflow; real_T s; boolean_T b0; uint32_T varargin_2[2]; boolean_T p; boolean_T exitg1; int32_T iv0[1]; int32_T iv1[2]; int32_T b_force[2]; int32_T iv2[1]; int32_T b_iy; int32_T c_iy; int32_T b_forceTemp[2]; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; emlrtStack e_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; d_st.prev = &c_st; d_st.tls = c_st.tls; e_st.prev = &d_st; e_st.tls = d_st.tls; emlrtHeapReferenceStackEnterFcnR2012b(sp); /* apply mechanical (push or pull) force on particles */ /* mechanicalForce is a logical flag */ /* particlPosition is a N by 3 vector of particle position */ /* pointSourcePosition is the position of force sources */ /* forceDirection is either -1 for 'in' or 1 for 'out' */ /* forceMagnitude is a positive number between 0 and 1 */ /* cutoff is the maximal direction the force operates on particle relative */ /* to the pointSourcePosition */ /* the output is a vector of N by 3 of delta position to th */ for (ix = 0; ix < 2; ix++) { sz[ix] = (uint32_T)particlePosition->size[ix]; } emxInit_real_T(sp, &forceTemp, 2, &c_emlrtRTEI, true); ix = forceTemp->size[0] * forceTemp->size[1]; forceTemp->size[0] = (int32_T)sz[0]; emxEnsureCapacity(sp, (emxArray__common *)forceTemp, ix, (int32_T)sizeof (real_T), &emlrtRTEI); ix = forceTemp->size[0] * forceTemp->size[1]; forceTemp->size[1] = (int32_T)sz[1]; emxEnsureCapacity(sp, (emxArray__common *)forceTemp, ix, (int32_T)sizeof (real_T), &emlrtRTEI); loop_ub = (int32_T)sz[0] * (int32_T)sz[1]; for (ix = 0; ix < loop_ub; ix++) { forceTemp->data[ix] = 0.0; } for (ix = 0; ix < 2; ix++) { sz[ix] = (uint32_T)particlePosition->size[ix]; } ix = force->size[0] * force->size[1]; force->size[0] = (int32_T)sz[0]; emxEnsureCapacity(sp, (emxArray__common *)force, ix, (int32_T)sizeof(real_T), &emlrtRTEI); ix = force->size[0] * force->size[1]; force->size[1] = (int32_T)sz[1]; emxEnsureCapacity(sp, (emxArray__common *)force, ix, (int32_T)sizeof(real_T), &emlrtRTEI); loop_ub = (int32_T)sz[0] * (int32_T)sz[1]; for (ix = 0; ix < loop_ub; ix++) { force->data[ix] = 0.0; } emxInit_real_T(sp, &forceMag, 2, &d_emlrtRTEI, true); vlen = particlePosition->size[0]; ix = forceMag->size[0] * forceMag->size[1]; forceMag->size[0] = vlen; emxEnsureCapacity(sp, (emxArray__common *)forceMag, ix, (int32_T)sizeof(real_T), &emlrtRTEI); vlen = particlePosition->size[0]; ix = forceMag->size[0] * forceMag->size[1]; forceMag->size[1] = vlen; emxEnsureCapacity(sp, (emxArray__common *)forceMag, ix, (int32_T)sizeof(real_T), &emlrtRTEI); loop_ub = particlePosition->size[0] * particlePosition->size[0]; for (ix = 0; ix < loop_ub; ix++) { forceMag->data[ix] = 0.0; } sIdx = 0; emxInit_real_T(sp, &forceDir, 2, &e_emlrtRTEI, true); b_emxInit_real_T(sp, &distToSource, 1, &f_emlrtRTEI, true); emxInit_int32_T(sp, &r0, 1, &emlrtRTEI, true); emxInit_boolean_T(sp, &r1, 2, &emlrtRTEI, true); emxInit_int32_T(sp, &r2, 1, &emlrtRTEI, true); emxInit_real_T(sp, &x, 2, &emlrtRTEI, true); b_emxInit_real_T(sp, &b_x, 1, &emlrtRTEI, true); b_emxInit_real_T(sp, &r3, 1, &emlrtRTEI, true); b_emxInit_real_T(sp, &r4, 1, &emlrtRTEI, true); emxInit_real_T(sp, &b_pointSourcePosition, 2, &emlrtRTEI, true); b_emxInit_real_T(sp, &b_forceDir, 1, &emlrtRTEI, true); emxInit_real_T(sp, &c_forceDir, 2, &emlrtRTEI, true); while (sIdx <= pointSourcePosition->size[0] - 1) { loop_ub = pointSourcePosition->size[1]; ix = pointSourcePosition->size[0]; if ((sIdx + 1 >= 1) && (sIdx + 1 < ix)) { vlen = sIdx + 1; } else { vlen = emlrtDynamicBoundsCheckR2012b(sIdx + 1, 1, ix, (emlrtBCInfo *) &e_emlrtBCI, sp); } ix = b_pointSourcePosition->size[0] * b_pointSourcePosition->size[1]; b_pointSourcePosition->size[0] = 1; b_pointSourcePosition->size[1] = loop_ub; emxEnsureCapacity(sp, (emxArray__common *)b_pointSourcePosition, ix, (int32_T)sizeof(real_T), &emlrtRTEI); for (ix = 0; ix < loop_ub; ix++) { b_pointSourcePosition->data[b_pointSourcePosition->size[0] * ix] = pointSourcePosition->data[(vlen + pointSourcePosition->size[0] * ix) - 1]; } st.site = &emlrtRSI; bsxfun(&st, particlePosition, b_pointSourcePosition, forceDir); /* Find the distance between the particles and the source */ st.site = &b_emlrtRSI; b_st.site = &h_emlrtRSI; c_st.site = &i_emlrtRSI; d_st.site = &j_emlrtRSI; for (ix = 0; ix < 2; ix++) { sz[ix] = (uint32_T)forceDir->size[ix]; } ix = x->size[0] * x->size[1]; x->size[0] = (int32_T)sz[0]; x->size[1] = (int32_T)sz[1]; emxEnsureCapacity(&d_st, (emxArray__common *)x, ix, (int32_T)sizeof(real_T), &b_emlrtRTEI); if (dimagree(x, forceDir)) { } else { emlrtErrorWithMessageIdR2012b(&d_st, &b_emlrtRTEI, "MATLAB:dimagree", 0); } ix = (int32_T)sz[0] * (int32_T)sz[1]; for (k = 0; k < ix; k++) { x->data[k] = forceDir->data[k] * forceDir->data[k]; } st.site = &b_emlrtRSI; b_st.site = &k_emlrtRSI; c_st.site = &l_emlrtRSI; for (ix = 0; ix < 2; ix++) { sz[ix] = (uint32_T)x->size[ix]; } ix = b_x->size[0]; b_x->size[0] = (int32_T)sz[0]; emxEnsureCapacity(&c_st, (emxArray__common *)b_x, ix, (int32_T)sizeof(real_T), &emlrtRTEI); if ((x->size[0] == 0) || (x->size[1] == 0)) { ix = b_x->size[0]; b_x->size[0] = (int32_T)sz[0]; emxEnsureCapacity(&c_st, (emxArray__common *)b_x, ix, (int32_T)sizeof (real_T), &emlrtRTEI); loop_ub = (int32_T)sz[0]; for (ix = 0; ix < loop_ub; ix++) { b_x->data[ix] = 0.0; } } else { vlen = x->size[1]; vstride = x->size[0]; iy = -1; ixstart = -1; d_st.site = &m_emlrtRSI; overflow = (x->size[0] > 2147483646); if (overflow) { e_st.site = &g_emlrtRSI; check_forloop_overflow_error(&e_st); } for (loop_ub = 1; loop_ub <= vstride; loop_ub++) { ixstart++; ix = ixstart; s = x->data[ixstart]; d_st.site = &n_emlrtRSI; if (2 > vlen) { b0 = false; } else { b0 = (vlen > 2147483646); } if (b0) { e_st.site = &g_emlrtRSI; check_forloop_overflow_error(&e_st); } for (k = 2; k <= vlen; k++) { ix += vstride; s += x->data[ix]; } iy++; b_x->data[iy] = s; } } st.site = &b_emlrtRSI; ix = distToSource->size[0]; distToSource->size[0] = b_x->size[0]; emxEnsureCapacity(&st, (emxArray__common *)distToSource, ix, (int32_T)sizeof (real_T), &emlrtRTEI); loop_ub = b_x->size[0]; for (ix = 0; ix < loop_ub; ix++) { distToSource->data[ix] = b_x->data[ix]; } for (k = 0; k < b_x->size[0]; k++) { if (b_x->data[k] < 0.0) { b_st.site = &o_emlrtRSI; eml_error(&b_st); } } for (k = 0; k < b_x->size[0]; k++) { distToSource->data[k] = muDoubleScalarSqrt(distToSource->data[k]); } /* Normalize the forceDirection */ iy = 0; while (iy < 3) { loop_ub = forceDir->size[0]; ix = r2->size[0]; r2->size[0] = loop_ub; emxEnsureCapacity(sp, (emxArray__common *)r2, ix, (int32_T)sizeof(int32_T), &emlrtRTEI); for (ix = 0; ix < loop_ub; ix++) { r2->data[ix] = ix; } ix = forceDir->size[1]; ixstart = 1 + iy; emlrtDynamicBoundsCheckR2012b(ixstart, 1, ix, (emlrtBCInfo *)&c_emlrtBCI, sp); st.site = &c_emlrtRSI; ix = forceDir->size[1]; ixstart = 1 + iy; emlrtDynamicBoundsCheckR2012b(ixstart, 1, ix, (emlrtBCInfo *)&d_emlrtBCI, &st); ix = forceDir->size[0]; sz[0] = (uint32_T)ix; sz[1] = 1U; varargin_2[0] = (uint32_T)distToSource->size[0]; varargin_2[1] = 1U; overflow = false; p = true; k = 0; exitg1 = false; while ((!exitg1) && (k < 2)) { if (!((int32_T)sz[k] == (int32_T)varargin_2[k])) { p = false; exitg1 = true; } else { k++; } } if (!p) { } else { overflow = true; } if (overflow) { } else { emlrtErrorWithMessageIdR2012b(&st, &l_emlrtRTEI, "MATLAB:dimagree", 0); } loop_ub = forceDir->size[0]; ix = b_x->size[0]; b_x->size[0] = loop_ub; emxEnsureCapacity(&st, (emxArray__common *)b_x, ix, (int32_T)sizeof(real_T), &emlrtRTEI); for (ix = 0; ix < loop_ub; ix++) { b_x->data[ix] = forceDir->data[ix + forceDir->size[0] * iy] / distToSource->data[ix]; } iv0[0] = r2->size[0]; emlrtSubAssignSizeCheckR2012b(iv0, 1, *(int32_T (*)[1])b_x->size, 1, (emlrtECInfo *)&d_emlrtECI, sp); loop_ub = b_x->size[0]; for (ix = 0; ix < loop_ub; ix++) { forceDir->data[r2->data[ix] + forceDir->size[0] * iy] = b_x->data[ix]; } /* bsxfun(@rdivide,forceDir,distToSource); */ iy++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } /* Multiply the */ if (forceDirection == -1.0) { ix = r4->size[0]; r4->size[0] = distToSource->size[0]; emxEnsureCapacity(sp, (emxArray__common *)r4, ix, (int32_T)sizeof(real_T), &emlrtRTEI); loop_ub = distToSource->size[0]; for (ix = 0; ix < loop_ub; ix++) { r4->data[ix] = 1.0 + distToSource->data[ix]; } rdivide(sp, forceMagnitude, r4, b_x); vlen = b_x->size[0]; ix = forceMag->size[0] * forceMag->size[1]; forceMag->size[0] = vlen; emxEnsureCapacity(sp, (emxArray__common *)forceMag, ix, (int32_T)sizeof (real_T), &emlrtRTEI); ix = forceMag->size[0] * forceMag->size[1]; forceMag->size[1] = 1; emxEnsureCapacity(sp, (emxArray__common *)forceMag, ix, (int32_T)sizeof (real_T), &emlrtRTEI); loop_ub = b_x->size[0]; for (ix = 0; ix < loop_ub; ix++) { forceMag->data[ix] = 1.0 - b_x->data[ix]; } } else { if (forceDirection == 1.0) { ix = r3->size[0]; r3->size[0] = distToSource->size[0]; emxEnsureCapacity(sp, (emxArray__common *)r3, ix, (int32_T)sizeof(real_T), &emlrtRTEI); loop_ub = distToSource->size[0]; for (ix = 0; ix < loop_ub; ix++) { r3->data[ix] = 1.0 + distToSource->data[ix]; } rdivide(sp, forceMagnitude, r3, b_x); vlen = b_x->size[0]; ix = forceMag->size[0] * forceMag->size[1]; forceMag->size[0] = vlen; emxEnsureCapacity(sp, (emxArray__common *)forceMag, ix, (int32_T)sizeof (real_T), &emlrtRTEI); ix = forceMag->size[0] * forceMag->size[1]; forceMag->size[1] = 1; emxEnsureCapacity(sp, (emxArray__common *)forceMag, ix, (int32_T)sizeof (real_T), &emlrtRTEI); loop_ub = b_x->size[0]; for (ix = 0; ix < loop_ub; ix++) { forceMag->data[ix] = b_x->data[ix]; } } } iy = 0; while (iy < 3) { ix = forceDir->size[1]; ixstart = 1 + iy; emlrtDynamicBoundsCheckR2012b(ixstart, 1, ix, (emlrtBCInfo *)&b_emlrtBCI, sp); ix = forceDir->size[0]; iv1[0] = ix; iv1[1] = 1; for (ix = 0; ix < 2; ix++) { b_force[ix] = forceMag->size[ix]; } if ((iv1[0] != b_force[0]) || (1 != b_force[1])) { emlrtSizeEqCheckNDR2012b(iv1, b_force, (emlrtECInfo *)&c_emlrtECI, sp); } loop_ub = forceTemp->size[0]; ix = r2->size[0]; r2->size[0] = loop_ub; emxEnsureCapacity(sp, (emxArray__common *)r2, ix, (int32_T)sizeof(int32_T), &emlrtRTEI); for (ix = 0; ix < loop_ub; ix++) { r2->data[ix] = ix; } ix = forceTemp->size[1]; ixstart = 1 + iy; emlrtDynamicBoundsCheckR2012b(ixstart, 1, ix, (emlrtBCInfo *)&emlrtBCI, sp); loop_ub = forceDir->size[0]; vlen = forceDir->size[0]; vstride = forceDir->size[0]; ix = b_forceDir->size[0]; b_forceDir->size[0] = vstride; emxEnsureCapacity(sp, (emxArray__common *)b_forceDir, ix, (int32_T)sizeof (real_T), &emlrtRTEI); for (ix = 0; ix < vstride; ix++) { b_forceDir->data[ix] = forceDir->data[ix + forceDir->size[0] * iy]; } ix = c_forceDir->size[0] * c_forceDir->size[1]; c_forceDir->size[0] = loop_ub; c_forceDir->size[1] = 1; emxEnsureCapacity(sp, (emxArray__common *)c_forceDir, ix, (int32_T)sizeof (real_T), &emlrtRTEI); for (ix = 0; ix < loop_ub; ix++) { c_forceDir->data[ix] = b_forceDir->data[ix]; } ix = b_x->size[0]; b_x->size[0] = vlen; emxEnsureCapacity(sp, (emxArray__common *)b_x, ix, (int32_T)sizeof(real_T), &emlrtRTEI); for (ix = 0; ix < vlen; ix++) { b_x->data[ix] = c_forceDir->data[ix] * forceMag->data[ix]; } iv2[0] = r2->size[0]; emlrtSubAssignSizeCheckR2012b(iv2, 1, *(int32_T (*)[1])b_x->size, 1, (emlrtECInfo *)&b_emlrtECI, sp); loop_ub = b_x->size[0]; for (ix = 0; ix < loop_ub; ix++) { forceTemp->data[r2->data[ix] + forceTemp->size[0] * iy] = b_x->data[ix]; } /* bsxfun(@times,forceDir,forceTemp); */ iy++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } iy = distToSource->size[0] - 1; vlen = 0; for (vstride = 0; vstride <= iy; vstride++) { if (distToSource->data[vstride] > cutoff) { vlen++; } } ix = r2->size[0]; r2->size[0] = vlen; emxEnsureCapacity(sp, (emxArray__common *)r2, ix, (int32_T)sizeof(int32_T), &emlrtRTEI); vlen = 0; for (vstride = 0; vstride <= iy; vstride++) { if (distToSource->data[vstride] > cutoff) { r2->data[vlen] = vstride + 1; vlen++; } } loop_ub = forceTemp->size[1]; vstride = forceTemp->size[0]; vlen = r2->size[0]; for (ix = 0; ix < loop_ub; ix++) { for (ixstart = 0; ixstart < vlen; ixstart++) { iy = r2->data[ixstart]; if ((iy >= 1) && (iy < vstride)) { b_iy = iy; } else { b_iy = emlrtDynamicBoundsCheckR2012b(iy, 1, vstride, (emlrtBCInfo *) &f_emlrtBCI, sp); } forceTemp->data[(b_iy + forceTemp->size[0] * ix) - 1] = 0.0; } } ix = r1->size[0] * r1->size[1]; r1->size[0] = forceTemp->size[0]; r1->size[1] = forceTemp->size[1]; emxEnsureCapacity(sp, (emxArray__common *)r1, ix, (int32_T)sizeof(boolean_T), &emlrtRTEI); loop_ub = forceTemp->size[0] * forceTemp->size[1]; for (ix = 0; ix < loop_ub; ix++) { r1->data[ix] = muDoubleScalarIsNaN(forceTemp->data[ix]); } iy = r1->size[0] * r1->size[1] - 1; vlen = 0; for (vstride = 0; vstride <= iy; vstride++) { if (r1->data[vstride]) { vlen++; } } ix = r0->size[0]; r0->size[0] = vlen; emxEnsureCapacity(sp, (emxArray__common *)r0, ix, (int32_T)sizeof(int32_T), &emlrtRTEI); vlen = 0; for (vstride = 0; vstride <= iy; vstride++) { if (r1->data[vstride]) { r0->data[vlen] = vstride + 1; vlen++; } } vstride = forceTemp->size[0]; vlen = forceTemp->size[1]; loop_ub = r0->size[0]; for (ix = 0; ix < loop_ub; ix++) { ixstart = vstride * vlen; iy = r0->data[ix]; if ((iy >= 1) && (iy < ixstart)) { c_iy = iy; } else { c_iy = emlrtDynamicBoundsCheckR2012b(iy, 1, ixstart, (emlrtBCInfo *) &g_emlrtBCI, sp); } forceTemp->data[c_iy - 1] = 0.0; } for (ix = 0; ix < 2; ix++) { b_force[ix] = force->size[ix]; } for (ix = 0; ix < 2; ix++) { b_forceTemp[ix] = forceTemp->size[ix]; } if ((b_force[0] != b_forceTemp[0]) || (b_force[1] != b_forceTemp[1])) { emlrtSizeEqCheckNDR2012b(b_force, b_forceTemp, (emlrtECInfo *)&emlrtECI, sp); } ix = force->size[0] * force->size[1]; emxEnsureCapacity(sp, (emxArray__common *)force, ix, (int32_T)sizeof(real_T), &emlrtRTEI); vlen = force->size[0]; vstride = force->size[1]; loop_ub = vlen * vstride; for (ix = 0; ix < loop_ub; ix++) { force->data[ix] += forceTemp->data[ix]; } sIdx++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } emxFree_real_T(&c_forceDir); emxFree_real_T(&b_forceDir); emxFree_real_T(&b_pointSourcePosition); emxFree_real_T(&r4); emxFree_real_T(&r3); emxFree_real_T(&b_x); emxFree_real_T(&x); emxFree_int32_T(&r2); emxFree_boolean_T(&r1); emxFree_int32_T(&r0); emxFree_real_T(&distToSource); emxFree_real_T(&forceDir); emxFree_real_T(&forceMag); emxFree_real_T(&forceTemp); emlrtHeapReferenceStackLeaveFcnR2012b(sp); }
void sum(const emlrtStack *sp, const emxArray_real_T *x, emxArray_real_T *y) { uint32_T sz[3]; int32_T vstride; int32_T k; int32_T iy; int32_T ixstart; boolean_T b11; int32_T j; int32_T ix; real_T s; emlrtStack st; emlrtStack b_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; for (vstride = 0; vstride < 3; vstride++) { sz[vstride] = (uint32_T)x->size[vstride]; } vstride = y->size[0] * y->size[1]; y->size[0] = (int32_T)sz[0]; y->size[1] = (int32_T)sz[1]; emxEnsureCapacity(sp, (emxArray__common *)y, vstride, (int32_T)sizeof(real_T), &q_emlrtRTEI); if ((x->size[0] == 0) || (x->size[1] == 0)) { vstride = y->size[0] * y->size[1]; y->size[0] = (int32_T)sz[0]; emxEnsureCapacity(sp, (emxArray__common *)y, vstride, (int32_T)sizeof(real_T), &sb_emlrtRTEI); vstride = y->size[0] * y->size[1]; y->size[1] = (int32_T)sz[1]; emxEnsureCapacity(sp, (emxArray__common *)y, vstride, (int32_T)sizeof(real_T), &sb_emlrtRTEI); k = (int32_T)sz[0] * (int32_T)sz[1]; for (vstride = 0; vstride < k; vstride++) { y->data[vstride] = 0.0; } } else { vstride = 1; for (k = 0; k < 2; k++) { vstride *= x->size[k]; } iy = -1; ixstart = -1; st.site = &be_emlrtRSI; if (1 > vstride) { b11 = false; } else { b11 = (vstride > 2147483646); } if (b11) { b_st.site = &db_emlrtRSI; check_forloop_overflow_error(&b_st); } for (j = 1; j <= vstride; j++) { ixstart++; ix = ixstart; s = x->data[ixstart]; for (k = 0; k < 2; k++) { ix += vstride; s += x->data[ix]; } iy++; y->data[iy] = s; } } }
static void c_eml_qrsolve(const emlrtStack *sp, const emxArray_real_T *A, emxArray_real_T *B, emxArray_real_T *Y) { emxArray_real_T *b_A; emxArray_real_T *work; int32_T mn; int32_T i51; int32_T ix; emxArray_real_T *tau; emxArray_int32_T *jpvt; int32_T m; int32_T n; int32_T b_mn; emxArray_real_T *vn1; emxArray_real_T *vn2; int32_T k; boolean_T overflow; boolean_T b12; int32_T i; int32_T i_i; int32_T nmi; int32_T mmi; int32_T pvt; int32_T iy; boolean_T b13; real_T xnorm; int32_T i52; real_T atmp; real_T d16; boolean_T b14; boolean_T b_i; ptrdiff_t n_t; ptrdiff_t incx_t; double * xix0_t; boolean_T exitg1; const mxArray *y; static const int32_T iv78[2] = { 1, 8 }; const mxArray *m14; char_T cv76[8]; static const char_T cv77[8] = { '%', '%', '%', 'd', '.', '%', 'd', 'e' }; char_T cv78[14]; uint32_T unnamed_idx_0; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; emlrtStack e_st; emlrtStack f_st; emlrtStack g_st; emlrtStack h_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; d_st.prev = &c_st; d_st.tls = c_st.tls; e_st.prev = &d_st; e_st.tls = d_st.tls; f_st.prev = &e_st; f_st.tls = e_st.tls; g_st.prev = &f_st; g_st.tls = f_st.tls; h_st.prev = &g_st; h_st.tls = g_st.tls; emlrtHeapReferenceStackEnterFcnR2012b(sp); emxInit_real_T(sp, &b_A, 2, &m_emlrtRTEI, true); b_emxInit_real_T(sp, &work, 1, &rb_emlrtRTEI, true); mn = (int32_T)muDoubleScalarMin(A->size[0], A->size[1]); st.site = &mc_emlrtRSI; b_st.site = &nc_emlrtRSI; c_st.site = &oc_emlrtRSI; i51 = b_A->size[0] * b_A->size[1]; b_A->size[0] = A->size[0]; b_A->size[1] = A->size[1]; emxEnsureCapacity(&c_st, (emxArray__common *)b_A, i51, (int32_T)sizeof(real_T), &m_emlrtRTEI); ix = A->size[0] * A->size[1]; for (i51 = 0; i51 < ix; i51++) { b_A->data[i51] = A->data[i51]; } b_emxInit_real_T(&c_st, &tau, 1, &m_emlrtRTEI, true); b_emxInit_int32_T(&c_st, &jpvt, 2, &m_emlrtRTEI, true); m = b_A->size[0]; n = b_A->size[1]; b_mn = muIntScalarMin_sint32(b_A->size[0], b_A->size[1]); i51 = tau->size[0]; tau->size[0] = b_mn; emxEnsureCapacity(&c_st, (emxArray__common *)tau, i51, (int32_T)sizeof(real_T), &n_emlrtRTEI); d_st.site = &mf_emlrtRSI; e_st.site = &rb_emlrtRSI; f_st.site = &sb_emlrtRSI; g_st.site = &tb_emlrtRSI; eml_signed_integer_colon(&g_st, b_A->size[1], jpvt); if ((b_A->size[0] == 0) || (b_A->size[1] == 0)) { } else { ix = b_A->size[1]; i51 = work->size[0]; work->size[0] = ix; emxEnsureCapacity(&c_st, (emxArray__common *)work, i51, (int32_T)sizeof (real_T), &m_emlrtRTEI); for (i51 = 0; i51 < ix; i51++) { work->data[i51] = 0.0; } b_emxInit_real_T(&c_st, &vn1, 1, &pb_emlrtRTEI, true); b_emxInit_real_T(&c_st, &vn2, 1, &qb_emlrtRTEI, true); d_st.site = &tc_emlrtRSI; ix = b_A->size[1]; i51 = vn1->size[0]; vn1->size[0] = ix; emxEnsureCapacity(&c_st, (emxArray__common *)vn1, i51, (int32_T)sizeof (real_T), &pb_emlrtRTEI); i51 = vn2->size[0]; vn2->size[0] = ix; emxEnsureCapacity(&c_st, (emxArray__common *)vn2, i51, (int32_T)sizeof (real_T), &qb_emlrtRTEI); k = 1; d_st.site = &nf_emlrtRSI; overflow = (b_A->size[1] > 2147483646); if (overflow) { e_st.site = &db_emlrtRSI; check_forloop_overflow_error(&e_st); } for (ix = 0; ix + 1 <= b_A->size[1]; ix++) { d_st.site = &sc_emlrtRSI; vn1->data[ix] = b_eml_xnrm2(&d_st, b_A->size[0], b_A, k); vn2->data[ix] = vn1->data[ix]; k += b_A->size[0]; } d_st.site = &rc_emlrtRSI; if (1 > b_mn) { b12 = false; } else { b12 = (b_mn > 2147483646); } if (b12) { e_st.site = &db_emlrtRSI; check_forloop_overflow_error(&e_st); } for (i = 1; i <= b_mn; i++) { i_i = (i + (i - 1) * m) - 1; nmi = n - i; mmi = m - i; d_st.site = &of_emlrtRSI; ix = eml_ixamax(&d_st, 1 + nmi, vn1, i); pvt = (i + ix) - 2; if (pvt + 1 != i) { d_st.site = &pf_emlrtRSI; e_st.site = &bc_emlrtRSI; f_st.site = &cc_emlrtRSI; ix = 1 + m * pvt; iy = 1 + m * (i - 1); g_st.site = &dc_emlrtRSI; if (1 > m) { b13 = false; } else { b13 = (m > 2147483646); } if (b13) { h_st.site = &db_emlrtRSI; check_forloop_overflow_error(&h_st); } for (k = 1; k <= m; k++) { i51 = b_A->size[0] * b_A->size[1]; xnorm = b_A->data[emlrtDynamicBoundsCheckFastR2012b(ix, 1, i51, &le_emlrtBCI, &f_st) - 1]; i51 = b_A->size[0] * b_A->size[1]; i52 = b_A->size[0] * b_A->size[1]; b_A->data[emlrtDynamicBoundsCheckFastR2012b(ix, 1, i51, &le_emlrtBCI, &f_st) - 1] = b_A->data[emlrtDynamicBoundsCheckFastR2012b(iy, 1, i52, &le_emlrtBCI, &f_st) - 1]; i51 = b_A->size[0] * b_A->size[1]; b_A->data[emlrtDynamicBoundsCheckFastR2012b(iy, 1, i51, &le_emlrtBCI, &f_st) - 1] = xnorm; ix++; iy++; } ix = jpvt->data[pvt]; jpvt->data[pvt] = jpvt->data[i - 1]; jpvt->data[i - 1] = ix; vn1->data[pvt] = vn1->data[i - 1]; vn2->data[pvt] = vn2->data[i - 1]; } if (i < m) { d_st.site = &qc_emlrtRSI; atmp = b_A->data[i_i]; d16 = 0.0; if (1 + mmi <= 0) { } else { e_st.site = &wc_emlrtRSI; xnorm = b_eml_xnrm2(&e_st, mmi, b_A, i_i + 2); if (xnorm != 0.0) { xnorm = muDoubleScalarHypot(b_A->data[i_i], xnorm); if (b_A->data[i_i] >= 0.0) { xnorm = -xnorm; } if (muDoubleScalarAbs(xnorm) < 1.0020841800044864E-292) { ix = 0; do { ix++; e_st.site = &xc_emlrtRSI; b_eml_xscal(&e_st, mmi, 9.9792015476736E+291, b_A, i_i + 2); xnorm *= 9.9792015476736E+291; atmp *= 9.9792015476736E+291; } while (!(muDoubleScalarAbs(xnorm) >= 1.0020841800044864E-292)); e_st.site = &yc_emlrtRSI; xnorm = b_eml_xnrm2(&e_st, mmi, b_A, i_i + 2); xnorm = muDoubleScalarHypot(atmp, xnorm); if (atmp >= 0.0) { xnorm = -xnorm; } d16 = (xnorm - atmp) / xnorm; e_st.site = &ad_emlrtRSI; b_eml_xscal(&e_st, mmi, 1.0 / (atmp - xnorm), b_A, i_i + 2); e_st.site = &bd_emlrtRSI; if (1 > ix) { b14 = false; } else { b14 = (ix > 2147483646); } if (b14) { f_st.site = &db_emlrtRSI; check_forloop_overflow_error(&f_st); } for (k = 1; k <= ix; k++) { xnorm *= 1.0020841800044864E-292; } atmp = xnorm; } else { d16 = (xnorm - b_A->data[i_i]) / xnorm; atmp = 1.0 / (b_A->data[i_i] - xnorm); e_st.site = &cd_emlrtRSI; b_eml_xscal(&e_st, mmi, atmp, b_A, i_i + 2); atmp = xnorm; } } } tau->data[i - 1] = d16; } else { atmp = b_A->data[i_i]; d_st.site = &pc_emlrtRSI; tau->data[i - 1] = eml_matlab_zlarfg(); } b_A->data[i_i] = atmp; if (i < n) { atmp = b_A->data[i_i]; b_A->data[i_i] = 1.0; d_st.site = &qf_emlrtRSI; eml_matlab_zlarf(&d_st, mmi + 1, nmi, i_i + 1, tau->data[i - 1], b_A, i + i * m, m, work); b_A->data[i_i] = atmp; } d_st.site = &rf_emlrtRSI; if (i + 1 > n) { b_i = false; } else { b_i = (n > 2147483646); } if (b_i) { e_st.site = &db_emlrtRSI; check_forloop_overflow_error(&e_st); } for (ix = i; ix + 1 <= n; ix++) { if (vn1->data[ix] != 0.0) { xnorm = muDoubleScalarAbs(b_A->data[(i + b_A->size[0] * ix) - 1]) / vn1->data[ix]; xnorm = 1.0 - xnorm * xnorm; if (xnorm < 0.0) { xnorm = 0.0; } atmp = vn1->data[ix] / vn2->data[ix]; atmp = xnorm * (atmp * atmp); if (atmp <= 1.4901161193847656E-8) { if (i < m) { d_st.site = &sf_emlrtRSI; e_st.site = &uc_emlrtRSI; if (mmi < 1) { xnorm = 0.0; } else { f_st.site = &vc_emlrtRSI; g_st.site = &vc_emlrtRSI; n_t = (ptrdiff_t)(mmi); g_st.site = &vc_emlrtRSI; incx_t = (ptrdiff_t)(1); i51 = b_A->size[0] * b_A->size[1]; i52 = (i + m * ix) + 1; xix0_t = (double *)(&b_A->data[emlrtDynamicBoundsCheckFastR2012b (i52, 1, i51, &vb_emlrtBCI, &f_st) - 1]); xnorm = dnrm2(&n_t, xix0_t, &incx_t); } vn1->data[ix] = xnorm; vn2->data[ix] = vn1->data[ix]; } else { vn1->data[ix] = 0.0; vn2->data[ix] = 0.0; } } else { d_st.site = &tf_emlrtRSI; vn1->data[ix] *= muDoubleScalarSqrt(xnorm); } } } } emxFree_real_T(&vn2); emxFree_real_T(&vn1); } atmp = 0.0; if (mn > 0) { xnorm = muDoubleScalarMax(A->size[0], A->size[1]) * muDoubleScalarAbs (b_A->data[0]) * 2.2204460492503131E-16; k = 0; exitg1 = false; while ((!exitg1) && (k <= mn - 1)) { if (muDoubleScalarAbs(b_A->data[k + b_A->size[0] * k]) <= xnorm) { st.site = &lc_emlrtRSI; y = NULL; m14 = emlrtCreateCharArray(2, iv78); for (i = 0; i < 8; i++) { cv76[i] = cv77[i]; } emlrtInitCharArrayR2013a(&st, 8, m14, cv76); emlrtAssign(&y, m14); b_st.site = &tg_emlrtRSI; emlrt_marshallIn(&b_st, c_sprintf(&b_st, b_sprintf(&b_st, y, emlrt_marshallOut(14.0), emlrt_marshallOut(6.0), &o_emlrtMCI), emlrt_marshallOut(xnorm), &p_emlrtMCI), "sprintf", cv78); st.site = &kc_emlrtRSI; b_eml_warning(&st, atmp, cv78); exitg1 = true; } else { atmp++; k++; } } } unnamed_idx_0 = (uint32_T)A->size[1]; i51 = Y->size[0]; Y->size[0] = (int32_T)unnamed_idx_0; emxEnsureCapacity(sp, (emxArray__common *)Y, i51, (int32_T)sizeof(real_T), &m_emlrtRTEI); ix = (int32_T)unnamed_idx_0; for (i51 = 0; i51 < ix; i51++) { Y->data[i51] = 0.0; } for (ix = 0; ix < mn; ix++) { if (tau->data[ix] != 0.0) { xnorm = B->data[ix]; i51 = A->size[0] + (int32_T)(1.0 - ((1.0 + (real_T)ix) + 1.0)); emlrtForLoopVectorCheckR2012b((1.0 + (real_T)ix) + 1.0, 1.0, A->size[0], mxDOUBLE_CLASS, i51, &ac_emlrtRTEI, sp); for (i = 0; i < i51; i++) { unnamed_idx_0 = ((uint32_T)ix + i) + 2U; xnorm += b_A->data[((int32_T)unnamed_idx_0 + b_A->size[0] * ix) - 1] * B->data[(int32_T)unnamed_idx_0 - 1]; } xnorm *= tau->data[ix]; if (xnorm != 0.0) { B->data[ix] -= xnorm; i51 = A->size[0] + (int32_T)(1.0 - ((1.0 + (real_T)ix) + 1.0)); emlrtForLoopVectorCheckR2012b((1.0 + (real_T)ix) + 1.0, 1.0, A->size[0], mxDOUBLE_CLASS, i51, &yb_emlrtRTEI, sp); for (i = 0; i < i51; i++) { unnamed_idx_0 = ((uint32_T)ix + i) + 2U; B->data[(int32_T)unnamed_idx_0 - 1] -= b_A->data[((int32_T) unnamed_idx_0 + b_A->size[0] * ix) - 1] * xnorm; } } } } emxFree_real_T(&tau); emlrtForLoopVectorCheckR2012b(1.0, 1.0, atmp, mxDOUBLE_CLASS, (int32_T)atmp, &xb_emlrtRTEI, sp); for (i = 0; i < (int32_T)atmp; i++) { Y->data[jpvt->data[i] - 1] = B->data[i]; } emlrtForLoopVectorCheckR2012b(atmp, -1.0, 1.0, mxDOUBLE_CLASS, (int32_T)-(1.0 + (-1.0 - atmp)), &wb_emlrtRTEI, sp); for (ix = 0; ix < (int32_T)-(1.0 + (-1.0 - atmp)); ix++) { xnorm = atmp + -(real_T)ix; Y->data[jpvt->data[(int32_T)xnorm - 1] - 1] = eml_div(Y->data[jpvt->data [(int32_T)xnorm - 1] - 1], b_A->data[((int32_T)xnorm + b_A->size[0] * ((int32_T)xnorm - 1)) - 1]); for (i = 0; i < (int32_T)(xnorm - 1.0); i++) { Y->data[jpvt->data[i] - 1] -= Y->data[jpvt->data[(int32_T)xnorm - 1] - 1] * b_A->data[i + b_A->size[0] * ((int32_T)xnorm - 1)]; } } emxFree_int32_T(&jpvt); emxFree_real_T(&work); emxFree_real_T(&b_A); emlrtHeapReferenceStackLeaveFcnR2012b(sp); }
/* Function Definitions */ void eye(real_T n, emxArray_real_T *I) { boolean_T p; const mxArray *y; static const int32_T iv37[2] = { 1, 28 }; const mxArray *m11; char_T cv43[28]; int32_T i; static const char_T cv44[28] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T', 'L', 'A', 'B', ':', 'N', 'o', 'n', 'I', 'n', 't', 'e', 'g', 'e', 'r', 'I', 'n', 'p', 'u', 't' }; const mxArray *b_y; static const int32_T iv38[2] = { 1, 28 }; real_T b_n; real_T c_n; const mxArray *c_y; static const int32_T iv39[2] = { 1, 21 }; char_T cv45[21]; static const char_T cv46[21] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T', 'L', 'A', 'B', ':', 'p', 'm', 'a', 'x', 's', 'i', 'z', 'e' }; int32_T loop_ub; real_T minval; boolean_T b6; emlrtPushRtStackR2012b(&dm_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&em_emlrtRSI, emlrtRootTLSGlobal); if ((n != n) || muDoubleScalarIsInf(n)) { p = FALSE; } else { p = TRUE; } if (p) { } else { emlrtPushRtStackR2012b(&oi_emlrtRSI, emlrtRootTLSGlobal); emlrt_synchGlobalsToML(); y = NULL; m11 = mxCreateCharArray(2, iv37); for (i = 0; i < 28; i++) { cv43[i] = cv44[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 28, m11, cv43); emlrtAssign(&y, m11); error(message(y, &s_emlrtMCI), &t_emlrtMCI); emlrt_synchGlobalsFromML(); emlrtPopRtStackR2012b(&oi_emlrtRSI, emlrtRootTLSGlobal); } if ((n != n) || muDoubleScalarIsInf(n)) { p = FALSE; } else { p = TRUE; } if (p) { } else { emlrtPushRtStackR2012b(&oi_emlrtRSI, emlrtRootTLSGlobal); emlrt_synchGlobalsToML(); b_y = NULL; m11 = mxCreateCharArray(2, iv38); for (i = 0; i < 28; i++) { cv43[i] = cv44[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 28, m11, cv43); emlrtAssign(&b_y, m11); error(message(b_y, &s_emlrtMCI), &t_emlrtMCI); emlrt_synchGlobalsFromML(); emlrtPopRtStackR2012b(&oi_emlrtRSI, emlrtRootTLSGlobal); } if (n <= 0.0) { b_n = 0.0; } else { if (n <= 0.0) { c_n = 0.0; } else { c_n = n; } b_n = c_n * n; } if (2.147483647E+9 >= b_n) { } else { emlrtPushRtStackR2012b(&pi_emlrtRSI, emlrtRootTLSGlobal); emlrt_synchGlobalsToML(); c_y = NULL; m11 = mxCreateCharArray(2, iv39); for (i = 0; i < 21; i++) { cv45[i] = cv46[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m11, cv45); emlrtAssign(&c_y, m11); error(message(c_y, &u_emlrtMCI), &v_emlrtMCI); emlrt_synchGlobalsFromML(); emlrtPopRtStackR2012b(&pi_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&em_emlrtRSI, emlrtRootTLSGlobal); i = I->size[0] * I->size[1]; I->size[0] = (int32_T)n; I->size[1] = (int32_T)n; emxEnsureCapacity((emxArray__common *)I, i, (int32_T)sizeof(real_T), &pb_emlrtRTEI); loop_ub = (int32_T)n * (int32_T)n; for (i = 0; i < loop_ub; i++) { I->data[i] = 0.0; } minval = muDoubleScalarMin(n, n); if ((int32_T)minval > 0) { emlrtPushRtStackR2012b(&fm_emlrtRSI, emlrtRootTLSGlobal); if (1 > (int32_T)minval) { b6 = FALSE; } else { b6 = ((int32_T)minval > 2147483646); } if (b6) { emlrtPushRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal); check_forloop_overflow_error(); emlrtPopRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&fm_emlrtRSI, emlrtRootTLSGlobal); for (i = 0; i + 1 <= (int32_T)minval; i++) { I->data[i + I->size[0] * i] = 1.0; } } emlrtPopRtStackR2012b(&dm_emlrtRSI, emlrtRootTLSGlobal); }
/* Function Definitions */ void mldivide(const emlrtStack *sp, const real_T A[16], real_T B[4]) { real_T b_A[16]; int8_T ipiv[4]; int32_T kAcol; int32_T info; int32_T j; int32_T c; int32_T ix; real_T temp; int32_T k; real_T s; int32_T b; int32_T jy; boolean_T b_kAcol; int32_T ijA; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; emlrtStack e_st; emlrtStack f_st; emlrtStack g_st; emlrtStack h_st; emlrtStack i_st; emlrtStack j_st; emlrtStack k_st; emlrtStack l_st; st.prev = sp; st.tls = sp->tls; st.site = &g_emlrtRSI; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; d_st.prev = &c_st; d_st.tls = c_st.tls; e_st.prev = &d_st; e_st.tls = d_st.tls; f_st.prev = &e_st; f_st.tls = e_st.tls; g_st.prev = &f_st; g_st.tls = f_st.tls; h_st.prev = &g_st; h_st.tls = g_st.tls; i_st.prev = &h_st; i_st.tls = h_st.tls; j_st.prev = &i_st; j_st.tls = i_st.tls; k_st.prev = &j_st; k_st.tls = j_st.tls; l_st.prev = &k_st; l_st.tls = k_st.tls; b_st.site = &h_emlrtRSI; c_st.site = &j_emlrtRSI; d_st.site = &k_emlrtRSI; e_st.site = &l_emlrtRSI; memcpy(&b_A[0], &A[0], sizeof(real_T) << 4); for (kAcol = 0; kAcol < 4; kAcol++) { ipiv[kAcol] = (int8_T)(1 + kAcol); } info = 0; for (j = 0; j < 3; j++) { c = j * 5; f_st.site = &m_emlrtRSI; g_st.site = &p_emlrtRSI; h_st.site = &q_emlrtRSI; kAcol = 0; ix = c; temp = muDoubleScalarAbs(b_A[c]); i_st.site = &r_emlrtRSI; for (k = 2; k <= 4 - j; k++) { ix++; s = muDoubleScalarAbs(b_A[ix]); if (s > temp) { kAcol = k - 1; temp = s; } } if (b_A[c + kAcol] != 0.0) { if (kAcol != 0) { ipiv[j] = (int8_T)((j + kAcol) + 1); ix = j; kAcol += j; for (k = 0; k < 4; k++) { temp = b_A[ix]; b_A[ix] = b_A[kAcol]; b_A[kAcol] = temp; ix += 4; kAcol += 4; } } b = (c - j) + 4; f_st.site = &n_emlrtRSI; for (jy = c + 1; jy + 1 <= b; jy++) { b_A[jy] /= b_A[c]; } } else { info = j + 1; } f_st.site = &o_emlrtRSI; g_st.site = &t_emlrtRSI; h_st.site = &u_emlrtRSI; i_st.site = &v_emlrtRSI; j_st.site = &w_emlrtRSI; kAcol = c; jy = c + 4; for (k = 1; k <= 3 - j; k++) { temp = b_A[jy]; if (b_A[jy] != 0.0) { ix = c + 1; b = (kAcol - j) + 8; k_st.site = &x_emlrtRSI; if (kAcol + 6 > b) { b_kAcol = false; } else { b_kAcol = (b > 2147483646); } if (b_kAcol) { l_st.site = &s_emlrtRSI; check_forloop_overflow_error(&l_st); } for (ijA = kAcol + 5; ijA + 1 <= b; ijA++) { b_A[ijA] += b_A[ix] * -temp; ix++; } } jy += 4; kAcol += 4; } } if ((info == 0) && (!(b_A[15] != 0.0))) { info = 4; } if (info > 0) { c_st.site = &i_emlrtRSI; d_st.site = &y_emlrtRSI; eml_warning(&d_st); } for (kAcol = 0; kAcol < 3; kAcol++) { if (ipiv[kAcol] != kAcol + 1) { temp = B[kAcol]; B[kAcol] = B[ipiv[kAcol] - 1]; B[ipiv[kAcol] - 1] = temp; } } for (k = 0; k < 4; k++) { kAcol = k << 2; if (B[k] != 0.0) { for (jy = k + 1; jy + 1 < 5; jy++) { B[jy] -= B[k] * b_A[jy + kAcol]; } } } for (k = 3; k > -1; k += -1) { kAcol = k << 2; if (B[k] != 0.0) { B[k] /= b_A[k + kAcol]; for (jy = 0; jy + 1 <= k; jy++) { B[jy] -= B[k] * b_A[jy + kAcol]; } } } }
/* Function Definitions */ void generateOFDMSignal(const emlrtStack *sp, OFDMDemodulator_1 *iobj_0, OFDMDemodulator_1 *iobj_1, OFDMDemodulator_1 **hPreambleDemod, OFDMDemodulator_1 **hDataDemod, creal_T r[25600], d_struct_T *tx) { OFDMModulator_1 hDataMod; OFDMModulator hPreambleMod; creal_T shortPreambleOFDM[64]; int32_T i; creal_T completeShortPreambleOFDM[160]; creal_T longPreambleOFDM[64]; creal_T completeLongPreambleOFDM[160]; real_T originalData[560]; real_T x[560]; int32_T ib; real_T b_originalData[560]; commcodegen_CRCGenerator_6 hGen; real_T dataWithCRC[563]; commcodegen_BPSKModulator_1 hMod; creal_T modData[563]; real_T varargin_1[13]; int32_T k; commcodegen_BPSKModulator_1 *obj; const mxArray *y; static const int32_T iv54[2] = { 1, 45 }; const mxArray *m10; char_T cv58[45]; static const char_T cv59[45] = { 'M', 'A', 'T', 'L', 'A', 'B', ':', 's', 'y', 's', 't', 'e', 'm', ':', 'm', 'e', 't', 'h', 'o', 'd', 'C', 'a', 'l', 'l', 'e', 'd', 'W', 'h', 'e', 'n', 'R', 'e', 'l', 'e', 'a', 's', 'e', 'd', 'C', 'o', 'd', 'e', 'g', 'e', 'n' }; const mxArray *b_y; static const int32_T iv55[2] = { 1, 4 }; char_T cv60[4]; static const char_T cv61[4] = { 's', 't', 'e', 'p' }; const mxArray *c_y; static const int32_T iv56[2] = { 1, 51 }; char_T cv62[51]; static const char_T cv63[51] = { 'M', 'A', 'T', 'L', 'A', 'B', ':', 's', 'y', 's', 't', 'e', 'm', ':', 'm', 'e', 't', 'h', 'o', 'd', 'C', 'a', 'l', 'l', 'e', 'd', 'W', 'h', 'e', 'n', 'L', 'o', 'c', 'k', 'e', 'd', 'R', 'e', 'l', 'e', 'a', 's', 'e', 'd', 'C', 'o', 'd', 'e', 'g', 'e', 'n' }; const mxArray *d_y; static const int32_T iv57[2] = { 1, 5 }; char_T cv64[5]; static const char_T cv65[5] = { 's', 'e', 't', 'u', 'p' }; static const int8_T value[8] = { 13, 1, 1, 1, 1, 1, 1, 1 }; boolean_T anyInputSizeChanged; boolean_T exitg2; static const int8_T iv58[8] = { 13, 1, 1, 1, 1, 1, 1, 1 }; creal_T varargout_1[13]; creal_T b_modData[576]; creal_T ofdmData[576]; comm_PNSequence_5 hPN; comm_PNSequence_5 *b_obj; static const int8_T iv59[8] = { 1, 0, 0, 0, 1, 0, 0, 1 }; static const int8_T iv60[7] = { 0, 0, 0, 0, 0, 0, 1 }; int8_T pilot[12]; uint8_T tmp; uint8_T tmp2; int8_T pilots[48]; int32_T ia; real_T b_pilots[48]; creal_T b_r[960]; creal_T preambles[320]; creal_T c_r[1280]; OFDMDemodulator_1 *object; int8_T b_data[4]; int32_T exitg1; int32_T exponent; boolean_T b2; int32_T i12; const mxArray *e_y; static const int32_T iv61[2] = { 1, 13 }; char_T cv66[13]; static const char_T cv67[13] = { 'c', 'o', 'm', 'm', ':', 'O', 'F', 'D', 'M', ':', 'x', 'x', 'x' }; static const creal_T dcv3[53] = { { 0.0, 0.0 }, { 0.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { -1.0, -1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { -1.0, -1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { -1.0, -1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { -1.0, -1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { - 1.0, -1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 } }; static const int8_T iv62[53] = { 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 0, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1 }; static const int8_T iv63[48] = { 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53 }; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; emlrtStack e_st; emlrtStack f_st; emlrtStack g_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; d_st.prev = &c_st; d_st.tls = c_st.tls; e_st.prev = &d_st; e_st.tls = d_st.tls; f_st.prev = &e_st; f_st.tls = e_st.tls; g_st.prev = &f_st; g_st.tls = f_st.tls; emlrtHeapReferenceStackEnterFcnR2012b(sp); emxInitStruct_OFDMModulator_1(sp, &hDataMod, &s_emlrtRTEI, TRUE); emxInitStruct_OFDMModulator(sp, &hPreambleMod, &t_emlrtRTEI, TRUE); /* generateOFDMSignal: Generate OFDM signal based on the 802.11a standard. */ /* This function returns the time domain signal and a structure containing */ /* details about the signal itself. This information is required by the */ /* receiver to operate correctly. */ /* % System Parameters */ /* OFDM modulator FFT size */ /* Enable moving averages for estimates */ /* 1e3 */ /* Message to transmit */ /* String holder */ /* coder.varsize('payloadMessage', [1, 80], [0 1]); */ /* payloadMessage = ''; */ /* % Create Short Preamble */ /* % [-27:-17] */ /* % [-16:-1] */ /* % [0:15] */ /* [16:27] */ /* % Create modulator */ /* hPreambleMod = OFDMModulator(... */ /* 'NumGuardBandCarriers', [6; 5],... */ /* 'CyclicPrefixLength', 0,... */ /* 'FFTLength' , FFTLength,... */ /* 'NumSymbols', 1); */ /* Create modulator */ st.site = &lk_emlrtRSI; OFDMModulator_OFDMModulator(&hPreambleMod); /* Modulate and scale */ st.site = &mk_emlrtRSI; SystemCore_step(&st, &hPreambleMod, shortPreambleOFDM); st.site = &mk_emlrtRSI; for (i = 0; i < 64; i++) { shortPreambleOFDM[i].re *= 1.4719601443879744; shortPreambleOFDM[i].im *= 1.4719601443879744; } /* Form 10 Short Preambles */ memcpy(&completeShortPreambleOFDM[0], &shortPreambleOFDM[0], sizeof(creal_T) << 6); memcpy(&completeShortPreambleOFDM[64], &shortPreambleOFDM[0], sizeof(creal_T) << 6); memcpy(&completeShortPreambleOFDM[128], &shortPreambleOFDM[0], sizeof(creal_T) << 5); /* % Create Long Preamble */ /* Modulate */ st.site = &nk_emlrtRSI; b_SystemCore_step(&st, &hPreambleMod, longPreambleOFDM); /* Form 2 Long Preambles */ memcpy(&completeLongPreambleOFDM[0], &longPreambleOFDM[32], sizeof(creal_T) << 5); memcpy(&completeLongPreambleOFDM[32], &longPreambleOFDM[0], sizeof(creal_T) << 6); memcpy(&completeLongPreambleOFDM[96], &longPreambleOFDM[0], sizeof(creal_T) << 6); /* % Generate Data */ /* Use string as message */ st.site = &ok_emlrtRSI; b_OFDMletters2bits(&st, originalData); st.site = &pk_emlrtRSI; for (i = 0; i < 80; i++) { for (ib = 0; ib < 7; ib++) { x[ib + 7 * i] = originalData[i + 80 * ib]; } } memcpy(&b_originalData[0], &x[0], 560U * sizeof(real_T)); /* Generate CRC */ st.site = &qk_emlrtRSI; b_CRCGenerator_CRCGenerator(&hGen); st.site = &rk_emlrtRSI; e_SystemCore_step(&st, &hGen, b_originalData, dataWithCRC); /* Add CRC */ /* Construct modulator for each subcarrier */ st.site = &sk_emlrtRSI; BPSKModulator_BPSKModulator(&hMod); /* BPSK */ /* Apply modulator for each subcarrier */ st.site = &tk_emlrtRSI; f_SystemCore_step(&st, &hMod, dataWithCRC, modData); /* Pad IFFT */ st.site = &uk_emlrtRSI; b_st.site = &u_emlrtRSI; emlrtRandu(varargin_1, 13); for (k = 0; k < 13; k++) { b_st.site = &v_emlrtRSI; b_st.site = &v_emlrtRSI; c_st.site = &p_emlrtRSI; varargin_1[k] = muDoubleScalarFloor(varargin_1[k] * 2.0); } st.site = &uk_emlrtRSI; obj = &hMod; if (!obj->isReleased) { } else { y = NULL; m10 = mxCreateCharArray(2, iv54); for (i = 0; i < 45; i++) { cv58[i] = cv59[i]; } emlrtInitCharArrayR2013a(&st, 45, m10, cv58); emlrtAssign(&y, m10); b_y = NULL; m10 = mxCreateCharArray(2, iv55); for (i = 0; i < 4; i++) { cv60[i] = cv61[i]; } emlrtInitCharArrayR2013a(&st, 4, m10, cv60); emlrtAssign(&b_y, m10); b_st.site = &cb_emlrtRSI; c_error(&b_st, message(&b_st, y, b_y, &emlrtMCI), &emlrtMCI); } if (!obj->isInitialized) { b_st.site = &cb_emlrtRSI; if (!obj->isInitialized) { } else { c_y = NULL; m10 = mxCreateCharArray(2, iv56); for (i = 0; i < 51; i++) { cv62[i] = cv63[i]; } emlrtInitCharArrayR2013a(&b_st, 51, m10, cv62); emlrtAssign(&c_y, m10); d_y = NULL; m10 = mxCreateCharArray(2, iv57); for (i = 0; i < 5; i++) { cv64[i] = cv65[i]; } emlrtInitCharArrayR2013a(&b_st, 5, m10, cv64); emlrtAssign(&d_y, m10); c_st.site = &cb_emlrtRSI; c_error(&c_st, message(&c_st, c_y, d_y, &emlrtMCI), &emlrtMCI); } c_st.site = &cb_emlrtRSI; obj->isInitialized = TRUE; d_st.site = &db_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; e_st.site = &db_emlrtRSI; d_st.site = &cb_emlrtRSI; e_st.site = &db_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; e_st.site = &db_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; for (i = 0; i < 8; i++) { obj->inputVarSize1[i] = (uint32_T)value[i]; } e_st.site = &db_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; e_st.site = &cb_emlrtRSI; e_st.site = &cb_emlrtRSI; f_st.site = &gg_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; e_st.site = &gg_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &gg_emlrtRSI; d_st.site = &gg_emlrtRSI; e_st.site = &db_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &gg_emlrtRSI; e_st.site = NULL; } b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &gg_emlrtRSI; b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; anyInputSizeChanged = FALSE; k = 0; exitg2 = FALSE; while ((exitg2 == FALSE) && (k < 8)) { if (obj->inputVarSize1[k] != (uint32_T)iv58[k]) { anyInputSizeChanged = TRUE; c_st.site = &cb_emlrtRSI; for (i = 0; i < 8; i++) { obj->inputVarSize1[i] = (uint32_T)value[i]; } d_st.site = &db_emlrtRSI; exitg2 = TRUE; } else { k++; } } if (anyInputSizeChanged) { b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; } b_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &gg_emlrtRSI; b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; d_Nondirect_stepImpl(obj, varargin_1, varargout_1); memcpy(&b_modData[0], &modData[0], 563U * sizeof(creal_T)); memcpy(&b_modData[563], &varargout_1[0], 13U * sizeof(creal_T)); /* Calculate required data sizes for correct receiver operation */ /* Save desired message size */ /* Save number of transmitted frames */ /* Convert data into subcarrier streams */ st.site = &vk_emlrtRSI; memcpy(&ofdmData[0], &b_modData[0], 576U * sizeof(creal_T)); /* Create Pilots */ st.site = &wk_emlrtRSI; b_obj = &hPN; /* System object Constructor function: comm.PNSequence */ b_obj->S0_isInitialized = FALSE; b_obj->S1_isReleased = FALSE; for (i = 0; i < 8; i++) { b_obj->P0_Polynomial[i] = (uint8_T)iv59[i]; } for (i = 0; i < 7; i++) { b_obj->P1_IniState[i] = 1; b_obj->P2_Mask[i] = (uint8_T)iv60[i]; } st.site = &xk_emlrtRSI; b_obj = &hPN; if (!b_obj->S0_isInitialized) { b_obj->S0_isInitialized = TRUE; if (b_obj->S1_isReleased) { emlrtErrorWithMessageIdR2012b(&st, &bc_emlrtRTEI, "MATLAB:system:runtimeMethodCalledWhenReleasedCodegen", 0); } b_st.site = NULL; b_st.site = NULL; /* System object Initialization function: comm.PNSequence */ for (ib = 0; ib < 7; ib++) { b_obj->W0_shiftReg[ib] = b_obj->P1_IniState[ib]; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, &b_st); } } b_st.site = NULL; /* System object Outputs function: comm.PNSequence */ for (ib = 0; ib < 12; ib++) { tmp = 0; for (i = 0; i < 7; i++) { tmp = (uint8_T)((uint32_T)tmp + (uint8_T)((uint32_T)b_obj->P0_Polynomial[i + 1] * b_obj->W0_shiftReg[i])); } tmp &= 1; tmp2 = 0; for (i = 0; i < 7; i++) { tmp2 = (uint8_T)((uint32_T)tmp2 + (uint8_T)((uint32_T)b_obj->W0_shiftReg[i] * b_obj->P2_Mask[i])); } pilot[ib] = (int8_T)(tmp2 & 1); for (i = 5; i > -1; i += -1) { b_obj->W0_shiftReg[i + 1] = b_obj->W0_shiftReg[i]; } b_obj->W0_shiftReg[0U] = tmp; } /* Create pilot */ st.site = &yk_emlrtRSI; ib = 0; for (i = 0; i < 4; i++) { ia = 0; for (k = 0; k < 12; k++) { pilots[ib] = pilot[ia]; b_st.site = &ng_emlrtRSI; ia++; b_st.site = &og_emlrtRSI; ib++; } } /* Expand to all pilot tones */ st.site = &al_emlrtRSI; for (i = 0; i < 12; i++) { for (ib = 0; ib < 4; ib++) { b_pilots[ib + (i << 2)] = 2.0 * (real_T)(pilots[i + 12 * ib] < 1) - 1.0; } } /* Bipolar to unipolar */ st.site = &bl_emlrtRSI; for (i = 0; i < 12; i++) { b_pilots[3 + (i << 2)] = -b_pilots[3 + (i << 2)]; } /* Invert last pilot */ /* Construct Modulator */ st.site = &cl_emlrtRSI; b_OFDMModulator_OFDMModulator(&st, &hDataMod); /* Modulate */ st.site = &dl_emlrtRSI; d_SystemCore_step(&st, &hDataMod, ofdmData, b_pilots, b_r); /* Add preambles to data */ memcpy(&preambles[0], &completeShortPreambleOFDM[0], 160U * sizeof(creal_T)); memcpy(&preambles[160], &completeLongPreambleOFDM[0], 160U * sizeof(creal_T)); memcpy(&c_r[0], &preambles[0], 320U * sizeof(creal_T)); memcpy(&c_r[320], &b_r[0], 960U * sizeof(creal_T)); /* Repeat frame */ st.site = &el_emlrtRSI; ib = 0; for (i = 0; i < 20; i++) { ia = 0; for (k = 0; k < 1280; k++) { r[ib] = c_r[ia]; b_st.site = &ng_emlrtRSI; ia++; b_st.site = &og_emlrtRSI; ib++; } } /* Save Demodulator object data for receiver */ /* hDataDemod = get(OFDMDemodulator(hDataMod)); */ /* hPreambleDemod = get(OFDMDemodulator(hPreambleMod)); */ st.site = &fl_emlrtRSI; object = iobj_0; *hDataDemod = object; b_st.site = &jj_emlrtRSI; object = *hDataDemod; c_st.site = &y_emlrtRSI; d_st.site = &bb_emlrtRSI; d_st.site = &bb_emlrtRSI; object->isInitialized = FALSE; object->isReleased = FALSE; e_st.site = &cb_emlrtRSI; f_st.site = &db_emlrtRSI; e_st.site = &cb_emlrtRSI; f_st.site = &db_emlrtRSI; c_st.site = &y_emlrtRSI; c_st.site = &ab_emlrtRSI; b_st.site = &kj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &lj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &mj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &nj_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &oj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &pj_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &qj_emlrtRSI; c_st.site = &db_emlrtRSI; /* OFDMBase Base object for OFDMModulator and OFDMDemodulator System objects */ /* Copyright 2013 The MathWorks, Inc. */ /* FFTLength FFT length */ /* Specify the IFFT length. This property can be set to an integer */ /* scalar. The value must be a power of two. The default value of */ /* this property is 64. */ /* CyclicPrefixLength Cyclic prefix length */ /* Specify the cyclic prefix length. This property can be set to a */ /* non-negative interher scalar. The default value of this property is 16. */ /* NumGuardBandCarriers Number of guard bands */ /* Specify the lower and upper guard bands in frequency domain.This */ /* property can be set to a non-nagative two-element vector. */ /* The default setting of this property is [6 5]. */ /* NumSymbols Number of OFDM symbols */ /* Specify the number of OFDM symbols at the output. The default value */ /* of this property is 1. */ /* PilotCarrierIndices Pilot subcarrier indices */ /* Specify the locations where pilots are to be inserted. You can */ /* set this property to a numeric scalar, column vector, matrix, or */ /* 3-D array. The defalut value of the property is [-21; -7; 7; 21]. */ /* Nontunable ideally */ /* Constructor */ /* validateattributes(fftLen, {'numeric'}, ... */ /* {'real','scalar','integer','finite','>=',8}, ... */ /* [class(obj) '.' propName], propName); */ /* validateattributes(CPLen, {'numeric'}, ... */ /* {'real','row','integer','nonnegative','finite'}, ... */ /* [class(obj) '.' propName], propName); */ /* validateattributes(guardBands, {'numeric'}, ... */ /* {'real','integer','nonnegative','finite','size', [2, 1]}, ... */ /* [class(obj) '.' propName], propName); */ /* validateattributes(numSym, {'numeric'}, ... */ /* {'real','scalar','integer','positive','finite'}, ... */ /* [class(obj) '.' propName], propName); */ /* validateattributes(pilotIdx, {'numeric'}, ... */ /* {'real','integer','positive','finite','3d'}, ... */ /* [class(obj) '.' propName], propName); */ /* Check the 3rd dimension for numTx */ d_st.site = &uh_emlrtRSI; e_st.site = &vh_emlrtRSI; for (k = 0; k < 4; k++) { b_data[k] = (int8_T)(12 + 14 * k); } f_st.site = &mi_emlrtRSI; i = 0; f_st.site = &ki_emlrtRSI; f_st.site = &ji_emlrtRSI; k = 1; while (k <= 4) { ib = b_data[k - 1]; do { exitg1 = 0; f_st.site = &ii_emlrtRSI; k++; if (k > 4) { exitg1 = 1; } else { f_st.site = &hi_emlrtRSI; frexp((real_T)ib / 2.0, &exponent); if (muDoubleScalarAbs(ib - b_data[k - 1]) < ldexp(1.0, exponent - 53)) { anyInputSizeChanged = TRUE; } else { anyInputSizeChanged = FALSE; } if (!anyInputSizeChanged) { exitg1 = 1; } } } while (exitg1 == 0); f_st.site = &gi_emlrtRSI; i++; b_data[i - 1] = (int8_T)ib; f_st.site = &fi_emlrtRSI; f_st.site = &fi_emlrtRSI; } f_st.site = &bi_emlrtRSI; f_st.site = &ai_emlrtRSI; f_st.site = &wh_emlrtRSI; if (1 > i) { b2 = FALSE; } else { b2 = (i > 2147483646); } if (b2) { g_st.site = &bg_emlrtRSI; check_forloop_overflow_error(&g_st); } d_st.site = &uh_emlrtRSI; d_st.site = &uh_emlrtRSI; if (1 > i) { i12 = 0; } else { i12 = i; } if (!(4 != i12)) { } else { e_y = NULL; m10 = mxCreateCharArray(2, iv61); for (i = 0; i < 13; i++) { cv66[i] = cv67[i]; } emlrtInitCharArrayR2013a(&d_st, 13, m10, cv66); emlrtAssign(&e_y, m10); e_st.site = &mv_emlrtRSI; c_error(&e_st, b_message(&e_st, e_y, &g_emlrtMCI), &g_emlrtMCI); } /* Error message: */ /* If pilot index is 2-D, the indices per symbol must be unique; */ /* If pilot index is 3-D, the indices across transmit antennas per symbol must be unique. */ c_st.site = &db_emlrtRSI; st.site = &gl_emlrtRSI; object = iobj_1; *hPreambleDemod = object; b_st.site = &jj_emlrtRSI; object = *hPreambleDemod; c_st.site = &y_emlrtRSI; d_st.site = &bb_emlrtRSI; d_st.site = &bb_emlrtRSI; object->isInitialized = FALSE; object->isReleased = FALSE; e_st.site = &cb_emlrtRSI; f_st.site = &db_emlrtRSI; e_st.site = &cb_emlrtRSI; f_st.site = &db_emlrtRSI; c_st.site = &y_emlrtRSI; c_st.site = &ab_emlrtRSI; b_st.site = &kj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &lj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &mj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &nj_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &oj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &pj_emlrtRSI; c_st.site = &db_emlrtRSI; /* Calcuate OFDM frequency bin size */ /* Calculate locations of pilots without guardbands */ /* Calculate locations of subcarrier datastreams without guardbands */ /* Remove guardband offsets */ /* Remove index offsets for pilots and guardbands */ /* dataSubcarrierIndexies([pilotLocationsWithoutGuardbands;DCNullLocation]) = [];%Remove pilot and DCNull locations */ /* Create return structure */ for (i = 0; i < 560; i++) { tx->originalData[i] = b_originalData[i]; } for (i = 0; i < 64; i++) { tx->shortPreambleOFDM[i] = shortPreambleOFDM[i]; } for (i = 0; i < 160; i++) { tx->completeShortPreambleOFDM[i] = completeShortPreambleOFDM[i]; } for (i = 0; i < 53; i++) { tx->shortPreamble[i] = dcv3[i]; } for (i = 0; i < 53; i++) { tx->longPreamble[i] = iv62[i]; } for (i = 0; i < 64; i++) { tx->longPreambleOFDM[i] = longPreambleOFDM[i]; } for (i = 0; i < 160; i++) { tx->completeLongPreambleOFDM[i] = completeLongPreambleOFDM[i]; } for (i = 0; i < 48; i++) { tx->pilots[i] = b_pilots[i]; } for (i = 0; i < 320; i++) { tx->preambles[i] = preambles[i]; } for (i = 0; i < 4; i++) { tx->pilotLocationsWithoutGuardbands[i] = 6.0 + 14.0 * (real_T)i; } tx->dataSubcarrierIndexies.size[0] = 1; tx->dataSubcarrierIndexies.size[1] = 48; for (i = 0; i < 48; i++) { tx->dataSubcarrierIndexies.data[i] = iv63[i]; } tx->samplingFreq = 5.0E+6; tx->FFTLength = 64.0; tx->enableMA = TRUE; tx->numCarriers = 48.0; tx->padBits = 13.0; tx->numSamples = 576.0; tx->messageCharacters = 80.0; tx->numFrames = 20.0; tx->frameLength = 1280.0; tx->freqBin = 78125.0; tx->DecimationFactor = 0.0; tx->receiveBufferLength = 0.0; /* padBits: 13 */ /* numSamples: 576 */ /* messageCharacters: 80 */ /* numFrames: 1000 */ /* frameLength: 1280 */ /* freqBin: 312500 */ /* hDataDemod: [1x1 struct] */ /* hPreambleDemod: [1x1 struct] */ st.site = NULL; b_Destructor(&hPN); emxFreeStruct_OFDMModulator(&hPreambleMod); emxFreeStruct_OFDMModulator_1(&hDataMod); emlrtHeapReferenceStackLeaveFcnR2012b(sp); }
/* Function Definitions */ void xgetrf(const emlrtStack *sp, real_T A[16], int32_T ipiv[4]) { int32_T iy; int32_T j; int32_T c; int32_T ix; real_T smax; int32_T jy; real_T s; int32_T b; int32_T b_j; boolean_T b_iy; int32_T ijA; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; emlrtStack e_st; emlrtStack f_st; emlrtStack g_st; st.prev = sp; st.tls = sp->tls; st.site = &v_emlrtRSI; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; d_st.prev = &c_st; d_st.tls = c_st.tls; e_st.prev = &d_st; e_st.tls = d_st.tls; f_st.prev = &e_st; f_st.tls = e_st.tls; g_st.prev = &f_st; g_st.tls = f_st.tls; for (iy = 0; iy < 4; iy++) { ipiv[iy] = 1 + iy; } for (j = 0; j < 3; j++) { c = j * 5; b_st.site = &w_emlrtRSI; c_st.site = &ab_emlrtRSI; iy = 0; ix = c; smax = muDoubleScalarAbs(A[c]); d_st.site = &bb_emlrtRSI; for (jy = 2; jy <= 4 - j; jy++) { ix++; s = muDoubleScalarAbs(A[ix]); if (s > smax) { iy = jy - 1; smax = s; } } if (A[c + iy] != 0.0) { if (iy != 0) { ipiv[j] = (j + iy) + 1; ix = j; iy += j; for (jy = 0; jy < 4; jy++) { smax = A[ix]; A[ix] = A[iy]; A[iy] = smax; ix += 4; iy += 4; } } b = (c - j) + 4; b_st.site = &x_emlrtRSI; for (iy = c + 1; iy + 1 <= b; iy++) { A[iy] /= A[c]; } } b_st.site = &y_emlrtRSI; c_st.site = &db_emlrtRSI; d_st.site = &eb_emlrtRSI; e_st.site = &fb_emlrtRSI; iy = c; jy = c + 4; f_st.site = &gb_emlrtRSI; for (b_j = 1; b_j <= 3 - j; b_j++) { smax = A[jy]; if (A[jy] != 0.0) { ix = c + 1; b = (iy - j) + 8; f_st.site = &hb_emlrtRSI; if (iy + 6 > b) { b_iy = false; } else { b_iy = (b > 2147483646); } if (b_iy) { g_st.site = &cb_emlrtRSI; check_forloop_overflow_error(&g_st, true); } for (ijA = iy + 5; ijA + 1 <= b; ijA++) { A[ijA] += A[ix] * -smax; ix++; } } jy += 4; iy += 4; } } }
boolean_T b_any(const emxArray_boolean_T *x) { boolean_T y; boolean_T overflow; boolean_T p; int32_T i; int32_T exitg2; const mxArray *b_y; static const int32_T iv35[2] = { 1, 41 }; const mxArray *m10; char_T cv39[41]; static const char_T cv40[41] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 'e', 'm', 'l', '_', 'a', 'l', 'l', '_', 'o', 'r', '_', 'a', 'n', 'y', '_', 's', 'p', 'e', 'c', 'i', 'a', 'l', 'E', 'm', 'p', 't', 'y' }; const mxArray *c_y; static const int32_T iv36[2] = { 1, 51 }; char_T cv41[51]; static const char_T cv42[51] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 'e', 'm', 'l', '_', 'a', 'l', 'l', '_', 'o', 'r', '_', 'a', 'n', 'y', '_', 'a', 'u', 't', 'o', 'D', 'i', 'm', 'I', 'n', 'c', 'o', 'm', 'p', 'a', 't', 'i', 'b', 'i', 'l', 'i', 't', 'y' }; boolean_T exitg1; emlrtPushRtStackR2012b(&gj_emlrtRSI, emlrtRootTLSGlobal); overflow = FALSE; p = FALSE; i = 0; do { exitg2 = 0; if (i < 2) { if (x->size[i] != 0) { exitg2 = 1; } else { i++; } } else { p = TRUE; exitg2 = 1; } } while (exitg2 == 0); if (!p) { } else { overflow = TRUE; } if (!overflow) { } else { emlrtPushRtStackR2012b(&hj_emlrtRSI, emlrtRootTLSGlobal); emlrt_synchGlobalsToML(); b_y = NULL; m10 = mxCreateCharArray(2, iv35); for (i = 0; i < 41; i++) { cv39[i] = cv40[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 41, m10, cv39); emlrtAssign(&b_y, m10); error(message(b_y, &bb_emlrtMCI), &cb_emlrtMCI); emlrt_synchGlobalsFromML(); emlrtPopRtStackR2012b(&hj_emlrtRSI, emlrtRootTLSGlobal); } if ((x->size[1] == 1) || (x->size[1] != 1)) { overflow = TRUE; } else { overflow = FALSE; } if (overflow) { } else { emlrtPushRtStackR2012b(&ij_emlrtRSI, emlrtRootTLSGlobal); emlrt_synchGlobalsToML(); c_y = NULL; m10 = mxCreateCharArray(2, iv36); for (i = 0; i < 51; i++) { cv41[i] = cv42[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 51, m10, cv41); emlrtAssign(&c_y, m10); error(message(c_y, &db_emlrtMCI), &eb_emlrtMCI); emlrt_synchGlobalsFromML(); emlrtPopRtStackR2012b(&ij_emlrtRSI, emlrtRootTLSGlobal); } y = FALSE; emlrtPushRtStackR2012b(&jj_emlrtRSI, emlrtRootTLSGlobal); if (1 > x->size[1]) { overflow = FALSE; } else { overflow = (x->size[1] > 2147483646); } if (overflow) { emlrtPushRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal); check_forloop_overflow_error(); emlrtPopRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&jj_emlrtRSI, emlrtRootTLSGlobal); i = 1; exitg1 = FALSE; while ((exitg1 == FALSE) && (i <= x->size[1])) { overflow = (x->data[i - 1] == 0); if (!overflow) { y = TRUE; exitg1 = TRUE; } else { i++; } } emlrtPopRtStackR2012b(&gj_emlrtRSI, emlrtRootTLSGlobal); return y; }
/* Function Definitions */ static void b_eml_sort(const emlrtStack *sp, const int32_T x_size[1], int32_T dim, real_T y_data[195], int32_T y_size[1], int32_T idx_data[195], int32_T idx_size[1]) { int32_T vlen; int32_T vwork_size[1]; int32_T vstride; boolean_T b6; int32_T k; int32_T i1; boolean_T b7; int32_T j; int32_T iidx_size[1]; int32_T iidx_data[195]; int32_T ix; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; st.prev = sp; st.tls = sp->tls; st.site = &vr_emlrtRSI; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; d_st.prev = &c_st; d_st.tls = c_st.tls; eml_assert_valid_dim(); if (dim <= 1) { vlen = x_size[0] - 1; } else { vlen = 0; } vwork_size[0] = (uint8_T)(vlen + 1); y_size[0] = x_size[0]; idx_size[0] = (uint8_T)x_size[0]; st.site = &wr_emlrtRSI; b_st.site = &vq_emlrtRSI; vstride = 1; c_st.site = &wq_emlrtRSI; if (1 > dim - 1) { b6 = FALSE; } else { b6 = (dim - 1 > 2147483646); } if (b6) { d_st.site = &eg_emlrtRSI; check_forloop_overflow_error(&d_st); } k = 1; while (k <= dim - 1) { c_st.site = &sk_emlrtRSI; vstride *= x_size[0]; k = 2; } st.site = &xr_emlrtRSI; st.site = &xr_emlrtRSI; st.site = &yr_emlrtRSI; b_st.site = &xq_emlrtRSI; k = dim + 1; while (k < 3) { c_st.site = &ld_emlrtRSI; k = 3; } st.site = &as_emlrtRSI; b_st.site = &dg_emlrtRSI; i1 = -1; st.site = &bs_emlrtRSI; st.site = &cs_emlrtRSI; b_st.site = &dg_emlrtRSI; if (1 > vstride) { b7 = FALSE; } else { b7 = (vstride > 2147483646); } if (b7) { b_st.site = &eg_emlrtRSI; check_forloop_overflow_error(&b_st); } for (j = 1; j <= vstride; j++) { st.site = &ds_emlrtRSI; i1++; st.site = &es_emlrtRSI; st.site = &fs_emlrtRSI; eml_sort_idx(vwork_size, iidx_data, iidx_size); ix = i1; for (k = 0; k <= vlen; k++) { y_data[ix] = 0.0; idx_data[ix] = iidx_data[k]; st.site = &gs_emlrtRSI; ix += vstride; } } }
real_T logpdf(const emxArray_real_T *x, const emxArray_real_T *A, real_T C) { real_T f; emxArray_real_T *a; int32_T i2; int32_T i; const mxArray *y; static const int32_T iv2[2] = { 1, 45 }; const mxArray *m0; char_T cv1[45]; static const char_T cv2[45] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 'm', 't', 'i', 'm', 'e', 's', '_', 'n', 'o', 'D', 'y', 'n', 'a', 'm', 'i', 'c', 'S', 'c', 'a', 'l', 'a', 'r', 'E', 'x', 'p', 'a', 'n', 's', 'i', 'o', 'n' }; const mxArray *b_y; static const int32_T iv3[2] = { 1, 21 }; char_T cv3[21]; static const char_T cv4[21] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T', 'L', 'A', 'B', ':', 'i', 'n', 'n', 'e', 'r', 'd', 'i', 'm' }; emxArray_real_T *c_y; int32_T loop_ub; int32_T i3; uint32_T unnamed_idx_0; real_T alpha1; real_T beta1; char_T TRANSB; char_T TRANSA; ptrdiff_t m_t; ptrdiff_t n_t; ptrdiff_t k_t; ptrdiff_t lda_t; ptrdiff_t ldb_t; ptrdiff_t ldc_t; double * alpha1_t; double * Aia0_t; double * Bib0_t; double * beta1_t; double * Cic0_t; emxArray_real_T *b_x; boolean_T overflow; boolean_T p; int32_T exitg1; const mxArray *d_y; static const int32_T iv4[2] = { 1, 30 }; char_T cv5[30]; static const char_T cv6[30] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 's', 'u', 'm', '_', 's', 'p', 'e', 'c', 'i', 'a', 'l', 'E', 'm', 'p', 't', 'y' }; const mxArray *e_y; static const int32_T iv5[2] = { 1, 36 }; char_T cv7[36]; static const char_T cv8[36] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 'a', 'u', 't', 'o', 'D', 'i', 'm', 'I', 'n', 'c', 'o', 'm', 'p', 'a', 't', 'i', 'b', 'i', 'l', 'i', 't', 'y' }; emxArray_real_T *b_a; const mxArray *f_y; static const int32_T iv6[2] = { 1, 45 }; const mxArray *g_y; static const int32_T iv7[2] = { 1, 21 }; emlrtHeapReferenceStackEnterFcnR2012b(emlrtRootTLSGlobal); emxInit_real_T(&a, 2, &e_emlrtRTEI, TRUE); emlrtPushRtStackR2012b(&h_emlrtRSI, emlrtRootTLSGlobal); i2 = a->size[0] * a->size[1]; a->size[0] = A->size[0]; a->size[1] = A->size[1]; emxEnsureCapacity((emxArray__common *)a, i2, (int32_T)sizeof(real_T), &e_emlrtRTEI); i = A->size[0] * A->size[1]; for (i2 = 0; i2 < i; i2++) { a->data[i2] = -A->data[i2]; } emlrtPushRtStackR2012b(&j_emlrtRSI, emlrtRootTLSGlobal); if (!(a->size[1] == x->size[0])) { if (((a->size[0] == 1) && (a->size[1] == 1)) || (x->size[0] == 1)) { emlrtPushRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal); y = NULL; m0 = mxCreateCharArray(2, iv2); for (i = 0; i < 45; i++) { cv1[i] = cv2[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m0, cv1); emlrtAssign(&y, m0); error(message(y, &b_emlrtMCI), &c_emlrtMCI); emlrtPopRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&k_emlrtRSI, emlrtRootTLSGlobal); b_y = NULL; m0 = mxCreateCharArray(2, iv3); for (i = 0; i < 21; i++) { cv3[i] = cv4[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m0, cv3); emlrtAssign(&b_y, m0); error(message(b_y, &d_emlrtMCI), &e_emlrtMCI); emlrtPopRtStackR2012b(&k_emlrtRSI, emlrtRootTLSGlobal); } } emlrtPopRtStackR2012b(&j_emlrtRSI, emlrtRootTLSGlobal); b_emxInit_real_T(&c_y, 1, &e_emlrtRTEI, TRUE); if ((a->size[1] == 1) || (x->size[0] == 1)) { i2 = c_y->size[0]; c_y->size[0] = a->size[0]; emxEnsureCapacity((emxArray__common *)c_y, i2, (int32_T)sizeof(real_T), &e_emlrtRTEI); i = a->size[0]; for (i2 = 0; i2 < i; i2++) { c_y->data[i2] = 0.0; loop_ub = a->size[1]; for (i3 = 0; i3 < loop_ub; i3++) { c_y->data[i2] += a->data[i2 + a->size[0] * i3] * x->data[i3]; } } } else { unnamed_idx_0 = (uint32_T)a->size[0]; emlrtPushRtStackR2012b(&i_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal); i2 = c_y->size[0]; c_y->size[0] = (int32_T)unnamed_idx_0; emxEnsureCapacity((emxArray__common *)c_y, i2, (int32_T)sizeof(real_T), &e_emlrtRTEI); i = (int32_T)unnamed_idx_0; for (i2 = 0; i2 < i; i2++) { c_y->data[i2] = 0.0; } if ((a->size[0] < 1) || (a->size[1] < 1)) { } else { emlrtPushRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal); alpha1 = 1.0; beta1 = 0.0; TRANSB = 'N'; TRANSA = 'N'; emlrtPushRtStackR2012b(&u_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); m_t = (ptrdiff_t)(a->size[0]); emlrtPopRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&u_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&v_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); n_t = (ptrdiff_t)(1); emlrtPopRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&v_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&w_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); k_t = (ptrdiff_t)(a->size[1]); emlrtPopRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&w_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); lda_t = (ptrdiff_t)(a->size[0]); emlrtPopRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&y_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); ldb_t = (ptrdiff_t)(a->size[1]); emlrtPopRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&y_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); ldc_t = (ptrdiff_t)(a->size[0]); emlrtPopRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&bb_emlrtRSI, emlrtRootTLSGlobal); alpha1_t = (double *)(&alpha1); emlrtPopRtStackR2012b(&bb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&cb_emlrtRSI, emlrtRootTLSGlobal); Aia0_t = (double *)(&a->data[0]); emlrtPopRtStackR2012b(&cb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&db_emlrtRSI, emlrtRootTLSGlobal); Bib0_t = (double *)(&x->data[0]); emlrtPopRtStackR2012b(&db_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal); beta1_t = (double *)(&beta1); emlrtPopRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&fb_emlrtRSI, emlrtRootTLSGlobal); Cic0_t = (double *)(&c_y->data[0]); emlrtPopRtStackR2012b(&fb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&gb_emlrtRSI, emlrtRootTLSGlobal); dgemm(&TRANSA, &TRANSB, &m_t, &n_t, &k_t, alpha1_t, Aia0_t, &lda_t, Bib0_t, &ldb_t, beta1_t, Cic0_t, &ldc_t); emlrtPopRtStackR2012b(&gb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&i_emlrtRSI, emlrtRootTLSGlobal); } emxFree_real_T(&a); b_emxInit_real_T(&b_x, 1, &e_emlrtRTEI, TRUE); i2 = b_x->size[0]; b_x->size[0] = c_y->size[0]; emxEnsureCapacity((emxArray__common *)b_x, i2, (int32_T)sizeof(real_T), &e_emlrtRTEI); i = c_y->size[0]; for (i2 = 0; i2 < i; i2++) { b_x->data[i2] = c_y->data[i2]; } for (i = 0; i < c_y->size[0]; i++) { b_x->data[i] = muDoubleScalarExp(b_x->data[i]); } i2 = b_x->size[0]; emxEnsureCapacity((emxArray__common *)b_x, i2, (int32_T)sizeof(real_T), &e_emlrtRTEI); i = b_x->size[0]; for (i2 = 0; i2 < i; i2++) { b_x->data[i2]++; } i2 = c_y->size[0]; c_y->size[0] = b_x->size[0]; emxEnsureCapacity((emxArray__common *)c_y, i2, (int32_T)sizeof(real_T), &e_emlrtRTEI); i = b_x->size[0]; for (i2 = 0; i2 < i; i2++) { c_y->data[i2] = b_x->data[i2]; } for (i = 0; i < b_x->size[0]; i++) { if (b_x->data[i] < 0.0) { emlrtPushRtStackR2012b(&e_emlrtRSI, emlrtRootTLSGlobal); eml_error(); emlrtPopRtStackR2012b(&e_emlrtRSI, emlrtRootTLSGlobal); } } for (i = 0; i < b_x->size[0]; i++) { c_y->data[i] = muDoubleScalarLog(c_y->data[i]); } emxFree_real_T(&b_x); overflow = FALSE; p = FALSE; i = 0; do { exitg1 = 0; if (i < 2) { if (i + 1 <= 1) { i2 = c_y->size[0]; } else { i2 = 1; } if (i2 != 0) { exitg1 = 1; } else { i++; } } else { p = TRUE; exitg1 = 1; } } while (exitg1 == 0); if (!p) { } else { overflow = TRUE; } if (!overflow) { } else { emlrtPushRtStackR2012b(&ib_emlrtRSI, emlrtRootTLSGlobal); d_y = NULL; m0 = mxCreateCharArray(2, iv4); for (i = 0; i < 30; i++) { cv5[i] = cv6[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 30, m0, cv5); emlrtAssign(&d_y, m0); error(message(d_y, &h_emlrtMCI), &i_emlrtMCI); emlrtPopRtStackR2012b(&ib_emlrtRSI, emlrtRootTLSGlobal); } if ((c_y->size[0] == 1) || (c_y->size[0] != 1)) { overflow = TRUE; } else { overflow = FALSE; } if (overflow) { } else { emlrtPushRtStackR2012b(&jb_emlrtRSI, emlrtRootTLSGlobal); e_y = NULL; m0 = mxCreateCharArray(2, iv5); for (i = 0; i < 36; i++) { cv7[i] = cv8[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 36, m0, cv7); emlrtAssign(&e_y, m0); error(message(e_y, &j_emlrtMCI), &k_emlrtMCI); emlrtPopRtStackR2012b(&jb_emlrtRSI, emlrtRootTLSGlobal); } if (c_y->size[0] == 0) { alpha1 = 0.0; } else { alpha1 = c_y->data[0]; emlrtPushRtStackR2012b(&kb_emlrtRSI, emlrtRootTLSGlobal); if (2 > c_y->size[0]) { overflow = FALSE; } else { overflow = (c_y->size[0] > 2147483646); } if (overflow) { emlrtPushRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal); check_forloop_overflow_error(); emlrtPopRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&kb_emlrtRSI, emlrtRootTLSGlobal); for (i = 2; i <= c_y->size[0]; i++) { alpha1 += c_y->data[i - 1]; } } emxFree_real_T(&c_y); emxInit_real_T(&b_a, 2, &e_emlrtRTEI, TRUE); i2 = b_a->size[0] * b_a->size[1]; b_a->size[0] = 1; emxEnsureCapacity((emxArray__common *)b_a, i2, (int32_T)sizeof(real_T), &e_emlrtRTEI); i = x->size[0]; i2 = b_a->size[0] * b_a->size[1]; b_a->size[1] = i; emxEnsureCapacity((emxArray__common *)b_a, i2, (int32_T)sizeof(real_T), &e_emlrtRTEI); i = x->size[0]; for (i2 = 0; i2 < i; i2++) { b_a->data[i2] = x->data[i2]; } emlrtPushRtStackR2012b(&j_emlrtRSI, emlrtRootTLSGlobal); if (!(b_a->size[1] == x->size[0])) { if ((b_a->size[1] == 1) || (x->size[0] == 1)) { emlrtPushRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal); f_y = NULL; m0 = mxCreateCharArray(2, iv6); for (i = 0; i < 45; i++) { cv1[i] = cv2[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m0, cv1); emlrtAssign(&f_y, m0); error(message(f_y, &b_emlrtMCI), &c_emlrtMCI); emlrtPopRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&k_emlrtRSI, emlrtRootTLSGlobal); g_y = NULL; m0 = mxCreateCharArray(2, iv7); for (i = 0; i < 21; i++) { cv3[i] = cv4[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m0, cv3); emlrtAssign(&g_y, m0); error(message(g_y, &d_emlrtMCI), &e_emlrtMCI); emlrtPopRtStackR2012b(&k_emlrtRSI, emlrtRootTLSGlobal); } } emlrtPopRtStackR2012b(&j_emlrtRSI, emlrtRootTLSGlobal); if ((b_a->size[1] == 1) || (x->size[0] == 1)) { beta1 = 0.0; for (i2 = 0; i2 < b_a->size[1]; i2++) { beta1 += b_a->data[b_a->size[0] * i2] * x->data[i2]; } } else { emlrtPushRtStackR2012b(&lb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&mb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&nb_emlrtRSI, emlrtRootTLSGlobal); if (b_a->size[1] < 1) { beta1 = 0.0; } else { emlrtPushRtStackR2012b(&pb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&sb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); n_t = (ptrdiff_t)(b_a->size[1]); emlrtPopRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&sb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&tb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); m_t = (ptrdiff_t)(1); emlrtPopRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&tb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ub_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); k_t = (ptrdiff_t)(1); emlrtPopRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&ub_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&vb_emlrtRSI, emlrtRootTLSGlobal); alpha1_t = (double *)(&b_a->data[0]); emlrtPopRtStackR2012b(&vb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&wb_emlrtRSI, emlrtRootTLSGlobal); Aia0_t = (double *)(&x->data[0]); emlrtPopRtStackR2012b(&wb_emlrtRSI, emlrtRootTLSGlobal); beta1 = ddot(&n_t, alpha1_t, &m_t, Aia0_t, &k_t); emlrtPopRtStackR2012b(&pb_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&nb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&mb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&lb_emlrtRSI, emlrtRootTLSGlobal); } emxFree_real_T(&b_a); f = -C * alpha1 - 0.5 * beta1; emlrtPopRtStackR2012b(&h_emlrtRSI, emlrtRootTLSGlobal); emlrtHeapReferenceStackLeaveFcnR2012b(emlrtRootTLSGlobal); return f; }