void fastdfa_api(const mxArray *prhs[1], const mxArray *plhs[3]) { emxArray_real_T *x; emxArray_real_T *intervals; emxArray_real_T *flucts; real_T alpha; emlrtStack st = { NULL, NULL, NULL }; st.tls = emlrtRootTLSGlobal; emlrtHeapReferenceStackEnterFcnR2012b(&st); emxInit_real_T(&st, &x, 1, true); emxInit_real_T(&st, &intervals, 1, true); emxInit_real_T(&st, &flucts, 1, true); prhs[0] = emlrtProtectR2012b(prhs[0], 0, false, -1); /* Marshall function inputs */ emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "x", x); /* Invoke the target function */ fastdfa(x, &alpha, intervals, flucts); /* Marshall function outputs */ plhs[0] = b_emlrt_marshallOut(alpha); plhs[1] = c_emlrt_marshallOut(intervals); plhs[2] = c_emlrt_marshallOut(flucts); flucts->canFreeData = false; emxFree_real_T(&flucts); intervals->canFreeData = false; emxFree_real_T(&intervals); x->canFreeData = false; emxFree_real_T(&x); emlrtHeapReferenceStackLeaveFcnR2012b(&st); }
void makeHistFutTablewithRearrange_api(const mxArray * const prhs[4], const mxArray *plhs[1]) { emxArray_uint8_T *testm; emxArray_real_T *rmat; emxArray_real_T *y; real_T range; real_T dims; emlrtStack st = { NULL, NULL, NULL }; st.tls = emlrtRootTLSGlobal; emlrtHeapReferenceStackEnterFcnR2012b(&st); emxInit_uint8_T(&st, &testm, 2, &h_emlrtRTEI, true); emxInit_real_T1(&st, &rmat, 1, &h_emlrtRTEI, true); emxInit_real_T(&st, &y, 2, &h_emlrtRTEI, true); /* Marshall function inputs */ emlrt_marshallIn(&st, emlrtAlias((const mxArray *)prhs[0]), "testm", testm); range = c_emlrt_marshallIn(&st, emlrtAliasP((const mxArray *)prhs[1]), "range"); dims = c_emlrt_marshallIn(&st, emlrtAliasP((const mxArray *)prhs[2]), "dims"); e_emlrt_marshallIn(&st, emlrtAlias((const mxArray *)prhs[3]), "rmat", rmat); /* Invoke the target function */ makeHistFutTablewithRearrange(&st, testm, range, dims, rmat, y); /* Marshall function outputs */ plhs[0] = emlrt_marshallOut(y); y->canFreeData = false; emxFree_real_T(&y); rmat->canFreeData = false; emxFree_real_T(&rmat); testm->canFreeData = false; emxFree_uint8_T(&testm); emlrtHeapReferenceStackLeaveFcnR2012b(&st); }
/* * Arguments : const mxArray *prhs[5] * const mxArray *plhs[1] * Return Type : void */ void SpringForce_api(const mxArray *prhs[5], const mxArray *plhs[1]) { emxArray_real_T *particleDist; emxArray_real_T *springConst; emxArray_boolean_T *connectivityMap; emxArray_real_T *minParticleDist; emxArray_real_T *fixedParticleNum; emxArray_real_T *force; emlrtStack st = { NULL, NULL, NULL }; st.tls = emlrtRootTLSGlobal; emlrtHeapReferenceStackEnterFcnR2012b(&st); emxInit_real_T(&st, &particleDist, 2, true); emxInit_real_T(&st, &springConst, 2, true); emxInit_boolean_T(&st, &connectivityMap, 2, true); emxInit_real_T(&st, &minParticleDist, 2, true); emxInit_real_T(&st, &fixedParticleNum, 2, true); emxInit_real_T(&st, &force, 2, true); prhs[0] = emlrtProtectR2012b(prhs[0], 0, false, -1); prhs[1] = emlrtProtectR2012b(prhs[1], 1, false, -1); prhs[2] = emlrtProtectR2012b(prhs[2], 2, false, -1); prhs[3] = emlrtProtectR2012b(prhs[3], 3, false, -1); prhs[4] = emlrtProtectR2012b(prhs[4], 4, false, -1); /* Marshall function inputs */ emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "particleDist", particleDist); emlrt_marshallIn(&st, emlrtAlias(prhs[1]), "springConst", springConst); c_emlrt_marshallIn(&st, emlrtAlias(prhs[2]), "connectivityMap", connectivityMap); emlrt_marshallIn(&st, emlrtAlias(prhs[3]), "minParticleDist", minParticleDist); e_emlrt_marshallIn(&st, emlrtAlias(prhs[4]), "fixedParticleNum", fixedParticleNum); /* Invoke the target function */ SpringForce(particleDist, springConst, connectivityMap, minParticleDist, fixedParticleNum, force); /* Marshall function outputs */ plhs[0] = emlrt_marshallOut(force); force->canFreeData = false; emxFree_real_T(&force); fixedParticleNum->canFreeData = false; emxFree_real_T(&fixedParticleNum); minParticleDist->canFreeData = false; emxFree_real_T(&minParticleDist); connectivityMap->canFreeData = false; emxFree_boolean_T(&connectivityMap); springConst->canFreeData = false; emxFree_real_T(&springConst); particleDist->canFreeData = false; emxFree_real_T(&particleDist); emlrtHeapReferenceStackLeaveFcnR2012b(&st); }
void swipep_api(const mxArray *prhs[8], const mxArray *plhs[3]) { emxArray_real_T *x; emxArray_real_T *p; emxArray_real_T *t; emxArray_real_T *s; real_T fs; real_T (*plim)[2]; real_T dt; real_T dlog2p; real_T dERBs; real_T woverlap; real_T sTHR; emlrtStack st = { NULL, NULL, NULL }; st.tls = emlrtRootTLSGlobal; emlrtHeapReferenceStackEnterFcnR2012b(&st); emxInit_real_T(&st, &x, 1, true); emxInit_real_T(&st, &p, 1, true); emxInit_real_T(&st, &t, 1, true); emxInit_real_T(&st, &s, 1, true); prhs[0] = emlrtProtectR2012b(prhs[0], 0, false, -1); prhs[2] = emlrtProtectR2012b(prhs[2], 2, false, -1); /* Marshall function inputs */ emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "x", x); fs = g_emlrt_marshallIn(&st, emlrtAliasP(prhs[1]), "fs"); plim = k_emlrt_marshallIn(&st, emlrtAlias(prhs[2]), "plim"); dt = g_emlrt_marshallIn(&st, emlrtAliasP(prhs[3]), "dt"); dlog2p = g_emlrt_marshallIn(&st, emlrtAliasP(prhs[4]), "dlog2p"); dERBs = g_emlrt_marshallIn(&st, emlrtAliasP(prhs[5]), "dERBs"); woverlap = g_emlrt_marshallIn(&st, emlrtAliasP(prhs[6]), "woverlap"); sTHR = g_emlrt_marshallIn(&st, emlrtAliasP(prhs[7]), "sTHR"); /* Invoke the target function */ swipep(x, fs, *plim, dt, dlog2p, dERBs, woverlap, sTHR, p, t, s); /* Marshall function outputs */ plhs[0] = c_emlrt_marshallOut(p); plhs[1] = c_emlrt_marshallOut(t); plhs[2] = c_emlrt_marshallOut(s); s->canFreeData = false; emxFree_real_T(&s); t->canFreeData = false; emxFree_real_T(&t); p->canFreeData = false; emxFree_real_T(&p); x->canFreeData = false; emxFree_real_T(&x); emlrtHeapReferenceStackLeaveFcnR2012b(&st); }
void features_ufb_api(const mxArray *prhs[7], const mxArray *plhs[1]) { emxArray_real_T *ftvec; emxArray_real_T *wvec; emxArray_real_T *ilog; emxArray_real_T *ftmin; emxArray_real_T *ftmax; real_T fbmin; real_T fbmax; emlrtStack st = { NULL, NULL, NULL }; st.tls = emlrtRootTLSGlobal; emlrtHeapReferenceStackEnterFcnR2012b(&st); b_emxInit_real_T(&st, &ftvec, 2, true); emxInit_real_T(&st, &wvec, 1, true); b_emxInit_real_T(&st, &ilog, 2, true); b_emxInit_real_T(&st, &ftmin, 2, true); b_emxInit_real_T(&st, &ftmax, 2, true); prhs[0] = emlrtProtectR2012b(prhs[0], 0, false, -1); prhs[1] = emlrtProtectR2012b(prhs[1], 1, false, -1); prhs[2] = emlrtProtectR2012b(prhs[2], 2, false, -1); prhs[3] = emlrtProtectR2012b(prhs[3], 3, false, -1); prhs[4] = emlrtProtectR2012b(prhs[4], 4, false, -1); /* Marshall function inputs */ i_emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "ftvec", ftvec); emlrt_marshallIn(&st, emlrtAlias(prhs[1]), "wvec", wvec); i_emlrt_marshallIn(&st, emlrtAlias(prhs[2]), "ilog", ilog); i_emlrt_marshallIn(&st, emlrtAlias(prhs[3]), "ftmin", ftmin); i_emlrt_marshallIn(&st, emlrtAlias(prhs[4]), "ftmax", ftmax); fbmin = g_emlrt_marshallIn(&st, emlrtAliasP(prhs[5]), "fbmin"); fbmax = g_emlrt_marshallIn(&st, emlrtAliasP(prhs[6]), "fbmax"); /* Invoke the target function */ fbmin = features_ufb(ftvec, wvec, ilog, ftmin, ftmax, fbmin, fbmax); /* Marshall function outputs */ plhs[0] = b_emlrt_marshallOut(fbmin); ftmax->canFreeData = false; emxFree_real_T(&ftmax); ftmin->canFreeData = false; emxFree_real_T(&ftmin); ilog->canFreeData = false; emxFree_real_T(&ilog); wvec->canFreeData = false; emxFree_real_T(&wvec); ftvec->canFreeData = false; emxFree_real_T(&ftvec); emlrtHeapReferenceStackLeaveFcnR2012b(&st); }
void lomb_api(const mxArray *prhs[4], const mxArray *plhs[3]) { emxArray_real_T *t; emxArray_real_T *h; emxArray_real_T *f; emxArray_real_T *P; emxArray_real_T *prob; real_T ofac; real_T hifac; emlrtStack st = { NULL, NULL, NULL }; st.tls = emlrtRootTLSGlobal; emlrtHeapReferenceStackEnterFcnR2012b(&st); emxInit_real_T(&st, &t, 1, true); emxInit_real_T(&st, &h, 1, true); emxInit_real_T(&st, &f, 1, true); emxInit_real_T(&st, &P, 1, true); emxInit_real_T(&st, &prob, 1, true); prhs[0] = emlrtProtectR2012b(prhs[0], 0, false, -1); prhs[1] = emlrtProtectR2012b(prhs[1], 1, false, -1); /* Marshall function inputs */ emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "t", t); emlrt_marshallIn(&st, emlrtAlias(prhs[1]), "h", h); ofac = g_emlrt_marshallIn(&st, emlrtAliasP(prhs[2]), "ofac"); hifac = g_emlrt_marshallIn(&st, emlrtAliasP(prhs[3]), "hifac"); /* Invoke the target function */ lomb(t, h, ofac, hifac, f, P, prob); /* Marshall function outputs */ plhs[0] = c_emlrt_marshallOut(f); plhs[1] = c_emlrt_marshallOut(P); plhs[2] = c_emlrt_marshallOut(prob); prob->canFreeData = false; emxFree_real_T(&prob); P->canFreeData = false; emxFree_real_T(&P); f->canFreeData = false; emxFree_real_T(&f); h->canFreeData = false; emxFree_real_T(&h); t->canFreeData = false; emxFree_real_T(&t); emlrtHeapReferenceStackLeaveFcnR2012b(&st); }
/* * Arguments : const mxArray *prhs[7] * const mxArray *plhs[1] * Return Type : void */ void classifyNotes_api(const mxArray *prhs[7], const mxArray *plhs[1]) { emxArray_real_T *notes_gt; emxArray_real_T *notes_tr; struct0_T Results; real_T onset_lim; real_T dur_percent_range; real_T min_dur_dist; real_T f0_range_in_cents; real_T hopsize; emlrtStack st = { NULL, NULL, NULL }; st.tls = emlrtRootTLSGlobal; emlrtHeapReferenceStackEnterFcnR2012b(&st); emxInit_real_T(&st, ¬es_gt, 2, true); emxInit_real_T(&st, ¬es_tr, 2, true); emxInitStruct_struct0_T(&st, &Results, true); prhs[0] = emlrtProtectR2012b(prhs[0], 0, false, -1); prhs[1] = emlrtProtectR2012b(prhs[1], 1, false, -1); /* Marshall function inputs */ emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "notes_gt", notes_gt); emlrt_marshallIn(&st, emlrtAlias(prhs[1]), "notes_tr", notes_tr); onset_lim = c_emlrt_marshallIn(&st, emlrtAliasP(prhs[2]), "onset_lim"); dur_percent_range = c_emlrt_marshallIn(&st, emlrtAliasP(prhs[3]), "dur_percent_range"); min_dur_dist = c_emlrt_marshallIn(&st, emlrtAliasP(prhs[4]), "min_dur_dist"); f0_range_in_cents = c_emlrt_marshallIn(&st, emlrtAliasP(prhs[5]), "f0_range_in_cents"); hopsize = c_emlrt_marshallIn(&st, emlrtAliasP(prhs[6]), "hopsize"); /* Invoke the target function */ classifyNotes(notes_gt, notes_tr, onset_lim, dur_percent_range, min_dur_dist, f0_range_in_cents, hopsize, &Results); /* Marshall function outputs */ plhs[0] = emlrt_marshallOut(&Results); emxFreeStruct_struct0_T(&Results); notes_tr->canFreeData = false; emxFree_real_T(¬es_tr); notes_gt->canFreeData = false; emxFree_real_T(¬es_gt); emlrtHeapReferenceStackLeaveFcnR2012b(&st); }
void Dcoeff_api(const mxArray * const prhs[6], const mxArray *plhs[1]) { emxArray_real_T *y; emxArray_real_T *x; emxArray_real_T *timePoints; emxArray_real_T *f; real_T j; real_T t; emlrtStack st = { NULL, NULL, NULL }; st.tls = emlrtRootTLSGlobal; emlrtHeapReferenceStackEnterFcnR2012b(&st); emxInit_real_T(&st, &y, 2, &ub_emlrtRTEI, true); emxInit_real_T(&st, &x, 2, &ub_emlrtRTEI, true); emxInit_real_T(&st, &timePoints, 2, &ub_emlrtRTEI, true); emxInit_real_T(&st, &f, 2, &ub_emlrtRTEI, true); /* Marshall function inputs */ e_emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "y", y); j = c_emlrt_marshallIn(&st, emlrtAliasP(prhs[1]), "j"); e_emlrt_marshallIn(&st, emlrtAlias(prhs[2]), "x", x); t = c_emlrt_marshallIn(&st, emlrtAliasP(prhs[3]), "t"); e_emlrt_marshallIn(&st, emlrtAlias(prhs[4]), "timePoints", timePoints); e_emlrt_marshallIn(&st, emlrtAlias(prhs[5]), "f", f); /* Invoke the target function */ j = Dcoeff(&st, y, j, x, t, timePoints, f); /* Marshall function outputs */ plhs[0] = emlrt_marshallOut(j); f->canFreeData = false; emxFree_real_T(&f); timePoints->canFreeData = false; emxFree_real_T(&timePoints); x->canFreeData = false; emxFree_real_T(&x); y->canFreeData = false; emxFree_real_T(&y); emlrtHeapReferenceStackLeaveFcnR2012b(&st); }
void TestBemHeatEq_optimized_api(const mxArray * const prhs[4], const mxArray *plhs[2]) { emxArray_real_T *sigIn; emxArray_real_T *u; emxArray_real_T *r; real_T regOrder; real_T lambda; boolean_T plotFlag; emlrtStack st = { NULL, NULL, NULL }; st.tls = emlrtRootTLSGlobal; emlrtHeapReferenceStackEnterFcnR2012b(&st); emxInit_real_T(&st, &sigIn, 2, &ub_emlrtRTEI, true); emxInit_real_T(&st, &u, 2, &ub_emlrtRTEI, true); b_emxInit_real_T(&st, &r, 1, &ub_emlrtRTEI, true); /* Marshall function inputs */ e_emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "sigIn", sigIn); regOrder = c_emlrt_marshallIn(&st, emlrtAliasP(prhs[1]), "regOrder"); lambda = c_emlrt_marshallIn(&st, emlrtAliasP(prhs[2]), "lambda"); plotFlag = k_emlrt_marshallIn(&st, emlrtAliasP(prhs[3]), "plotFlag"); /* Invoke the target function */ TestBemHeatEq_optimized(&st, sigIn, regOrder, lambda, plotFlag, u, r); /* Marshall function outputs */ plhs[0] = f_emlrt_marshallOut(u); plhs[1] = g_emlrt_marshallOut(r); r->canFreeData = false; emxFree_real_T(&r); u->canFreeData = false; emxFree_real_T(&u); sigIn->canFreeData = false; emxFree_real_T(&sigIn); emlrtHeapReferenceStackLeaveFcnR2012b(&st); }
void features_bta_api(const mxArray *prhs[1], const mxArray *plhs[1]) { real_T (*ft)[2]; emxArray_real_T *tap; emlrtStack st = { NULL, NULL, NULL }; st.tls = emlrtRootTLSGlobal; ft = (real_T (*)[2])mxMalloc(sizeof(real_T [2])); emlrtHeapReferenceStackEnterFcnR2012b(&st); b_emxInit_real_T(&st, &tap, 2, true); prhs[0] = emlrtProtectR2012b(prhs[0], 0, false, -1); /* Marshall function inputs */ e_emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "tap", tap); /* Invoke the target function */ features_bta(tap, *ft); /* Marshall function outputs */ plhs[0] = f_emlrt_marshallOut(*ft); tap->canFreeData = false; emxFree_real_T(&tap); emlrtHeapReferenceStackLeaveFcnR2012b(&st); }
/* * function [counts] = get_unique_counts(a,uniques) */ void get_unique_counts(const emlrtStack *sp, const emxArray_real_T *a, const emxArray_real_T *uniques, emxArray_real_T *counts) { int32_T i0; int32_T loop_ub; int32_T i; emxArray_boolean_T *s; real_T b_uniques; int32_T k; emlrtHeapReferenceStackEnterFcnR2012b(sp); /* 'get_unique_counts:3' counts = zeros(numel(uniques),1); */ i0 = counts->size[0]; counts->size[0] = uniques->size[0]; emxEnsureCapacity(sp, (emxArray__common *)counts, i0, (int32_T)sizeof(real_T), &emlrtRTEI); loop_ub = uniques->size[0]; for (i0 = 0; i0 < loop_ub; i0++) { counts->data[i0] = 0.0; } /* 'get_unique_counts:5' for i = 1:numel(uniques) */ i = 1; emxInit_boolean_T(sp, &s, 3, &emlrtRTEI, true); while (i - 1 <= uniques->size[0] - 1) { /* 'get_unique_counts:6' counts(i) = nnz(a==uniques(i)); */ i0 = s->size[0] * s->size[1] * s->size[2]; s->size[0] = a->size[0]; s->size[1] = a->size[1]; s->size[2] = a->size[2]; emxEnsureCapacity(sp, (emxArray__common *)s, i0, (int32_T)sizeof(boolean_T), &emlrtRTEI); i0 = uniques->size[0]; if (!((i >= 1) && (i <= i0))) { emlrtDynamicBoundsCheckR2012b(i, 1, i0, &emlrtBCI, sp); } b_uniques = uniques->data[i - 1]; loop_ub = a->size[0] * a->size[1] * a->size[2]; for (i0 = 0; i0 < loop_ub; i0++) { s->data[i0] = (a->data[i0] == b_uniques); } loop_ub = 0; i0 = s->size[0] * s->size[1] * s->size[2]; for (k = 0; k < i0; k++) { if (s->data[k]) { loop_ub++; } } i0 = counts->size[0]; if (!((i >= 1) && (i <= i0))) { emlrtDynamicBoundsCheckR2012b(i, 1, i0, &b_emlrtBCI, sp); } counts->data[i - 1] = loop_ub; i++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } emxFree_boolean_T(&s); emlrtHeapReferenceStackLeaveFcnR2012b(sp); }
/* 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); }
/* * Arguments : const mxArray *prhs[19] * const mxArray *plhs[4] * Return Type : void */ void clcDP_olyHyb_tmp_api(const mxArray *prhs[19], const mxArray *plhs[4]) { emxArray_real_T *engKinNumVec_wayInx; emxArray_real_T *slpVec_wayInx; emxArray_real_T *engKinMat_engKinInx_wayInx; static struct0_T FZG; emxArray_real_T *optPreInxTn3; emxArray_real_T *batFrcOptTn3; emxArray_real_T *fulEngOptTn3; emxArray_real_T *cos2goActMat; real_T disFlg; real_T wayStp; real_T batEngStp; real_T batEngBeg; real_T batPwrAux; real_T psiBatEng; real_T psiTim; real_T staChgPenCosVal; real_T wayInxBeg; real_T wayInxEnd; real_T engKinBegInx; real_T engKinNum; real_T staNum; real_T wayNum; real_T staBeg; emlrtStack st = { NULL, NULL, NULL }; st.tls = emlrtRootTLSGlobal; emlrtHeapReferenceStackEnterFcnR2012b(&st); emxInit_real_T(&st, &engKinNumVec_wayInx, 1, true); emxInit_real_T(&st, &slpVec_wayInx, 1, true); b_emxInit_real_T(&st, &engKinMat_engKinInx_wayInx, 2, true); emxInitStruct_struct0_T(&st, &FZG, true); c_emxInit_real_T(&st, &optPreInxTn3, 3, true); c_emxInit_real_T(&st, &batFrcOptTn3, 3, true); c_emxInit_real_T(&st, &fulEngOptTn3, 3, true); b_emxInit_real_T(&st, &cos2goActMat, 2, true); prhs[15] = emlrtProtectR2012b(prhs[15], 15, false, -1); prhs[16] = emlrtProtectR2012b(prhs[16], 16, false, -1); prhs[17] = emlrtProtectR2012b(prhs[17], 17, false, -1); /* Marshall function inputs */ disFlg = emlrt_marshallIn(&st, emlrtAliasP(prhs[0]), "disFlg"); wayStp = emlrt_marshallIn(&st, emlrtAliasP(prhs[1]), "wayStp"); batEngStp = emlrt_marshallIn(&st, emlrtAliasP(prhs[2]), "batEngStp"); batEngBeg = emlrt_marshallIn(&st, emlrtAliasP(prhs[3]), "batEngBeg"); batPwrAux = emlrt_marshallIn(&st, emlrtAliasP(prhs[4]), "batPwrAux"); psiBatEng = emlrt_marshallIn(&st, emlrtAliasP(prhs[5]), "psiBatEng"); psiTim = emlrt_marshallIn(&st, emlrtAliasP(prhs[6]), "psiTim"); staChgPenCosVal = emlrt_marshallIn(&st, emlrtAliasP(prhs[7]), "staChgPenCosVal"); wayInxBeg = emlrt_marshallIn(&st, emlrtAliasP(prhs[8]), "wayInxBeg"); wayInxEnd = emlrt_marshallIn(&st, emlrtAliasP(prhs[9]), "wayInxEnd"); engKinBegInx = emlrt_marshallIn(&st, emlrtAliasP(prhs[10]), "engKinBegInx"); engKinNum = emlrt_marshallIn(&st, emlrtAliasP(prhs[11]), "engKinNum"); staNum = emlrt_marshallIn(&st, emlrtAliasP(prhs[12]), "staNum"); wayNum = emlrt_marshallIn(&st, emlrtAliasP(prhs[13]), "wayNum"); staBeg = emlrt_marshallIn(&st, emlrtAliasP(prhs[14]), "staBeg"); c_emlrt_marshallIn(&st, emlrtAlias(prhs[15]), "engKinNumVec_wayInx", engKinNumVec_wayInx); c_emlrt_marshallIn(&st, emlrtAlias(prhs[16]), "slpVec_wayInx", slpVec_wayInx); e_emlrt_marshallIn(&st, emlrtAlias(prhs[17]), "engKinMat_engKinInx_wayInx", engKinMat_engKinInx_wayInx); g_emlrt_marshallIn(&st, emlrtAliasP(prhs[18]), "FZG", &FZG); /* Invoke the target function */ clcDP_olyHyb_tmp(disFlg, wayStp, batEngStp, batEngBeg, batPwrAux, psiBatEng, psiTim, staChgPenCosVal, wayInxBeg, wayInxEnd, engKinBegInx, engKinNum, staNum, wayNum, staBeg, engKinNumVec_wayInx, slpVec_wayInx, engKinMat_engKinInx_wayInx, &FZG, optPreInxTn3, batFrcOptTn3, fulEngOptTn3, cos2goActMat); /* Marshall function outputs */ plhs[0] = emlrt_marshallOut(optPreInxTn3); plhs[1] = emlrt_marshallOut(batFrcOptTn3); plhs[2] = emlrt_marshallOut(fulEngOptTn3); plhs[3] = b_emlrt_marshallOut(cos2goActMat); cos2goActMat->canFreeData = false; emxFree_real_T(&cos2goActMat); fulEngOptTn3->canFreeData = false; emxFree_real_T(&fulEngOptTn3); batFrcOptTn3->canFreeData = false; emxFree_real_T(&batFrcOptTn3); optPreInxTn3->canFreeData = false; emxFree_real_T(&optPreInxTn3); emxFreeStruct_struct0_T(&FZG); engKinMat_engKinInx_wayInx->canFreeData = false; emxFree_real_T(&engKinMat_engKinInx_wayInx); slpVec_wayInx->canFreeData = false; emxFree_real_T(&slpVec_wayInx); engKinNumVec_wayInx->canFreeData = false; emxFree_real_T(&engKinNumVec_wayInx); emlrtHeapReferenceStackLeaveFcnR2012b(&st); }
void mldivide(const emlrtStack *sp, const emxArray_real_T *A, const emxArray_real_T *B, emxArray_real_T *Y) { const mxArray *y; static const int32_T iv77[2] = { 1, 21 }; const mxArray *m13; char_T cv74[21]; int32_T i; static const char_T cv75[21] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T', 'L', 'A', 'B', ':', 'd', 'i', 'm', 'a', 'g', 'r', 'e', 'e' }; emxArray_real_T *b_B; emxArray_real_T *r17; uint32_T unnamed_idx_0; int32_T loop_ub; emlrtStack st; st.prev = sp; st.tls = sp->tls; emlrtHeapReferenceStackEnterFcnR2012b(sp); if (B->size[0] == A->size[0]) { } else { y = NULL; m13 = emlrtCreateCharArray(2, iv77); for (i = 0; i < 21; i++) { cv74[i] = cv75[i]; } emlrtInitCharArrayR2013a(sp, 21, m13, cv74); emlrtAssign(&y, m13); st.site = &xf_emlrtRSI; error(&st, message(&st, y, &bb_emlrtMCI), &bb_emlrtMCI); } b_emxInit_real_T(sp, &b_B, 1, &tb_emlrtRTEI, true); b_emxInit_real_T(sp, &r17, 1, &tb_emlrtRTEI, true); if ((A->size[0] == 0) || (A->size[1] == 0) || (B->size[0] == 0)) { unnamed_idx_0 = (uint32_T)A->size[1]; i = Y->size[0]; Y->size[0] = (int32_T)unnamed_idx_0; emxEnsureCapacity(sp, (emxArray__common *)Y, i, (int32_T)sizeof(real_T), &tb_emlrtRTEI); loop_ub = (int32_T)unnamed_idx_0; for (i = 0; i < loop_ub; i++) { Y->data[i] = 0.0; } } else if (A->size[0] == A->size[1]) { i = Y->size[0]; Y->size[0] = B->size[0]; emxEnsureCapacity(sp, (emxArray__common *)Y, i, (int32_T)sizeof(real_T), &tb_emlrtRTEI); loop_ub = B->size[0]; for (i = 0; i < loop_ub; i++) { Y->data[i] = B->data[i]; } st.site = &xf_emlrtRSI; b_eml_lusolve(&st, A, Y); } else { i = b_B->size[0]; b_B->size[0] = B->size[0]; emxEnsureCapacity(sp, (emxArray__common *)b_B, i, (int32_T)sizeof(real_T), &tb_emlrtRTEI); loop_ub = B->size[0]; for (i = 0; i < loop_ub; i++) { b_B->data[i] = B->data[i]; } st.site = &xf_emlrtRSI; c_eml_qrsolve(&st, A, b_B, r17); i = Y->size[0]; Y->size[0] = r17->size[0]; emxEnsureCapacity(sp, (emxArray__common *)Y, i, (int32_T)sizeof(real_T), &tb_emlrtRTEI); loop_ub = r17->size[0]; for (i = 0; i < loop_ub; i++) { Y->data[i] = r17->data[i]; } } emxFree_real_T(&r17); emxFree_real_T(&b_B); emlrtHeapReferenceStackLeaveFcnR2012b(sp); }
/* Function Definitions */ void determineCriterion(struct0_T *p, real_T trial) { emxArray_real_T *b_p; int32_T loop_ub; int32_T i19; emxArray_real_T *c_p; int32_T d_p; int32_T i20; emxArray_real_T *e_p; emxArray_real_T *f_p; emlrtHeapReferenceStackEnterFcnR2012b(emlrtRootTLSGlobal); /* update criterion for use on next trial */ /* when two layers are available, each are allowed seperate decision */ /* thresholds */ /* p.mean_famil_diff(trial) = mean(familDiffs); */ if (p->numThresh == 2.0) { emxInit_real_T(&b_p, 1, true); loop_ub = p->usePRC->size[0]; i19 = b_p->size[0]; b_p->size[0] = loop_ub; emxEnsureCapacity((emxArray__common *)b_p, i19, (int32_T)sizeof(real_T)); for (i19 = 0; i19 < loop_ub; i19++) { b_p->data[i19] = p->usePRC->data[i19 + p->usePRC->size[0] * ((int32_T) trial - 1)]; } if (all(b_p)) { if (1.0 > (real_T)p->famil_diff_thresh->size[1] - 1.0) { loop_ub = -1; } else { loop_ub = (int32_T)((real_T)p->famil_diff_thresh->size[1] - 1.0) - 1; } c_emxInit_real_T(&c_p, 2, true); d_p = p->famil_diff_thresh->size[1]; i19 = c_p->size[0] * c_p->size[1]; c_p->size[0] = 2; c_p->size[1] = d_p; emxEnsureCapacity((emxArray__common *)c_p, i19, (int32_T)sizeof(real_T)); for (i19 = 0; i19 < d_p; i19++) { c_p->data[c_p->size[0] * i19] = p->famil_diff_thresh->data [p->famil_diff_thresh->size[0] * i19]; } c_p->data[1] = p->famil_difference->data[(int32_T)trial - 1]; for (i19 = 0; i19 <= loop_ub; i19++) { c_p->data[1 + c_p->size[0] * (i19 + 1)] = p->famil_diff_thresh->data[1 + p->famil_diff_thresh->size[0] * i19]; } i19 = p->famil_diff_thresh->size[0] * p->famil_diff_thresh->size[1]; p->famil_diff_thresh->size[0] = c_p->size[0]; p->famil_diff_thresh->size[1] = c_p->size[1]; emxEnsureCapacity((emxArray__common *)p->famil_diff_thresh, i19, (int32_T) sizeof(real_T)); loop_ub = c_p->size[1]; for (i19 = 0; i19 < loop_ub; i19++) { d_p = c_p->size[0]; for (i20 = 0; i20 < d_p; i20++) { p->famil_diff_thresh->data[i20 + p->famil_diff_thresh->size[0] * i19] = c_p->data[i20 + c_p->size[0] * i19]; } } emxFree_real_T(&c_p); } else { if (1.0 > (real_T)p->famil_diff_thresh->size[1] - 1.0) { loop_ub = -1; } else { loop_ub = (int32_T)((real_T)p->famil_diff_thresh->size[1] - 1.0) - 1; } c_emxInit_real_T(&e_p, 2, true); d_p = p->famil_diff_thresh->size[1] - 1; i19 = e_p->size[0] * e_p->size[1]; e_p->size[0] = 2; e_p->size[1] = loop_ub + 2; emxEnsureCapacity((emxArray__common *)e_p, i19, (int32_T)sizeof(real_T)); e_p->data[0] = p->famil_difference->data[(int32_T)trial - 1]; for (i19 = 0; i19 <= loop_ub; i19++) { e_p->data[e_p->size[0] * (i19 + 1)] = p->famil_diff_thresh->data [p->famil_diff_thresh->size[0] * i19]; } for (i19 = 0; i19 <= d_p; i19++) { e_p->data[1 + e_p->size[0] * i19] = p->famil_diff_thresh->data[1 + p->famil_diff_thresh->size[0] * i19]; } i19 = p->famil_diff_thresh->size[0] * p->famil_diff_thresh->size[1]; p->famil_diff_thresh->size[0] = e_p->size[0]; p->famil_diff_thresh->size[1] = e_p->size[1]; emxEnsureCapacity((emxArray__common *)p->famil_diff_thresh, i19, (int32_T) sizeof(real_T)); loop_ub = e_p->size[1]; for (i19 = 0; i19 < loop_ub; i19++) { d_p = e_p->size[0]; for (i20 = 0; i20 < d_p; i20++) { p->famil_diff_thresh->data[i20 + p->famil_diff_thresh->size[0] * i19] = e_p->data[i20 + e_p->size[0] * i19]; } } emxFree_real_T(&e_p); /* p.famil_diff_thresh = [p.famil_diff_thresh, p.famil_difference(trial)]; */ /* p.threshForPlotting(trial) = mean(p.famil_diff_thresh); */ /* p.familDiff_threshTracking(trial) = famil_diff_thresh_new; */ } emxFree_real_T(&b_p); } else { if (1.0 > (real_T)p->famil_diff_thresh->size[1] - 1.0) { loop_ub = -1; } else { loop_ub = (int32_T)((real_T)p->famil_diff_thresh->size[1] - 1.0) - 1; } c_emxInit_real_T(&f_p, 2, true); d_p = p->famil_diff_thresh->size[1] - 1; i19 = f_p->size[0] * f_p->size[1]; f_p->size[0] = 2; f_p->size[1] = loop_ub + 2; emxEnsureCapacity((emxArray__common *)f_p, i19, (int32_T)sizeof(real_T)); f_p->data[0] = p->famil_difference->data[(int32_T)trial - 1]; for (i19 = 0; i19 <= loop_ub; i19++) { f_p->data[f_p->size[0] * (i19 + 1)] = p->famil_diff_thresh->data [p->famil_diff_thresh->size[0] * i19]; } for (i19 = 0; i19 <= d_p; i19++) { f_p->data[1 + f_p->size[0] * i19] = p->famil_diff_thresh->data[1 + p->famil_diff_thresh->size[0] * i19]; } i19 = p->famil_diff_thresh->size[0] * p->famil_diff_thresh->size[1]; p->famil_diff_thresh->size[0] = f_p->size[0]; p->famil_diff_thresh->size[1] = f_p->size[1]; emxEnsureCapacity((emxArray__common *)p->famil_diff_thresh, i19, (int32_T) sizeof(real_T)); loop_ub = f_p->size[1]; for (i19 = 0; i19 < loop_ub; i19++) { d_p = f_p->size[0]; for (i20 = 0; i20 < d_p; i20++) { p->famil_diff_thresh->data[i20 + p->famil_diff_thresh->size[0] * i19] = f_p->data[i20 + f_p->size[0] * i19]; } } emxFree_real_T(&f_p); } emlrtHeapReferenceStackLeaveFcnR2012b(emlrtRootTLSGlobal); }
/* 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); }
/* Function Definitions */ real_T Dcoeff(const emlrtStack *sp, const emxArray_real_T *y, real_T j, const emxArray_real_T *x, real_T t, const emxArray_real_T *timePoints, const emxArray_real_T *f) { real_T vals; emxArray_real_T *a; int32_T i11; int32_T unnamed_idx_1; emxArray_real_T *r4; int32_T i12; int32_T i13; int32_T i14; int32_T i15; int32_T i16; int32_T i17; int32_T i18; int32_T i19; emlrtStack st; st.prev = sp; st.tls = sp->tls; emlrtHeapReferenceStackEnterFcnR2012b(sp); emxInit_real_T(sp, &a, 2, &e_emlrtRTEI, true); /* Calculate the integral int_0^1(f(y,t_j)*A_{yj}(x,t)dy) by midpoint */ /* integration rule */ /* the spatial integration of all points y at time t_j */ i11 = a->size[0] * a->size[1]; a->size[0] = 1; emxEnsureCapacity(sp, (emxArray__common *)a, i11, (int32_T)sizeof(real_T), &d_emlrtRTEI); unnamed_idx_1 = y->size[1]; i11 = a->size[0] * a->size[1]; a->size[1] = unnamed_idx_1; emxEnsureCapacity(sp, (emxArray__common *)a, i11, (int32_T)sizeof(real_T), &d_emlrtRTEI); unnamed_idx_1 = y->size[1]; for (i11 = 0; i11 < unnamed_idx_1; i11++) { a->data[i11] = 0.0; } emxInit_real_T(sp, &r4, 2, &d_emlrtRTEI, true); vals = 0.0; i11 = y->size[1]; emlrtDynamicBoundsCheckFastR2012b(1, 1, i11, &ib_emlrtBCI, sp); st.site = &q_emlrtRSI; b_Acoeff(&st, y->data[0], j, x, t, timePoints, r4); i11 = r4->size[1]; emlrtSizeEqCheck1DFastR2012b(1, i11, &c_emlrtECI, sp); unnamed_idx_1 = y->size[1]; emlrtDynamicBoundsCheckFastR2012b(1, 1, unnamed_idx_1, &jb_emlrtBCI, sp); i11 = r4->size[1]; emlrtDynamicBoundsCheckFastR2012b(1, 1, i11, &kb_emlrtBCI, sp); a->data[0] = r4->data[0]; unnamed_idx_1 = 2; while (unnamed_idx_1 - 2 <= y->size[1] - 2) { i11 = y->size[1]; st.site = &r_emlrtRSI; b_Acoeff(&st, y->data[emlrtDynamicBoundsCheckFastR2012b(unnamed_idx_1, 1, i11, &mb_emlrtBCI, sp) - 1], j, x, t, timePoints, r4); i11 = r4->size[1]; emlrtSizeEqCheck1DFastR2012b(1, i11, &d_emlrtECI, sp); i11 = r4->size[1]; emlrtDynamicBoundsCheckFastR2012b(1, 1, i11, &lb_emlrtBCI, sp); i11 = a->size[1]; a->data[emlrtDynamicBoundsCheckFastR2012b(unnamed_idx_1, 1, i11, &nb_emlrtBCI, sp) - 1] = r4->data[0]; i11 = a->size[1]; i12 = f->size[1]; i13 = a->size[1]; i14 = unnamed_idx_1 - 1; i15 = f->size[1]; i16 = unnamed_idx_1 - 1; i17 = y->size[1]; i18 = y->size[1]; i19 = unnamed_idx_1 - 1; vals += 0.5 * (a->data[emlrtDynamicBoundsCheckFastR2012b(unnamed_idx_1, 1, i11, &ob_emlrtBCI, sp) - 1] * f->data[emlrtDynamicBoundsCheckFastR2012b (unnamed_idx_1, 1, i12, &pb_emlrtBCI, sp) - 1] + a-> data[emlrtDynamicBoundsCheckFastR2012b(i14, 1, i13, &qb_emlrtBCI, sp) - 1] * f->data[emlrtDynamicBoundsCheckFastR2012b(i16, 1, i15, &rb_emlrtBCI, sp) - 1]) * (y->data[emlrtDynamicBoundsCheckFastR2012b (unnamed_idx_1, 1, i17, &sb_emlrtBCI, sp) - 1] - y-> data[emlrtDynamicBoundsCheckFastR2012b(i19, 1, i18, &tb_emlrtBCI, sp) - 1]); unnamed_idx_1++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, sp); } emxFree_real_T(&r4); emxFree_real_T(&a); emlrtHeapReferenceStackLeaveFcnR2012b(sp); return vals; }
/* Function Definitions */ void imshift(uint8_T I[270000], const real_T disparity[2]) { real_T xStart2; real_T yStart2; real_T xEnd2; real_T yEnd2; int32_T i2; int32_T i3; int32_T i4; int32_T i5; int32_T tmp_size_idx_0; int32_T loop_ub; int32_T i6; int32_T tmp_data[225]; int32_T b_tmp_size_idx_0; int32_T b_tmp_data[400]; emxArray_uint8_T *b_I; int32_T iv3[3]; int32_T i7; int32_T b_loop_ub; int32_T i8; int32_T c_I[3]; int32_T c_tmp_data[400]; int32_T d_tmp_data[225]; emxArray_uint8_T *d_I; emlrtHeapReferenceStackEnterFcnR2012b(emlrtRootTLSGlobal); xStart2 = muDoubleScalarMax(1.0, 1.0 + disparity[0]); yStart2 = muDoubleScalarMax(1.0, 1.0 + disparity[1]); xEnd2 = muDoubleScalarMin(225.0, 225.0 + disparity[0]); yEnd2 = muDoubleScalarMin(400.0, 400.0 + disparity[1]); i2 = (int32_T)muDoubleScalarMax(1.0, 1.0 - disparity[0]) - 1; i3 = (int32_T)muDoubleScalarMin(225.0, 225.0 - disparity[0]); i4 = (int32_T)muDoubleScalarMax(1.0, 1.0 - disparity[1]) - 1; i5 = (int32_T)muDoubleScalarMin(400.0, 400.0 - disparity[1]); tmp_size_idx_0 = ((int32_T)xEnd2 - (int32_T)xStart2) + 1; loop_ub = (int32_T)xEnd2 - (int32_T)xStart2; for (i6 = 0; i6 <= loop_ub; i6++) { tmp_data[i6] = ((int32_T)xStart2 + i6) - 1; } b_tmp_size_idx_0 = ((int32_T)yEnd2 - (int32_T)yStart2) + 1; loop_ub = (int32_T)yEnd2 - (int32_T)yStart2; for (i6 = 0; i6 <= loop_ub; i6++) { b_tmp_data[i6] = ((int32_T)yStart2 + i6) - 1; } emxInit_uint8_T(&b_I, 3, &emlrtRTEI, TRUE); iv3[0] = tmp_size_idx_0; iv3[1] = b_tmp_size_idx_0; iv3[2] = 3; i6 = b_I->size[0] * b_I->size[1] * b_I->size[2]; b_I->size[0] = i3 - i2; b_I->size[1] = i5 - i4; b_I->size[2] = 3; emxEnsureCapacity((emxArray__common *)b_I, i6, (int32_T)sizeof(uint8_T), &emlrtRTEI); for (i6 = 0; i6 < 3; i6++) { loop_ub = i5 - i4; for (i7 = 0; i7 < loop_ub; i7++) { b_loop_ub = i3 - i2; for (i8 = 0; i8 < b_loop_ub; i8++) { b_I->data[(i8 + b_I->size[0] * i7) + b_I->size[0] * b_I->size[1] * i6] = I[((i2 + i8) + 225 * (i4 + i7)) + 90000 * i6]; } } } for (i6 = 0; i6 < 3; i6++) { c_I[i6] = b_I->size[i6]; } emxFree_uint8_T(&b_I); emlrtSubAssignSizeCheckR2012b(iv3, 3, c_I, 3, &emlrtECI, emlrtRootTLSGlobal); for (i6 = 0; i6 < b_tmp_size_idx_0; i6++) { c_tmp_data[i6] = b_tmp_data[i6]; } for (i6 = 0; i6 < tmp_size_idx_0; i6++) { d_tmp_data[i6] = tmp_data[i6]; } emxInit_uint8_T(&d_I, 3, &emlrtRTEI, TRUE); i6 = d_I->size[0] * d_I->size[1] * d_I->size[2]; d_I->size[0] = i3 - i2; d_I->size[1] = i5 - i4; d_I->size[2] = 3; emxEnsureCapacity((emxArray__common *)d_I, i6, (int32_T)sizeof(uint8_T), &emlrtRTEI); for (i6 = 0; i6 < 3; i6++) { loop_ub = i5 - i4; for (i7 = 0; i7 < loop_ub; i7++) { b_loop_ub = i3 - i2; for (i8 = 0; i8 < b_loop_ub; i8++) { d_I->data[(i8 + d_I->size[0] * i7) + d_I->size[0] * d_I->size[1] * i6] = I[((i2 + i8) + 225 * (i4 + i7)) + 90000 * i6]; } } } for (i2 = 0; i2 < 3; i2++) { loop_ub = d_I->size[1]; for (i3 = 0; i3 < loop_ub; i3++) { b_loop_ub = d_I->size[0]; for (i4 = 0; i4 < b_loop_ub; i4++) { I[(d_tmp_data[i4] + 225 * c_tmp_data[i3]) + 90000 * i2] = d_I->data[(i4 + d_I->size[0] * i3) + d_I->size[0] * d_I->size[1] * i2]; } } } emxFree_uint8_T(&d_I); if (xStart2 == 1.0) { if (xEnd2 + 1.0 > 225.0) { i2 = 0; i3 = 0; } else { i2 = (int32_T)(xEnd2 + 1.0); i2 = emlrtDynamicBoundsCheckFastR2012b(i2, 1, 225, &b_emlrtBCI, emlrtRootTLSGlobal) - 1; i3 = 225; } tmp_size_idx_0 = i3 - i2; for (i3 = 0; i3 < 3; i3++) { for (i4 = 0; i4 < 400; i4++) { for (i5 = 0; i5 < tmp_size_idx_0; i5++) { I[((i2 + i5) + 225 * i4) + 90000 * i3] = 0; } } } } else { for (i2 = 0; i2 < 3; i2++) { for (i3 = 0; i3 < 400; i3++) { loop_ub = (int32_T)(xStart2 - 1.0); for (i4 = 0; i4 < loop_ub; i4++) { I[(i4 + 225 * i3) + 90000 * i2] = 0; } } } } if (yStart2 == 1.0) { if (yEnd2 + 1.0 > 400.0) { i2 = 0; i3 = 0; } else { i2 = (int32_T)(yEnd2 + 1.0); i2 = emlrtDynamicBoundsCheckFastR2012b(i2, 1, 400, &emlrtBCI, emlrtRootTLSGlobal) - 1; i3 = 400; } tmp_size_idx_0 = i3 - i2; for (i3 = 0; i3 < 3; i3++) { for (i4 = 0; i4 < tmp_size_idx_0; i4++) { for (i5 = 0; i5 < 225; i5++) { I[(i5 + 225 * (i2 + i4)) + 90000 * i3] = 0; } } } } else { for (i2 = 0; i2 < 3; i2++) { loop_ub = (int32_T)(yStart2 - 1.0); for (i3 = 0; i3 < loop_ub; i3++) { for (i4 = 0; i4 < 225; i4++) { I[(i4 + 225 * i3) + 90000 * i2] = 0; } } } } emlrtHeapReferenceStackLeaveFcnR2012b(emlrtRootTLSGlobal); }
/* 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 */ void CalculateHeatSolution(const emlrtStack *sp, real_T N0, real_T N, const emxArray_real_T *t, const emxArray_real_T *gridT, const emxArray_real_T *x, const emxArray_real_T *u0, const emxArray_real_T *q0j, const emxArray_real_T *q1j, const emxArray_real_T *h0j, const emxArray_real_T *h1j, const emxArray_real_T *f, const emxArray_real_T *r, emxArray_real_T *u) { emxArray_real_T *eta; int32_T i12; real_T sTime; int32_T loop_ub; int32_T i13; int32_T j; emxArray_real_T *b_f; int32_T i; real_T sSpace; int32_T tIdx; int32_T b_i; int32_T i14; int32_T i15; int32_T i16; int32_T i17; int32_T i18; int32_T i19; int32_T i20; int32_T i21; int32_T i22; int32_T i23; int32_T i24; emlrtStack st; emlrtStack b_st; emlrtStack c_st; st.prev = sp; st.tls = sp->tls; b_st.prev = sp; b_st.tls = sp->tls; c_st.prev = sp; c_st.tls = sp->tls; emlrtHeapReferenceStackEnterFcnR2012b(sp); emxInit_real_T(sp, &eta, 2, &f_emlrtRTEI, true); /* get the solution for the inverse heat source, u(x,t), */ /* N0 - number of space points */ /* N - number of time points */ /* t - time points */ /* gridT - time points grid */ /* x space points */ /* q0j flux at x=0 du/dn */ /* q1j flux at x=1 du/dn */ /* h0j boundary condition u(0,t) */ /* u1j boundary condition u(1,t) */ /* f multiplier of the source f(x,t)r(t) size[N N0] */ /* r calculated source term size [N,1] */ i12 = eta->size[0] * eta->size[1]; eta->size[0] = 1; sTime = emlrtNonNegativeCheckFastR2012b(N0, &eb_emlrtDCI, sp); eta->size[1] = (int32_T)emlrtIntegerCheckFastR2012b(sTime, &db_emlrtDCI, sp); emxEnsureCapacity(sp, (emxArray__common *)eta, i12, (int32_T)sizeof(real_T), &e_emlrtRTEI); sTime = emlrtNonNegativeCheckFastR2012b(N0, &eb_emlrtDCI, sp); loop_ub = (int32_T)emlrtIntegerCheckFastR2012b(sTime, &db_emlrtDCI, sp); for (i12 = 0; i12 < loop_ub; i12++) { eta->data[i12] = 1.0; } i12 = (int32_T)N0; emlrtDynamicBoundsCheckFastR2012b(1, 1, i12, &tc_emlrtBCI, sp); eta->data[0] = 0.5; i12 = (int32_T)N0; i13 = (int32_T)N0; eta->data[emlrtDynamicBoundsCheckFastR2012b(i13, 1, i12, &uc_emlrtBCI, sp) - 1] = 0.5; i12 = u->size[0] * u->size[1]; sTime = emlrtNonNegativeCheckFastR2012b(N, &gb_emlrtDCI, sp); u->size[0] = (int32_T)emlrtIntegerCheckFastR2012b(sTime, &fb_emlrtDCI, sp); u->size[1] = (int32_T)N0; emxEnsureCapacity(sp, (emxArray__common *)u, i12, (int32_T)sizeof(real_T), &e_emlrtRTEI); sTime = emlrtNonNegativeCheckFastR2012b(N, &gb_emlrtDCI, sp); loop_ub = (int32_T)emlrtIntegerCheckFastR2012b(sTime, &fb_emlrtDCI, sp) * (int32_T)N0; for (i12 = 0; i12 < loop_ub; i12++) { u->data[i12] = 0.0; } j = 1; emxInit_real_T(sp, &b_f, 2, &e_emlrtRTEI, true); while (j - 1 <= (int32_T)N0 - 1) { /* space index */ emlrtForLoopVectorCheckR2012b(1.0, 1.0, N, mxDOUBLE_CLASS, (int32_T)N, &gc_emlrtRTEI, sp); i = 1; while (i - 1 <= (int32_T)N - 1) { /* time index */ sTime = 0.0; /* cumulative sums */ sSpace = 0.0; emlrtForLoopVectorCheckR2012b(1.0, 1.0, N, mxDOUBLE_CLASS, (int32_T)N, &hc_emlrtRTEI, sp); tIdx = 0; while (tIdx <= (int32_T)N - 1) { /* time index */ loop_ub = f->size[1]; i12 = f->size[0]; b_i = emlrtDynamicBoundsCheckFastR2012b(i, 1, i12, &sc_emlrtBCI, sp); i12 = b_f->size[0] * b_f->size[1]; b_f->size[0] = 1; b_f->size[1] = loop_ub; emxEnsureCapacity(sp, (emxArray__common *)b_f, i12, (int32_T)sizeof (real_T), &e_emlrtRTEI); for (i12 = 0; i12 < loop_ub; i12++) { b_f->data[b_f->size[0] * i12] = f->data[(b_i + f->size[0] * i12) - 1]; } i12 = x->size[1]; i13 = t->size[1]; i14 = q0j->size[0]; i15 = x->size[1]; loop_ub = t->size[1]; b_i = q1j->size[0]; i16 = x->size[1]; i17 = t->size[1]; i18 = h0j->size[0]; i19 = x->size[1]; i20 = t->size[1]; i21 = h1j->size[0]; i22 = x->size[1]; i23 = t->size[1]; i24 = r->size[0]; st.site = &bb_emlrtRSI; b_st.site = &cb_emlrtRSI; c_st.site = &db_emlrtRSI; sTime = ((((sTime + Acoeff(&st, 0.0, 1.0 + (real_T)tIdx, x-> data[emlrtDynamicBoundsCheckFastR2012b(j, 1, i12, &cd_emlrtBCI, sp) - 1], t->data[emlrtDynamicBoundsCheckFastR2012b(i, 1, i13, &dd_emlrtBCI, sp) - 1], gridT) * q0j->data[emlrtDynamicBoundsCheckFastR2012b(tIdx + 1, 1, i14, &ed_emlrtBCI, sp) - 1]) + Acoeff(&st, 1.0, 1.0 + (real_T) tIdx, x->data[emlrtDynamicBoundsCheckFastR2012b(j, 1, i15, &fd_emlrtBCI, sp) - 1], t->data[emlrtDynamicBoundsCheckFastR2012b(i, 1, loop_ub, &gd_emlrtBCI, sp) - 1], gridT) * q1j-> data[emlrtDynamicBoundsCheckFastR2012b(tIdx + 1, 1, b_i, &hd_emlrtBCI, sp) - 1]) - Bcoeff(&b_st, 0.0, 1.0 + (real_T) tIdx, x->data[emlrtDynamicBoundsCheckFastR2012b(j, 1, i16, &id_emlrtBCI, sp) - 1], t-> data[emlrtDynamicBoundsCheckFastR2012b(i, 1, i17, &jd_emlrtBCI, sp) - 1], gridT) * h0j-> data[emlrtDynamicBoundsCheckFastR2012b(tIdx + 1, 1, i18, &kd_emlrtBCI, sp) - 1]) - Bcoeff(&b_st, 1.0, 1.0 + (real_T) tIdx, x->data[emlrtDynamicBoundsCheckFastR2012b(j, 1, i19, &ld_emlrtBCI, sp) - 1], t-> data[emlrtDynamicBoundsCheckFastR2012b(i, 1, i20, &md_emlrtBCI, sp) - 1], gridT) * h1j-> data[emlrtDynamicBoundsCheckFastR2012b(tIdx + 1, 1, i21, &nd_emlrtBCI, sp) - 1]) + b_Dcoeff(&c_st, x, 1.0 + (real_T) tIdx, x->data[emlrtDynamicBoundsCheckFastR2012b(j, 1, i22, &od_emlrtBCI, sp) - 1], t->data[emlrtDynamicBoundsCheckFastR2012b(i, 1, i23, &pd_emlrtBCI, sp) - 1], gridT, b_f) * r-> data[emlrtDynamicBoundsCheckFastR2012b(tIdx + 1, 1, i24, &qd_emlrtBCI, sp) - 1]; tIdx++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, sp); } loop_ub = 0; while (loop_ub <= (int32_T)N0 - 1) { /* space index */ i12 = x->size[1]; i13 = t->size[1]; i14 = u0->size[1]; i15 = 1 + loop_ub; st.site = &eb_emlrtRSI; sSpace += b_Ccoeff(&st, 1.0 + (real_T)loop_ub, x-> data[emlrtDynamicBoundsCheckFastR2012b(j, 1, i12, &yc_emlrtBCI, sp) - 1], t->data[emlrtDynamicBoundsCheckFastR2012b(i, 1, i13, &ad_emlrtBCI, sp) - 1], gridT) * u0-> data[emlrtDynamicBoundsCheckFastR2012b(i15, 1, i14, &bd_emlrtBCI, sp) - 1]; loop_ub++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, sp); } i12 = u->size[0]; i13 = u->size[1]; i14 = eta->size[1]; u->data[(emlrtDynamicBoundsCheckFastR2012b(i, 1, i12, &vc_emlrtBCI, sp) + u->size[0] * (emlrtDynamicBoundsCheckFastR2012b(j, 1, i13, &wc_emlrtBCI, sp) - 1)) - 1] = (sTime + sSpace) * eta-> data[emlrtDynamicBoundsCheckFastR2012b(j, 1, i14, &xc_emlrtBCI, sp) - 1]; i++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, sp); } j++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, sp); } emxFree_real_T(&b_f); emxFree_real_T(&eta); emlrtHeapReferenceStackLeaveFcnR2012b(sp); }
/* Function Definitions */ real_T Dcoeff(const emlrtStack *sp, const emxArray_real_T *y, real_T j, const emxArray_real_T *x, real_T t, const emxArray_real_T *gridT, const emxArray_real_T *f) { real_T vals; emxArray_real_T *a; int32_T i57; int32_T unnamed_idx_1; emxArray_real_T *r7; int32_T i58; int32_T i59; int32_T i60; int32_T i61; int32_T i62; int32_T i63; int32_T i64; int32_T i65; emlrtStack st; st.prev = sp; st.tls = sp->tls; emlrtHeapReferenceStackEnterFcnR2012b(sp); emxInit_real_T(sp, &a, 2, &c_emlrtRTEI, true); /* Calculate the integral int_0^1(f(y,t_j)*A_{yj}(x,t)dy) by midpoint */ /* integration rule */ /* the spatial integration of all points y at time t_j */ i57 = a->size[0] * a->size[1]; a->size[0] = 1; emxEnsureCapacity(sp, (emxArray__common *)a, i57, (int32_T)sizeof(real_T), &g_emlrtRTEI); unnamed_idx_1 = y->size[1]; i57 = a->size[0] * a->size[1]; a->size[1] = unnamed_idx_1; emxEnsureCapacity(sp, (emxArray__common *)a, i57, (int32_T)sizeof(real_T), &g_emlrtRTEI); unnamed_idx_1 = y->size[1]; for (i57 = 0; i57 < unnamed_idx_1; i57++) { a->data[i57] = 0.0; } emxInit_real_T(sp, &r7, 2, &g_emlrtRTEI, true); vals = 0.0; i57 = y->size[1]; emlrtDynamicBoundsCheckFastR2012b(1, 1, i57, &kb_emlrtBCI, sp); st.site = &v_emlrtRSI; b_Acoeff(&st, y->data[0], j, x, t, gridT, r7); i57 = r7->size[1]; emlrtSizeEqCheck1DFastR2012b(1, i57, &k_emlrtECI, sp); unnamed_idx_1 = y->size[1]; emlrtDynamicBoundsCheckFastR2012b(1, 1, unnamed_idx_1, &jb_emlrtBCI, sp); i57 = r7->size[1]; emlrtDynamicBoundsCheckFastR2012b(1, 1, i57, &pe_emlrtBCI, sp); a->data[0] = r7->data[0]; /* y = 0:1/(numel(y)-2):1; */ unnamed_idx_1 = 2; while (unnamed_idx_1 - 2 <= f->size[1] - 2) { i57 = y->size[1]; st.site = &w_emlrtRSI; b_Acoeff(&st, y->data[emlrtDynamicBoundsCheckFastR2012b(unnamed_idx_1, 1, i57, &hc_emlrtBCI, sp) - 1], j, x, t, gridT, r7); i57 = r7->size[1]; emlrtSizeEqCheck1DFastR2012b(1, i57, &l_emlrtECI, sp); i57 = r7->size[1]; emlrtDynamicBoundsCheckFastR2012b(1, 1, i57, &qe_emlrtBCI, sp); i57 = a->size[1]; a->data[emlrtDynamicBoundsCheckFastR2012b(unnamed_idx_1, 1, i57, &gc_emlrtBCI, sp) - 1] = r7->data[0]; i57 = a->size[1]; i58 = f->size[1]; i59 = a->size[1]; i60 = unnamed_idx_1 - 1; i61 = f->size[1]; i62 = unnamed_idx_1 - 1; i63 = y->size[1]; i64 = y->size[1]; i65 = unnamed_idx_1 - 1; vals += 0.5 * (a->data[emlrtDynamicBoundsCheckFastR2012b(unnamed_idx_1, 1, i57, &ic_emlrtBCI, sp) - 1] * f->data[emlrtDynamicBoundsCheckFastR2012b (unnamed_idx_1, 1, i58, &ib_emlrtBCI, sp) - 1] + a-> data[emlrtDynamicBoundsCheckFastR2012b(i60, 1, i59, &jc_emlrtBCI, sp) - 1] * f->data[emlrtDynamicBoundsCheckFastR2012b(i62, 1, i61, &hb_emlrtBCI, sp) - 1]) * (y->data[emlrtDynamicBoundsCheckFastR2012b (unnamed_idx_1, 1, i63, &kc_emlrtBCI, sp) - 1] - y-> data[emlrtDynamicBoundsCheckFastR2012b(i65, 1, i64, &lc_emlrtBCI, sp) - 1]); unnamed_idx_1++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, sp); } emxFree_real_T(&r7); emxFree_real_T(&a); emlrtHeapReferenceStackLeaveFcnR2012b(sp); return vals; }
real_T b_Dcoeff(const emlrtStack *sp, const emxArray_real_T *y, real_T j, real_T x, real_T t, const emxArray_real_T *gridT, const emxArray_real_T *f) { real_T vals; emxArray_real_T *a; int32_T i25; int32_T unnamed_idx_1; int32_T i26; int32_T i27; int32_T i28; int32_T i29; int32_T i30; int32_T i31; int32_T i32; int32_T i33; emlrtStack st; st.prev = sp; st.tls = sp->tls; emlrtHeapReferenceStackEnterFcnR2012b(sp); emxInit_real_T(sp, &a, 2, &c_emlrtRTEI, true); /* Calculate the integral int_0^1(f(y,t_j)*A_{yj}(x,t)dy) by midpoint */ /* integration rule */ /* the spatial integration of all points y at time t_j */ i25 = a->size[0] * a->size[1]; a->size[0] = 1; emxEnsureCapacity(sp, (emxArray__common *)a, i25, (int32_T)sizeof(real_T), &g_emlrtRTEI); unnamed_idx_1 = y->size[1]; i25 = a->size[0] * a->size[1]; a->size[1] = unnamed_idx_1; emxEnsureCapacity(sp, (emxArray__common *)a, i25, (int32_T)sizeof(real_T), &g_emlrtRTEI); unnamed_idx_1 = y->size[1]; for (i25 = 0; i25 < unnamed_idx_1; i25++) { a->data[i25] = 0.0; } vals = 0.0; unnamed_idx_1 = y->size[1]; emlrtDynamicBoundsCheckFastR2012b(1, 1, unnamed_idx_1, &jb_emlrtBCI, sp); i25 = y->size[1]; emlrtDynamicBoundsCheckFastR2012b(1, 1, i25, &kb_emlrtBCI, sp); st.site = &v_emlrtRSI; a->data[0] = Acoeff(&st, y->data[0], j, x, t, gridT); /* y = 0:1/(numel(y)-2):1; */ unnamed_idx_1 = 2; while (unnamed_idx_1 - 2 <= f->size[1] - 2) { i25 = a->size[1]; i26 = y->size[1]; st.site = &w_emlrtRSI; a->data[emlrtDynamicBoundsCheckFastR2012b(unnamed_idx_1, 1, i25, &gc_emlrtBCI, sp) - 1] = Acoeff(&st, y-> data[emlrtDynamicBoundsCheckFastR2012b(unnamed_idx_1, 1, i26, &hc_emlrtBCI, sp) - 1], j, x, t, gridT); i25 = a->size[1]; i26 = f->size[1]; i27 = a->size[1]; i28 = unnamed_idx_1 - 1; i29 = f->size[1]; i30 = unnamed_idx_1 - 1; i31 = y->size[1]; i32 = y->size[1]; i33 = unnamed_idx_1 - 1; vals += 0.5 * (a->data[emlrtDynamicBoundsCheckFastR2012b(unnamed_idx_1, 1, i25, &ic_emlrtBCI, sp) - 1] * f->data[emlrtDynamicBoundsCheckFastR2012b (unnamed_idx_1, 1, i26, &ib_emlrtBCI, sp) - 1] + a-> data[emlrtDynamicBoundsCheckFastR2012b(i28, 1, i27, &jc_emlrtBCI, sp) - 1] * f->data[emlrtDynamicBoundsCheckFastR2012b(i30, 1, i29, &hb_emlrtBCI, sp) - 1]) * (y->data[emlrtDynamicBoundsCheckFastR2012b (unnamed_idx_1, 1, i31, &kc_emlrtBCI, sp) - 1] - y-> data[emlrtDynamicBoundsCheckFastR2012b(i33, 1, i32, &lc_emlrtBCI, sp) - 1]); unnamed_idx_1++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, sp); } emxFree_real_T(&a); emlrtHeapReferenceStackLeaveFcnR2012b(sp); return vals; }
/* 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 */ static void b_equalizeOFDM(testMACRouterStackData *SD, const emlrtStack *sp, const creal_T recv_data[1280], const real_T tx_longPreamble[53], const real_T tx_pilots[48], const real_T c_tx_pilotLocationsWithoutGuard[4], const real_T tx_dataSubcarrierIndexies_data[48], const int32_T tx_dataSubcarrierIndexies_size[2], c_struct_T *estimate, OFDMDemodulator_1 *hPreambleDemod, OFDMDemodulator_1 *hDataDemod, creal_T R[576], emxArray_creal_T *Rraw) { OFDMDemodulator_1 *obj; const mxArray *y; static const int32_T iv198[2] = { 1, 45 }; const mxArray *m49; char_T cv241[45]; int32_T i; static const char_T cv242[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 iv199[2] = { 1, 4 }; char_T cv243[4]; static const char_T cv244[4] = { 's', 't', 'e', 'p' }; const mxArray *c_y; static const int32_T iv200[2] = { 1, 51 }; char_T cv245[51]; static const char_T cv246[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 iv201[2] = { 1, 5 }; char_T cv247[5]; static const char_T cv248[5] = { 's', 'e', 't', 'u', 'p' }; int8_T fullGrid[64]; int32_T k; static const int8_T iv202[11] = { 0, 1, 2, 3, 4, 5, 59, 60, 61, 62, 63 }; int8_T ii_data[64]; int32_T ii; boolean_T exitg2; boolean_T guard2 = FALSE; int8_T b_ii_data[64]; creal_T recv[64]; emxArray_creal_T *RLongFirst; const mxArray *e_y; static const int32_T iv203[2] = { 1, 45 }; const mxArray *f_y; static const int32_T iv204[2] = { 1, 4 }; const mxArray *g_y; static const int32_T iv205[2] = { 1, 51 }; const mxArray *h_y; static const int32_T iv206[2] = { 1, 5 }; boolean_T exitg1; boolean_T guard1 = FALSE; creal_T b_recv[64]; emxArray_creal_T *RLongSecond; emxArray_creal_T *b_R; creal_T c_R[106]; real_T b_tx_longPreamble[106]; creal_T RNormal[106]; real_T dv13[106]; real_T dv14[106]; real_T REnergy[53]; creal_T RConj[53]; creal_T b_RConj[53]; const mxArray *i_y; static const int32_T iv207[2] = { 1, 45 }; const mxArray *j_y; static const int32_T iv208[2] = { 1, 4 }; const mxArray *k_y; static const int32_T iv209[2] = { 1, 51 }; const mxArray *l_y; static const int32_T iv210[2] = { 1, 5 }; int8_T b_fullGrid[768]; static const int16_T iv211[48] = { 11, 25, 39, 53, 75, 89, 103, 117, 139, 153, 167, 181, 203, 217, 231, 245, 267, 281, 295, 309, 331, 345, 359, 373, 395, 409, 423, 437, 459, 473, 487, 501, 523, 537, 551, 565, 587, 601, 615, 629, 651, 665, 679, 693, 715, 729, 743, 757 }; boolean_T c_fullGrid[768]; int32_T ii_size[1]; int32_T c_ii_data[768]; real_T d_ii_data[768]; int32_T b_ii_size[1]; creal_T RXPilots[48]; creal_T preambleGainsFull[636]; int32_T ia; int32_T iv212[3]; static const int8_T iv213[3] = { 48, 12, 1 }; int32_T b_Rraw[3]; creal_T PilotNormal[48]; real_T pilotEqGains_re; real_T pilotEqGains_im; real_T a[48]; real_T PilotEnergy[48]; creal_T b_PilotNormal[48]; creal_T pilotEqGains[576]; creal_T preambleGainsFull_data[576]; creal_T b_preambleGainsFull_data[576]; creal_T c_preambleGainsFull_data[576]; real_T preambleGainsFull_data_re; real_T preambleGainsFull_data_im; 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); /* equalizeOFDM: Equalize the entire OFDM frame through the use of both */ /* the long preamble from the 802.11a standard and four pilot tones in */ /* the data frames themselves. The gains from the pilots are */ /* interpolated across frequency to fill the data frame and apply gains */ /* to all data subcarriers. */ /* %% Use Long Preamble frame to estimate channel in frequency domain */ /* Separate out received preambles */ emlrtVectorVectorIndexCheckR2012b(1280, 1, 1, 160, &y_emlrtECI, sp); /* Demod */ st.site = &xr_emlrtRSI; obj = hPreambleDemod; if (!obj->isReleased) { } else { y = NULL; m49 = mxCreateCharArray(2, iv198); for (i = 0; i < 45; i++) { cv241[i] = cv242[i]; } emlrtInitCharArrayR2013a(&st, 45, m49, cv241); emlrtAssign(&y, m49); b_y = NULL; m49 = mxCreateCharArray(2, iv199); for (i = 0; i < 4; i++) { cv243[i] = cv244[i]; } emlrtInitCharArrayR2013a(&st, 4, m49, cv243); emlrtAssign(&b_y, m49); 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; m49 = mxCreateCharArray(2, iv200); for (i = 0; i < 51; i++) { cv245[i] = cv246[i]; } emlrtInitCharArrayR2013a(&b_st, 51, m49, cv245); emlrtAssign(&c_y, m49); d_y = NULL; m49 = mxCreateCharArray(2, iv201); for (i = 0; i < 5; i++) { cv247[i] = cv248[i]; } emlrtInitCharArrayR2013a(&b_st, 5, m49, cv247); emlrtAssign(&d_y, m49); 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; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; memset(&fullGrid[0], 1, sizeof(int8_T) << 6); for (k = 0; k < 11; k++) { fullGrid[iv202[k]] = 0; } d_st.site = &fs_emlrtRSI; i = 0; ii = 1; exitg2 = FALSE; while ((exitg2 == FALSE) && (ii < 65)) { guard2 = FALSE; if (fullGrid[ii - 1] == 1) { i++; ii_data[i - 1] = (int8_T)ii; if (i >= 64) { exitg2 = TRUE; } else { guard2 = TRUE; } } else { guard2 = TRUE; } if (guard2 == TRUE) { ii++; } } if (1 > i) { i = 0; } for (k = 0; k < i; k++) { b_ii_data[k] = ii_data[k]; } for (k = 0; k < i; k++) { ii_data[k] = b_ii_data[k]; } d_st.site = &fs_emlrtRSI; k = obj->pDataLinearIndices->size[0]; obj->pDataLinearIndices->size[0] = i; emxEnsureCapacity(&d_st, (emxArray__common *)obj->pDataLinearIndices, k, (int32_T)sizeof(real_T), &pb_emlrtRTEI); for (k = 0; k < i; k++) { obj->pDataLinearIndices->data[k] = ii_data[k]; } c_st.site = &cb_emlrtRSI; } 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; 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; b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; memcpy(&recv[0], &recv_data[192], sizeof(creal_T) << 6); emxInit_creal_T(&st, &RLongFirst, 3, &yb_emlrtRTEI, TRUE); b_st.site = &cb_emlrtRSI; OFDMDemodulator_stepImpl(&b_st, obj, recv, RLongFirst); /* First half of long preamble */ st.site = &yr_emlrtRSI; obj = hPreambleDemod; if (!obj->isReleased) { } else { e_y = NULL; m49 = mxCreateCharArray(2, iv203); for (i = 0; i < 45; i++) { cv241[i] = cv242[i]; } emlrtInitCharArrayR2013a(&st, 45, m49, cv241); emlrtAssign(&e_y, m49); f_y = NULL; m49 = mxCreateCharArray(2, iv204); for (i = 0; i < 4; i++) { cv243[i] = cv244[i]; } emlrtInitCharArrayR2013a(&st, 4, m49, cv243); emlrtAssign(&f_y, m49); b_st.site = &cb_emlrtRSI; c_error(&b_st, message(&b_st, e_y, f_y, &emlrtMCI), &emlrtMCI); } if (!obj->isInitialized) { b_st.site = &cb_emlrtRSI; if (!obj->isInitialized) { } else { g_y = NULL; m49 = mxCreateCharArray(2, iv205); for (i = 0; i < 51; i++) { cv245[i] = cv246[i]; } emlrtInitCharArrayR2013a(&b_st, 51, m49, cv245); emlrtAssign(&g_y, m49); h_y = NULL; m49 = mxCreateCharArray(2, iv206); for (i = 0; i < 5; i++) { cv247[i] = cv248[i]; } emlrtInitCharArrayR2013a(&b_st, 5, m49, cv247); emlrtAssign(&h_y, m49); c_st.site = &cb_emlrtRSI; c_error(&c_st, message(&c_st, g_y, h_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; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; memset(&fullGrid[0], 1, sizeof(int8_T) << 6); for (k = 0; k < 11; k++) { fullGrid[iv202[k]] = 0; } d_st.site = &fs_emlrtRSI; i = 0; ii = 1; exitg1 = FALSE; while ((exitg1 == FALSE) && (ii < 65)) { guard1 = FALSE; if (fullGrid[ii - 1] == 1) { i++; ii_data[i - 1] = (int8_T)ii; if (i >= 64) { exitg1 = TRUE; } else { guard1 = TRUE; } } else { guard1 = TRUE; } if (guard1 == TRUE) { ii++; } } if (1 > i) { i = 0; } for (k = 0; k < i; k++) { b_ii_data[k] = ii_data[k]; } for (k = 0; k < i; k++) { ii_data[k] = b_ii_data[k]; } d_st.site = &fs_emlrtRSI; k = obj->pDataLinearIndices->size[0]; obj->pDataLinearIndices->size[0] = i; emxEnsureCapacity(&d_st, (emxArray__common *)obj->pDataLinearIndices, k, (int32_T)sizeof(real_T), &pb_emlrtRTEI); for (k = 0; k < i; k++) { obj->pDataLinearIndices->data[k] = ii_data[k]; } c_st.site = &cb_emlrtRSI; } 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; 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; b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; memcpy(&b_recv[0], &recv_data[256], sizeof(creal_T) << 6); emxInit_creal_T(&st, &RLongSecond, 3, &ac_emlrtRTEI, TRUE); emxInit_creal_T(&st, &b_R, 3, &pb_emlrtRTEI, TRUE); b_st.site = &cb_emlrtRSI; OFDMDemodulator_stepImpl(&b_st, obj, b_recv, RLongSecond); /* Second half of long preamble */ /* %% Preamble Equalization */ /* Get Equalizer tap gains */ k = RLongFirst->size[0]; ii = RLongSecond->size[0]; emlrtDimSizeEqCheckFastR2012b(k, ii, &x_emlrtECI, sp); st.site = &as_emlrtRSI; k = b_R->size[0] * b_R->size[1] * b_R->size[2]; b_R->size[0] = RLongFirst->size[0]; b_R->size[1] = 2; b_R->size[2] = 1; emxEnsureCapacity(&st, (emxArray__common *)b_R, k, (int32_T)sizeof(creal_T), &pb_emlrtRTEI); i = RLongFirst->size[0]; for (k = 0; k < i; k++) { b_R->data[k] = RLongFirst->data[k]; } emxFree_creal_T(&RLongFirst); i = RLongSecond->size[0]; for (k = 0; k < i; k++) { b_R->data[k + b_R->size[0]] = RLongSecond->data[k]; } emxFree_creal_T(&RLongSecond); /* Calculate Equalizer Taps with preamble symbols */ /* Calculate non-normalized channel gains */ for (k = 0; k < 53; k++) { ii = b_R->size[0]; i = 1 + k; emlrtDynamicBoundsCheckFastR2012b(i, 1, ii, &lb_emlrtBCI, &st); } i = b_R->size[0]; for (k = 0; k < 2; k++) { for (ii = 0; ii < 53; ii++) { c_R[ii + 53 * k] = b_R->data[ii + i * k]; } } emxFree_creal_T(&b_R); for (k = 0; k < 53; k++) { b_tx_longPreamble[k] = tx_longPreamble[k]; b_tx_longPreamble[53 + k] = tx_longPreamble[k]; } b_st.site = &bt_emlrtRSI; b_rdivide(c_R, b_tx_longPreamble, RNormal); /* Known is the original Long Preamble symbols */ /* Scale channel gains */ b_st.site = &ct_emlrtRSI; d_abs(RNormal, dv13); memcpy(&dv14[0], &dv13[0], 106U * sizeof(real_T)); b_st.site = &ct_emlrtRSI; b_power(dv14, dv13); b_st.site = &ct_emlrtRSI; c_mean(dv13, REnergy); b_st.site = &dt_emlrtRSI; d_mean(RNormal, RConj); for (k = 0; k < 53; k++) { RConj[k].im = -RConj[k].im; b_RConj[k] = RConj[k]; } b_st.site = &et_emlrtRSI; c_rdivide(b_RConj, REnergy, RConj); /* Separate data from preambles */ /* recvData = recv(length(tx.preambles)+1:length(tx.preambles)+(hDataDemod.NumSymbols)*(tx.FFTLength+hDataDemod.CyclicPrefixLength)); */ emlrtVectorVectorIndexCheckR2012b(1280, 1, 1, 960, &w_emlrtECI, sp); /* CG */ /* OFDM Demod */ st.site = &bs_emlrtRSI; obj = hDataDemod; if (!obj->isReleased) { } else { i_y = NULL; m49 = mxCreateCharArray(2, iv207); for (i = 0; i < 45; i++) { cv241[i] = cv242[i]; } emlrtInitCharArrayR2013a(&st, 45, m49, cv241); emlrtAssign(&i_y, m49); j_y = NULL; m49 = mxCreateCharArray(2, iv208); for (i = 0; i < 4; i++) { cv243[i] = cv244[i]; } emlrtInitCharArrayR2013a(&st, 4, m49, cv243); emlrtAssign(&j_y, m49); b_st.site = &cb_emlrtRSI; c_error(&b_st, message(&b_st, i_y, j_y, &emlrtMCI), &emlrtMCI); } if (!obj->isInitialized) { b_st.site = &cb_emlrtRSI; if (!obj->isInitialized) { } else { k_y = NULL; m49 = mxCreateCharArray(2, iv209); for (i = 0; i < 51; i++) { cv245[i] = cv246[i]; } emlrtInitCharArrayR2013a(&b_st, 51, m49, cv245); emlrtAssign(&k_y, m49); l_y = NULL; m49 = mxCreateCharArray(2, iv210); for (i = 0; i < 5; i++) { cv247[i] = cv248[i]; } emlrtInitCharArrayR2013a(&b_st, 5, m49, cv247); emlrtAssign(&l_y, m49); c_st.site = &cb_emlrtRSI; c_error(&c_st, message(&c_st, k_y, l_y, &emlrtMCI), &emlrtMCI); } c_st.site = &cb_emlrtRSI; g_SystemProp_matlabCodegenSetAn(obj); c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; b_SystemCore_validateProperties(); c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; memset(&b_fullGrid[0], 1, 768U * sizeof(int8_T)); for (k = 0; k < 12; k++) { for (ii = 0; ii < 11; ii++) { b_fullGrid[iv202[ii] + (k << 6)] = 0; } b_fullGrid[32 + (k << 6)] = 0; } d_st.site = &st_emlrtRSI; d_st.site = &st_emlrtRSI; for (k = 0; k < 48; k++) { b_fullGrid[iv211[k]] = 2; } d_st.site = &fs_emlrtRSI; for (k = 0; k < 768; k++) { c_fullGrid[k] = (b_fullGrid[k] == 1); } eml_find(c_fullGrid, c_ii_data, ii_size); b_ii_size[0] = ii_size[0]; i = ii_size[0]; for (k = 0; k < i; k++) { d_ii_data[k] = c_ii_data[k]; } d_st.site = &fs_emlrtRSI; h_SystemProp_matlabCodegenSetAn(&d_st, obj, d_ii_data, b_ii_size); c_st.site = &cb_emlrtRSI; } 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; 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; b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; b_OFDMDemodulator_stepImpl(SD, &b_st, obj, *(creal_T (*)[960])&recv_data[320], Rraw, RXPilots); /* Expand equalizer gains to full frame size */ st.site = &cs_emlrtRSI; i = 0; for (ii = 0; ii < 12; ii++) { ia = 0; for (k = 0; k < 53; k++) { preambleGainsFull[i] = RConj[ia]; b_st.site = &ng_emlrtRSI; ia++; b_st.site = &og_emlrtRSI; i++; } } /* Isolate pilot gains from preamble equalizer */ /* Needed to correctly adjust pilot gains */ /* Apply preamble equalizer gains to data and pilots */ /* Correct pilots */ for (i = 0; i < 3; i++) { iv212[i] = iv213[i]; } for (k = 0; k < 3; k++) { b_Rraw[k] = Rraw->size[k]; } emlrtSizeEqCheckNDR2012b(iv212, b_Rraw, &v_emlrtECI, sp); /* Correct data */ /* %% Pilot Equalization */ /* Get pilot-based equalizer gains */ st.site = &ds_emlrtRSI; /* Calculate Equalizer Taps with pilot symbols */ /* Calculate non-normalized channel gains */ b_st.site = &vt_emlrtRSI; c_st.site = &k_emlrtRSI; for (k = 0; k < 12; k++) { for (ii = 0; ii < 4; ii++) { pilotEqGains_re = preambleGainsFull[((int32_T) c_tx_pilotLocationsWithoutGuard[ii] + 53 * k) - 1].re * RXPilots[ii + (k << 2)].re - preambleGainsFull[((int32_T) c_tx_pilotLocationsWithoutGuard[ii] + 53 * k) - 1].im * RXPilots[ii + (k << 2)].im; pilotEqGains_im = preambleGainsFull[((int32_T) c_tx_pilotLocationsWithoutGuard[ii] + 53 * k) - 1].re * RXPilots[ii + (k << 2)].im + preambleGainsFull[((int32_T) c_tx_pilotLocationsWithoutGuard[ii] + 53 * k) - 1].im * RXPilots[ii + (k << 2)].re; if (pilotEqGains_im == 0.0) { PilotNormal[ii + (k << 2)].re = pilotEqGains_re / tx_pilots[ii + (k << 2)]; PilotNormal[ii + (k << 2)].im = 0.0; } else if (pilotEqGains_re == 0.0) { PilotNormal[ii + (k << 2)].re = 0.0; PilotNormal[ii + (k << 2)].im = pilotEqGains_im / tx_pilots[ii + (k << 2)]; } else { PilotNormal[ii + (k << 2)].re = pilotEqGains_re / tx_pilots[ii + (k << 2)]; PilotNormal[ii + (k << 2)].im = pilotEqGains_im / tx_pilots[ii + (k << 2)]; } } } /* Scale channel gains */ b_st.site = &wt_emlrtRSI; for (k = 0; k < 48; k++) { c_st.site = &qc_emlrtRSI; d_st.site = &co_emlrtRSI; a[k] = muDoubleScalarHypot(PilotNormal[k].re, PilotNormal[k].im); } b_st.site = &wt_emlrtRSI; c_st.site = &n_emlrtRSI; d_st.site = &hp_emlrtRSI; for (k = 0; k < 48; k++) { d_st.site = &o_emlrtRSI; PilotEnergy[k] = a[k] * a[k]; } b_st.site = &xt_emlrtRSI; c_st.site = &k_emlrtRSI; /* Interpolate to data carrier size */ for (k = 0; k < 48; k++) { if (-PilotNormal[k].im == 0.0) { b_PilotNormal[k].re = PilotNormal[k].re / PilotEnergy[k]; b_PilotNormal[k].im = 0.0; } else if (PilotNormal[k].re == 0.0) { b_PilotNormal[k].re = 0.0; b_PilotNormal[k].im = -PilotNormal[k].im / PilotEnergy[k]; } else { b_PilotNormal[k].re = PilotNormal[k].re / PilotEnergy[k]; b_PilotNormal[k].im = -PilotNormal[k].im / PilotEnergy[k]; } } b_st.site = &yt_emlrtRSI; resample(SD, &b_st, b_PilotNormal, pilotEqGains); /* Apply Equalizer from Pilots */ for (k = 0; k < 12; k++) { for (ii = 0; ii < 48; ii++) { preambleGainsFull_data[ii + 48 * k] = preambleGainsFull[((int32_T) tx_dataSubcarrierIndexies_data[tx_dataSubcarrierIndexies_size[0] * ii] + 53 * k) - 1]; } } for (k = 0; k < 12; k++) { memcpy(&b_preambleGainsFull_data[48 * k], &preambleGainsFull_data[48 * k], 48U * sizeof(creal_T)); } i = Rraw->size[0]; for (k = 0; k < 12; k++) { for (ii = 0; ii < 48; ii++) { c_preambleGainsFull_data[ii + 48 * k].re = b_preambleGainsFull_data[ii + 48 * k].re * Rraw->data[ii + i * k].re - b_preambleGainsFull_data[ii + 48 * k].im * Rraw->data[ii + i * k].im; c_preambleGainsFull_data[ii + 48 * k].im = b_preambleGainsFull_data[ii + 48 * k].re * Rraw->data[ii + i * k].im + b_preambleGainsFull_data[ii + 48 * k].im * Rraw->data[ii + i * k].re; } } for (k = 0; k < 12; k++) { for (ii = 0; ii < 48; ii++) { pilotEqGains_re = pilotEqGains[ii + 48 * k].re; pilotEqGains_im = pilotEqGains[ii + 48 * k].im; preambleGainsFull_data_re = c_preambleGainsFull_data[ii + 48 * k].re; preambleGainsFull_data_im = c_preambleGainsFull_data[ii + 48 * k].im; R[ii + 48 * k].re = pilotEqGains_re * preambleGainsFull_data_re - pilotEqGains_im * preambleGainsFull_data_im; R[ii + 48 * k].im = pilotEqGains_re * preambleGainsFull_data_im + pilotEqGains_im * preambleGainsFull_data_re; } } /* Save Gains for visualization */ estimate->pilotEqGains.size[0] = 48; estimate->pilotEqGains.size[1] = 12; for (k = 0; k < 576; k++) { estimate->pilotEqGains.data[k] = pilotEqGains[k]; } estimate->preambleEqGains.size[0] = 53; for (k = 0; k < 53; k++) { estimate->preambleEqGains.data[k] = RConj[k]; } emlrtHeapReferenceStackLeaveFcnR2012b(sp); }
/* Function Definitions */ real_T signalPower(const emxArray_creal_T *input) { real_T out; emxArray_real_T *a; emxArray_real_T *b; int32_T i2; int32_T i; const mxArray *y; static const int32_T iv11[2] = { 1, 45 }; const mxArray *m1; char_T cv17[45]; static const char_T cv18[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 iv12[2] = { 1, 21 }; char_T cv19[21]; static const char_T cv20[21] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T', 'L', 'A', 'B', ':', 'i', 'n', 'n', 'e', 'r', 'd', 'i', 'm' }; real_T c_y; ptrdiff_t n_t; ptrdiff_t incx_t; ptrdiff_t incy_t; double * xix0_t; double * yiy0_t; emlrtHeapReferenceStackEnterFcnR2012b(emlrtRootTLSGlobal); b_emxInit_real_T(&a, 2, &f_emlrtRTEI, TRUE); emxInit_real_T(&b, 1, &f_emlrtRTEI, TRUE); /* out=input'*input/sentBitsSize; */ /* out=abs(out); */ emlrtPushRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal); b_abs(input, b); i2 = a->size[0] * a->size[1]; a->size[0] = 1; emxEnsureCapacity((emxArray__common *)a, i2, (int32_T)sizeof(real_T), &f_emlrtRTEI); i = b->size[0]; i2 = a->size[0] * a->size[1]; a->size[1] = i; emxEnsureCapacity((emxArray__common *)a, i2, (int32_T)sizeof(real_T), &f_emlrtRTEI); i = b->size[0]; for (i2 = 0; i2 < i; i2++) { a->data[i2] = b->data[i2]; } b_abs(input, b); emlrtPushRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal); if (!(a->size[1] == b->size[0])) { if ((a->size[1] == 1) || (b->size[0] == 1)) { emlrtPushRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal); emlrt_synchGlobalsToML(); y = NULL; m1 = mxCreateCharArray(2, iv11); for (i = 0; i < 45; i++) { cv17[i] = cv18[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m1, cv17); emlrtAssign(&y, m1); error(message(y, &i_emlrtMCI), &j_emlrtMCI); emlrt_synchGlobalsFromML(); emlrtPopRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal); emlrt_synchGlobalsToML(); b_y = NULL; m1 = mxCreateCharArray(2, iv12); for (i = 0; i < 21; i++) { cv19[i] = cv20[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m1, cv19); emlrtAssign(&b_y, m1); error(message(b_y, &k_emlrtMCI), &l_emlrtMCI); emlrt_synchGlobalsFromML(); emlrtPopRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal); } } emlrtPopRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal); if ((a->size[1] == 1) || (b->size[0] == 1)) { c_y = 0.0; for (i2 = 0; i2 < a->size[1]; i2++) { c_y += a->data[a->size[0] * i2] * b->data[i2]; } } else { emlrtPushRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&q_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&r_emlrtRSI, emlrtRootTLSGlobal); if (a->size[1] < 1) { c_y = 0.0; } else { emlrtPushRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&y_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); n_t = (ptrdiff_t)(a->size[1]); emlrtPopRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&y_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); incx_t = (ptrdiff_t)(1); emlrtPopRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&bb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); incy_t = (ptrdiff_t)(1); emlrtPopRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&bb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&cb_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); xix0_t = (double *)(&a->data[0]); emlrtPopRtStackR2012b(&cb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&db_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); yiy0_t = (double *)(&b->data[0]); emlrtPopRtStackR2012b(&db_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); c_y = ddot(&n_t, xix0_t, &incx_t, yiy0_t, &incy_t); emlrtPopRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&r_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&q_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal); } emxFree_real_T(&b); emxFree_real_T(&a); out = c_y / (real_T)input->size[0]; emlrtPopRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal); emlrtHeapReferenceStackLeaveFcnR2012b(emlrtRootTLSGlobal); return out; }
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); }
/* * Arguments : const mxArray *prhs[15] * const mxArray *plhs[7] * Return Type : void */ void clcOptTrj_tmp_api(const mxArray *prhs[15], const mxArray *plhs[7]) { emxArray_real_T *engKinNumVec_wayInx; emxArray_real_T *engKinMat_engKinInx_wayInx; emxArray_real_T *engKinOptVec; emxArray_real_T *batEngDltOptVec; emxArray_real_T *fulEngDltOptVec; emxArray_real_T *staVec; emxArray_real_T *psiEngKinOptVec; real_T disFlg; real_T wayStp; real_T wayNum; real_T wayInxBeg; real_T wayInxEnd; real_T staEnd; real_T engKinNum; real_T engKinEndInxVal; real_T staNum; real_T (*optPreInxTn3)[52800]; real_T (*batFrcOptTn3)[52800]; real_T (*fulEngOptTn3)[52800]; real_T (*cos2goActMat)[66]; real_T engKinEndInx; real_T fulEngOpt; emlrtStack st = { NULL, NULL, NULL }; st.tls = emlrtRootTLSGlobal; emlrtHeapReferenceStackEnterFcnR2012b(&st); emxInit_real_T(&st, &engKinNumVec_wayInx, 1, true); b_emxInit_real_T(&st, &engKinMat_engKinInx_wayInx, 2, true); emxInit_real_T(&st, &engKinOptVec, 1, true); emxInit_real_T(&st, &batEngDltOptVec, 1, true); emxInit_real_T(&st, &fulEngDltOptVec, 1, true); emxInit_real_T(&st, &staVec, 1, true); emxInit_real_T(&st, &psiEngKinOptVec, 1, true); prhs[9] = emlrtProtectR2012b(prhs[9], 9, false, -1); prhs[10] = emlrtProtectR2012b(prhs[10], 10, false, -1); prhs[11] = emlrtProtectR2012b(prhs[11], 11, false, -1); prhs[12] = emlrtProtectR2012b(prhs[12], 12, false, -1); prhs[13] = emlrtProtectR2012b(prhs[13], 13, false, -1); prhs[14] = emlrtProtectR2012b(prhs[14], 14, false, -1); /* Marshall function inputs */ disFlg = emlrt_marshallIn(&st, emlrtAliasP(prhs[0]), "disFlg"); wayStp = emlrt_marshallIn(&st, emlrtAliasP(prhs[1]), "wayStp"); wayNum = emlrt_marshallIn(&st, emlrtAliasP(prhs[2]), "wayNum"); wayInxBeg = emlrt_marshallIn(&st, emlrtAliasP(prhs[3]), "wayInxBeg"); wayInxEnd = emlrt_marshallIn(&st, emlrtAliasP(prhs[4]), "wayInxEnd"); staEnd = emlrt_marshallIn(&st, emlrtAliasP(prhs[5]), "staEnd"); engKinNum = emlrt_marshallIn(&st, emlrtAliasP(prhs[6]), "engKinNum"); engKinEndInxVal = emlrt_marshallIn(&st, emlrtAliasP(prhs[7]), "engKinEndInxVal"); staNum = emlrt_marshallIn(&st, emlrtAliasP(prhs[8]), "staNum"); c_emlrt_marshallIn(&st, emlrtAlias(prhs[9]), "engKinNumVec_wayInx", engKinNumVec_wayInx); e_emlrt_marshallIn(&st, emlrtAlias(prhs[10]), "engKinMat_engKinInx_wayInx", engKinMat_engKinInx_wayInx); optPreInxTn3 = g_emlrt_marshallIn(&st, emlrtAlias(prhs[11]), "optPreInxTn3"); batFrcOptTn3 = g_emlrt_marshallIn(&st, emlrtAlias(prhs[12]), "batFrcOptTn3"); fulEngOptTn3 = g_emlrt_marshallIn(&st, emlrtAlias(prhs[13]), "fulEngOptTn3"); cos2goActMat = i_emlrt_marshallIn(&st, emlrtAlias(prhs[14]), "cos2goActMat"); /* Invoke the target function */ clcOptTrj_tmp(disFlg, wayStp, wayNum, wayInxBeg, wayInxEnd, staEnd, engKinNum, engKinEndInxVal, staNum, engKinNumVec_wayInx, engKinMat_engKinInx_wayInx, *optPreInxTn3, *batFrcOptTn3, *fulEngOptTn3, *cos2goActMat, engKinOptVec, batEngDltOptVec, fulEngDltOptVec, staVec, psiEngKinOptVec, &fulEngOpt, &engKinEndInx); /* Marshall function outputs */ plhs[0] = emlrt_marshallOut(engKinOptVec); plhs[1] = emlrt_marshallOut(batEngDltOptVec); plhs[2] = emlrt_marshallOut(fulEngDltOptVec); plhs[3] = emlrt_marshallOut(staVec); plhs[4] = emlrt_marshallOut(psiEngKinOptVec); plhs[5] = b_emlrt_marshallOut(fulEngOpt); plhs[6] = b_emlrt_marshallOut(engKinEndInx); psiEngKinOptVec->canFreeData = false; emxFree_real_T(&psiEngKinOptVec); staVec->canFreeData = false; emxFree_real_T(&staVec); fulEngDltOptVec->canFreeData = false; emxFree_real_T(&fulEngDltOptVec); batEngDltOptVec->canFreeData = false; emxFree_real_T(&batEngDltOptVec); engKinOptVec->canFreeData = false; emxFree_real_T(&engKinOptVec); engKinMat_engKinInx_wayInx->canFreeData = false; emxFree_real_T(&engKinMat_engKinInx_wayInx); engKinNumVec_wayInx->canFreeData = false; emxFree_real_T(&engKinNumVec_wayInx); emlrtHeapReferenceStackLeaveFcnR2012b(&st); }
/* 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); }
void occflow_api(const mxArray *prhs[18], const mxArray *plhs[4]) { emxArray_real_T *cgridvec; emxArray_real_T *cgridvecprev; emxArray_real_T *context; emxArray_real_T *nei_idx; emxArray_real_T *nei_weight; emxArray_real_T *nei4u_idx; emxArray_real_T *nei4u_weight; emxArray_real_T *predvec; emxArray_real_T *maxvec; real_T nei_filter_n; 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; emlrtStack st = { NULL, NULL, NULL }; st.tls = emlrtRootTLSGlobal; emlrtHeapReferenceStackEnterFcnR2012b(&st); emxInit_real_T(&st, &cgridvec, 1, &b_emlrtRTEI, true); emxInit_real_T(&st, &cgridvecprev, 1, &b_emlrtRTEI, true); emxInit_real_T1(&st, &context, 2, &b_emlrtRTEI, true); emxInit_real_T1(&st, &nei_idx, 2, &b_emlrtRTEI, true); emxInit_real_T1(&st, &nei_weight, 2, &b_emlrtRTEI, true); emxInit_real_T1(&st, &nei4u_idx, 2, &b_emlrtRTEI, true); emxInit_real_T1(&st, &nei4u_weight, 2, &b_emlrtRTEI, true); emxInit_real_T(&st, &predvec, 1, &b_emlrtRTEI, true); emxInit_real_T(&st, &maxvec, 1, &b_emlrtRTEI, true); prhs[1] = emlrtProtectR2012b(prhs[1], 1, true, -1); prhs[2] = emlrtProtectR2012b(prhs[2], 2, true, -1); /* Marshall function inputs */ emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "cgridvec", cgridvec); emlrt_marshallIn(&st, emlrtAlias(prhs[1]), "cgridvecprev", cgridvecprev); c_emlrt_marshallIn(&st, emlrtAlias(prhs[2]), "context", context); c_emlrt_marshallIn(&st, emlrtAlias(prhs[3]), "nei_idx", nei_idx); c_emlrt_marshallIn(&st, emlrtAlias(prhs[4]), "nei_weight", nei_weight); nei_filter_n = e_emlrt_marshallIn(&st, emlrtAliasP(prhs[5]), "nei_filter_n"); c_emlrt_marshallIn(&st, emlrtAlias(prhs[6]), "nei4u_idx", nei4u_idx); c_emlrt_marshallIn(&st, emlrtAlias(prhs[7]), "nei4u_weight", nei4u_weight); nei4u_filter_n = e_emlrt_marshallIn(&st, emlrtAliasP(prhs[8]), "nei4u_filter_n"); occval = e_emlrt_marshallIn(&st, emlrtAliasP(prhs[9]), "occval"); minthreshold = e_emlrt_marshallIn(&st, emlrtAliasP(prhs[10]), "minthreshold"); maxthreshold = e_emlrt_marshallIn(&st, emlrtAliasP(prhs[11]), "maxthreshold"); reinitval = e_emlrt_marshallIn(&st, emlrtAliasP(prhs[12]), "reinitval"); intensifyrate = e_emlrt_marshallIn(&st, emlrtAliasP(prhs[13]), "intensifyrate"); nocc_attenuaterate = e_emlrt_marshallIn(&st, emlrtAliasP(prhs[14]), "nocc_attenuaterate"); unknown_attenuaterate = e_emlrt_marshallIn(&st, emlrtAliasP(prhs[15]), "unknown_attenuaterate"); sigm_coef = e_emlrt_marshallIn(&st, emlrtAliasP(prhs[16]), "sigm_coef"); do_attenuation_first = e_emlrt_marshallIn(&st, emlrtAliasP(prhs[17]), "do_attenuation_first"); /* Invoke the target function */ occflow(&st, cgridvec, cgridvecprev, context, nei_idx, nei_weight, nei_filter_n, nei4u_idx, nei4u_weight, nei4u_filter_n, occval, minthreshold, maxthreshold, reinitval, intensifyrate, nocc_attenuaterate, unknown_attenuaterate, sigm_coef, do_attenuation_first, predvec, maxvec); /* Marshall function outputs */ plhs[0] = c_emlrt_marshallOut(predvec); d_emlrt_marshallOut(cgridvecprev, prhs[1]); plhs[1] = prhs[1]; e_emlrt_marshallOut(context, prhs[2]); plhs[2] = prhs[2]; plhs[3] = c_emlrt_marshallOut(maxvec); maxvec->canFreeData = false; emxFree_real_T(&maxvec); predvec->canFreeData = false; emxFree_real_T(&predvec); nei4u_weight->canFreeData = false; emxFree_real_T(&nei4u_weight); nei4u_idx->canFreeData = false; emxFree_real_T(&nei4u_idx); nei_weight->canFreeData = false; emxFree_real_T(&nei_weight); nei_idx->canFreeData = false; emxFree_real_T(&nei_idx); context->canFreeData = false; emxFree_real_T(&context); cgridvecprev->canFreeData = false; emxFree_real_T(&cgridvecprev); cgridvec->canFreeData = false; emxFree_real_T(&cgridvec); emlrtHeapReferenceStackLeaveFcnR2012b(&st); }
void sqrtm(const emxArray_real_T *A, emxArray_creal_T *X, real_T *arg2) { emxArray_creal_T *T; emxArray_creal_T *y; boolean_T b0; const mxArray *b_y; static const int32_T iv40[2] = { 1, 19 }; const mxArray *m2; char_T cv12[19]; int32_T i; static const char_T cv13[19] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T', 'L', 'A', 'B', ':', 's', 'q', 'u', 'a', 'r', 'e' }; emxArray_creal_T *Q; emxArray_creal_T *r25; int32_T loop_ub; int16_T iv41[2]; emxArray_creal_T *R; real_T s_re; real_T s_im; int32_T k; real_T R_re; real_T R_im; real_T T_re; real_T T_im; real_T brm; int32_T i1; int32_T b_loop_ub; int32_T i2; emxArray_creal_T *b_T; emxArray_real_T *b_X; emlrtHeapReferenceStackEnterFcnR2012b(emlrtRootTLSGlobal); emxInit_creal_T(&T, 2, &k_emlrtRTEI, TRUE); emxInit_creal_T(&y, 2, &k_emlrtRTEI, TRUE); b0 = (A->size[0] == A->size[1]); if (b0) { } else { emlrtPushRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); emlrt_synchGlobalsToML(); b_y = NULL; m2 = mxCreateCharArray(2, iv40); for (i = 0; i < 19; i++) { cv12[i] = cv13[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 19, m2, cv12); emlrtAssign(&b_y, m2); error(message(b_y, &f_emlrtMCI), &g_emlrtMCI); emlrt_synchGlobalsFromML(); emlrtPopRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); } emxInit_creal_T(&Q, 2, &k_emlrtRTEI, TRUE); emxInit_creal_T(&r25, 2, &k_emlrtRTEI, TRUE); emlrtPushRtStackR2012b(&ib_emlrtRSI, emlrtRootTLSGlobal); schur(A, Q, r25); i = T->size[0] * T->size[1]; T->size[0] = r25->size[0]; T->size[1] = r25->size[1]; emxEnsureCapacity((emxArray__common *)T, i, (int32_T)sizeof(creal_T), &k_emlrtRTEI); loop_ub = r25->size[0] * r25->size[1]; for (i = 0; i < loop_ub; i++) { T->data[i] = r25->data[i]; } emxFree_creal_T(&r25); emlrtPopRtStackR2012b(&ib_emlrtRSI, emlrtRootTLSGlobal); for (i = 0; i < 2; i++) { iv41[i] = (int16_T)T->size[i]; } emxInit_creal_T(&R, 2, &l_emlrtRTEI, TRUE); i = R->size[0] * R->size[1]; R->size[0] = iv41[0]; emxEnsureCapacity((emxArray__common *)R, i, (int32_T)sizeof(creal_T), &k_emlrtRTEI); i = R->size[0] * R->size[1]; R->size[1] = iv41[1]; emxEnsureCapacity((emxArray__common *)R, i, (int32_T)sizeof(creal_T), &k_emlrtRTEI); loop_ub = iv41[0] * iv41[1]; for (i = 0; i < loop_ub; i++) { R->data[i].re = 0.0; R->data[i].im = 0.0; } emlrtPushRtStackR2012b(&jb_emlrtRSI, emlrtRootTLSGlobal); b0 = isUTmatD(T); emlrtPopRtStackR2012b(&jb_emlrtRSI, emlrtRootTLSGlobal); if (b0) { emlrtPushRtStackR2012b(&kb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&kb_emlrtRSI, emlrtRootTLSGlobal); for (loop_ub = 0; loop_ub + 1 <= A->size[0]; loop_ub++) { R->data[loop_ub + R->size[0] * loop_ub] = T->data[loop_ub + T->size[0] * loop_ub]; c_sqrt(&R->data[loop_ub + R->size[0] * loop_ub]); } } else { emlrtPushRtStackR2012b(&lb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&lb_emlrtRSI, emlrtRootTLSGlobal); for (loop_ub = 0; loop_ub + 1 <= A->size[0]; loop_ub++) { R->data[loop_ub + R->size[0] * loop_ub] = T->data[loop_ub + T->size[0] * loop_ub]; c_sqrt(&R->data[loop_ub + R->size[0] * loop_ub]); for (i = loop_ub - 1; i + 1 > 0; i--) { s_re = 0.0; s_im = 0.0; emlrtPushRtStackR2012b(&mb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&mb_emlrtRSI, emlrtRootTLSGlobal); for (k = i + 1; k + 1 <= loop_ub; k++) { R_re = R->data[i + R->size[0] * k].re * R->data[k + R->size[0] * loop_ub].re - R->data[i + R->size[0] * k].im * R->data[k + R->size[0] * loop_ub].im; R_im = R->data[i + R->size[0] * k].re * R->data[k + R->size[0] * loop_ub].im + R->data[i + R->size[0] * k].im * R->data[k + R->size[0] * loop_ub].re; s_re += R_re; s_im += R_im; } T_re = T->data[i + T->size[0] * loop_ub].re - s_re; T_im = T->data[i + T->size[0] * loop_ub].im - s_im; R_re = R->data[i + R->size[0] * i].re + R->data[loop_ub + R->size[0] * loop_ub].re; R_im = R->data[i + R->size[0] * i].im + R->data[loop_ub + R->size[0] * loop_ub].im; if (R_im == 0.0) { if (T_im == 0.0) { R->data[i + R->size[0] * loop_ub].re = T_re / R_re; R->data[i + R->size[0] * loop_ub].im = 0.0; } else if (T_re == 0.0) { R->data[i + R->size[0] * loop_ub].re = 0.0; R->data[i + R->size[0] * loop_ub].im = T_im / R_re; } else { R->data[i + R->size[0] * loop_ub].re = T_re / R_re; R->data[i + R->size[0] * loop_ub].im = T_im / R_re; } } else if (R_re == 0.0) { if (T_re == 0.0) { R->data[i + R->size[0] * loop_ub].re = T_im / R_im; R->data[i + R->size[0] * loop_ub].im = 0.0; } else if (T_im == 0.0) { R->data[i + R->size[0] * loop_ub].re = 0.0; R->data[i + R->size[0] * loop_ub].im = -(T_re / R_im); } else { R->data[i + R->size[0] * loop_ub].re = T_im / R_im; R->data[i + R->size[0] * loop_ub].im = -(T_re / R_im); } } else { brm = muDoubleScalarAbs(R_re); s_re = muDoubleScalarAbs(R_im); if (brm > s_re) { s_re = R_im / R_re; s_im = R_re + s_re * R_im; R->data[i + R->size[0] * loop_ub].re = (T_re + s_re * T_im) / s_im; R->data[i + R->size[0] * loop_ub].im = (T_im - s_re * T_re) / s_im; } else if (s_re == brm) { if (R_re > 0.0) { s_im = 0.5; } else { s_im = -0.5; } if (R_im > 0.0) { s_re = 0.5; } else { s_re = -0.5; } R->data[i + R->size[0] * loop_ub].re = (T_re * s_im + T_im * s_re) / brm; R->data[i + R->size[0] * loop_ub].im = (T_im * s_im - T_re * s_re) / brm; } else { s_re = R_re / R_im; s_im = R_im + s_re * R_re; R->data[i + R->size[0] * loop_ub].re = (s_re * T_re + T_im) / s_im; R->data[i + R->size[0] * loop_ub].im = (s_re * T_im - T_re) / s_im; } } } } } emlrtPushRtStackR2012b(&nb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&kh_emlrtRSI, emlrtRootTLSGlobal); dynamic_size_checks(Q, R); emlrtPopRtStackR2012b(&kh_emlrtRSI, emlrtRootTLSGlobal); if ((Q->size[1] == 1) || (R->size[0] == 1)) { i = y->size[0] * y->size[1]; y->size[0] = Q->size[0]; y->size[1] = R->size[1]; emxEnsureCapacity((emxArray__common *)y, i, (int32_T)sizeof(creal_T), &k_emlrtRTEI); loop_ub = Q->size[0]; for (i = 0; i < loop_ub; i++) { k = R->size[1]; for (i1 = 0; i1 < k; i1++) { y->data[i + y->size[0] * i1].re = 0.0; y->data[i + y->size[0] * i1].im = 0.0; b_loop_ub = Q->size[1]; for (i2 = 0; i2 < b_loop_ub; i2++) { s_re = Q->data[i + Q->size[0] * i2].re * R->data[i2 + R->size[0] * i1] .re - Q->data[i + Q->size[0] * i2].im * R->data[i2 + R->size[0] * i1] .im; s_im = Q->data[i + Q->size[0] * i2].re * R->data[i2 + R->size[0] * i1] .im + Q->data[i + Q->size[0] * i2].im * R->data[i2 + R->size[0] * i1] .re; y->data[i + y->size[0] * i1].re += s_re; y->data[i + y->size[0] * i1].im += s_im; } } } } else { iv41[0] = (int16_T)Q->size[0]; iv41[1] = (int16_T)R->size[1]; emlrtPushRtStackR2012b(&jh_emlrtRSI, emlrtRootTLSGlobal); i = y->size[0] * y->size[1]; y->size[0] = iv41[0]; emxEnsureCapacity((emxArray__common *)y, i, (int32_T)sizeof(creal_T), &k_emlrtRTEI); i = y->size[0] * y->size[1]; y->size[1] = iv41[1]; emxEnsureCapacity((emxArray__common *)y, i, (int32_T)sizeof(creal_T), &k_emlrtRTEI); loop_ub = iv41[0] * iv41[1]; for (i = 0; i < loop_ub; i++) { y->data[i].re = 0.0; y->data[i].im = 0.0; } eml_xgemm(Q->size[0], R->size[1], Q->size[1], Q, Q->size[0], R, Q->size[1], y, Q->size[0]); emlrtPopRtStackR2012b(&jh_emlrtRSI, emlrtRootTLSGlobal); } emxFree_creal_T(&R); i = T->size[0] * T->size[1]; T->size[0] = Q->size[1]; T->size[1] = Q->size[0]; emxEnsureCapacity((emxArray__common *)T, i, (int32_T)sizeof(creal_T), &k_emlrtRTEI); loop_ub = Q->size[0]; for (i = 0; i < loop_ub; i++) { k = Q->size[1]; for (i1 = 0; i1 < k; i1++) { T->data[i1 + T->size[0] * i].re = Q->data[i + Q->size[0] * i1].re; T->data[i1 + T->size[0] * i].im = -Q->data[i + Q->size[0] * i1].im; } } emxFree_creal_T(&Q); emlrtPushRtStackR2012b(&kh_emlrtRSI, emlrtRootTLSGlobal); dynamic_size_checks(y, T); emlrtPopRtStackR2012b(&kh_emlrtRSI, emlrtRootTLSGlobal); if ((y->size[1] == 1) || (T->size[0] == 1)) { i = X->size[0] * X->size[1]; X->size[0] = y->size[0]; X->size[1] = T->size[1]; emxEnsureCapacity((emxArray__common *)X, i, (int32_T)sizeof(creal_T), &k_emlrtRTEI); loop_ub = y->size[0]; for (i = 0; i < loop_ub; i++) { k = T->size[1]; for (i1 = 0; i1 < k; i1++) { X->data[i + X->size[0] * i1].re = 0.0; X->data[i + X->size[0] * i1].im = 0.0; b_loop_ub = y->size[1]; for (i2 = 0; i2 < b_loop_ub; i2++) { s_re = y->data[i + y->size[0] * i2].re * T->data[i2 + T->size[0] * i1] .re - y->data[i + y->size[0] * i2].im * T->data[i2 + T->size[0] * i1] .im; s_im = y->data[i + y->size[0] * i2].re * T->data[i2 + T->size[0] * i1] .im + y->data[i + y->size[0] * i2].im * T->data[i2 + T->size[0] * i1] .re; X->data[i + X->size[0] * i1].re += s_re; X->data[i + X->size[0] * i1].im += s_im; } } } } else { iv41[0] = (int16_T)y->size[0]; iv41[1] = (int16_T)T->size[1]; emlrtPushRtStackR2012b(&jh_emlrtRSI, emlrtRootTLSGlobal); i = X->size[0] * X->size[1]; X->size[0] = iv41[0]; emxEnsureCapacity((emxArray__common *)X, i, (int32_T)sizeof(creal_T), &k_emlrtRTEI); i = X->size[0] * X->size[1]; X->size[1] = iv41[1]; emxEnsureCapacity((emxArray__common *)X, i, (int32_T)sizeof(creal_T), &k_emlrtRTEI); loop_ub = iv41[0] * iv41[1]; for (i = 0; i < loop_ub; i++) { X->data[i].re = 0.0; X->data[i].im = 0.0; } eml_xgemm(y->size[0], T->size[1], y->size[1], y, y->size[0], T, y->size[1], X, y->size[0]); emlrtPopRtStackR2012b(&jh_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&nb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&kh_emlrtRSI, emlrtRootTLSGlobal); dynamic_size_checks(X, X); emlrtPopRtStackR2012b(&kh_emlrtRSI, emlrtRootTLSGlobal); if ((X->size[1] == 1) || (X->size[0] == 1)) { i = T->size[0] * T->size[1]; T->size[0] = X->size[0]; T->size[1] = X->size[1]; emxEnsureCapacity((emxArray__common *)T, i, (int32_T)sizeof(creal_T), &k_emlrtRTEI); loop_ub = X->size[0]; for (i = 0; i < loop_ub; i++) { k = X->size[1]; for (i1 = 0; i1 < k; i1++) { T->data[i + T->size[0] * i1].re = 0.0; T->data[i + T->size[0] * i1].im = 0.0; b_loop_ub = X->size[1]; for (i2 = 0; i2 < b_loop_ub; i2++) { s_re = X->data[i + X->size[0] * i2].re * X->data[i2 + X->size[0] * i1] .re - X->data[i + X->size[0] * i2].im * X->data[i2 + X->size[0] * i1] .im; s_im = X->data[i + X->size[0] * i2].re * X->data[i2 + X->size[0] * i1] .im + X->data[i + X->size[0] * i2].im * X->data[i2 + X->size[0] * i1] .re; T->data[i + T->size[0] * i1].re += s_re; T->data[i + T->size[0] * i1].im += s_im; } } } } else { iv41[0] = (int16_T)X->size[0]; iv41[1] = (int16_T)X->size[1]; emlrtPushRtStackR2012b(&jh_emlrtRSI, emlrtRootTLSGlobal); i = T->size[0] * T->size[1]; T->size[0] = iv41[0]; emxEnsureCapacity((emxArray__common *)T, i, (int32_T)sizeof(creal_T), &k_emlrtRTEI); i = T->size[0] * T->size[1]; T->size[1] = iv41[1]; emxEnsureCapacity((emxArray__common *)T, i, (int32_T)sizeof(creal_T), &k_emlrtRTEI); loop_ub = iv41[0] * iv41[1]; for (i = 0; i < loop_ub; i++) { T->data[i].re = 0.0; T->data[i].im = 0.0; } eml_xgemm(X->size[0], X->size[1], X->size[1], X, X->size[0], X, X->size[1], T, X->size[0]); emlrtPopRtStackR2012b(&jh_emlrtRSI, emlrtRootTLSGlobal); } emxInit_creal_T(&b_T, 2, &k_emlrtRTEI, TRUE); emlrtPopRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); i = b_T->size[0] * b_T->size[1]; b_T->size[0] = T->size[0]; b_T->size[1] = T->size[1]; emxEnsureCapacity((emxArray__common *)b_T, i, (int32_T)sizeof(creal_T), &k_emlrtRTEI); loop_ub = T->size[0] * T->size[1]; for (i = 0; i < loop_ub; i++) { b_T->data[i].re = T->data[i].re - A->data[i]; b_T->data[i].im = T->data[i].im; } emxInit_real_T(&b_X, 2, &k_emlrtRTEI, TRUE); s_re = norm(b_T); s_im = b_norm(A); *arg2 = s_re / s_im; emlrtPopRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); i = b_X->size[0] * b_X->size[1]; b_X->size[0] = X->size[0]; b_X->size[1] = X->size[1]; emxEnsureCapacity((emxArray__common *)b_X, i, (int32_T)sizeof(real_T), &k_emlrtRTEI); loop_ub = X->size[0] * X->size[1]; emxFree_creal_T(&b_T); for (i = 0; i < loop_ub; i++) { b_X->data[i] = X->data[i].im; } if (c_norm(b_X) <= 10.0 * (real_T)A->size[0] * 2.2204460492503131E-16 * d_norm (X)) { emlrtPushRtStackR2012b(&pb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&pb_emlrtRSI, emlrtRootTLSGlobal); for (loop_ub = 0; loop_ub + 1 <= A->size[0]; loop_ub++) { emlrtPushRtStackR2012b(&qb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&qb_emlrtRSI, emlrtRootTLSGlobal); for (i = 0; i + 1 <= A->size[0]; i++) { s_re = X->data[i + X->size[0] * loop_ub].re; X->data[i + X->size[0] * loop_ub].re = s_re; X->data[i + X->size[0] * loop_ub].im = 0.0; } } } emxFree_real_T(&b_X); emxFree_creal_T(&y); emxFree_creal_T(&T); emlrtHeapReferenceStackLeaveFcnR2012b(emlrtRootTLSGlobal); }