real_T d_norm(const emxArray_creal_T *x) { real_T y; int32_T j; int32_T i; boolean_T exitg1; real_T s; if ((x->size[0] == 1) || (x->size[1] == 1)) { y = 0.0; j = x->size[0] * x->size[1]; for (i = 0; i < j; i++) { y += muDoubleScalarHypot(x->data[i].re, x->data[i].im); } } else { y = 0.0; j = 0; exitg1 = FALSE; while ((exitg1 == FALSE) && (j <= x->size[1] - 1)) { s = 0.0; for (i = 0; i < x->size[0]; i++) { s += muDoubleScalarHypot(x->data[i + x->size[0] * j].re, x->data[i + x->size[0] * j].im); } if (muDoubleScalarIsNaN(s)) { y = rtNaN; exitg1 = TRUE; } else { if (s > y) { y = s; } j++; } } } return y; }
/* 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 */ comm_SDRuTransmitter *SDRuTransmitter_SDRuTransmitter(const emlrtStack *sp, comm_SDRuTransmitter *obj) { comm_SDRuTransmitter *b_obj; comm_SDRuTransmitter *c_obj; real_T varargin_1[10]; int32_T k; int32_T i0; static const char_T cv0[5] = { 'S', 'D', 'R', 'u', '_' }; real_T d0; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; emlrtStack e_st; emlrtStack f_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; b_obj = obj; st.site = &g_emlrtRSI; c_obj = b_obj; c_obj->pSubDevice = TxId; b_st.site = &h_emlrtRSI; c_st.site = &i_emlrtRSI; d_st.site = &j_emlrtRSI; c_st.site = &i_emlrtRSI; c_obj->isInitialized = 0; d_st.site = &k_emlrtRSI; b_st.site = &h_emlrtRSI; c_st.site = &l_emlrtRSI; b_st.site = &h_emlrtRSI; c_st.site = &m_emlrtRSI; b_rand(varargin_1); for (k = 0; k < 10; k++) { varargin_1[k] = 48.0 + muDoubleScalarFloor(varargin_1[k] * 10.0); } b_st.site = &h_emlrtRSI; for (k = 0; k < 10; k++) { i0 = (int32_T)varargin_1[k]; if (!((i0 >= 0) && (i0 <= 255))) { emlrtDynamicBoundsCheckR2012b(i0, 0, 255, &emlrtBCI, &b_st); } } for (k = 0; k < 5; k++) { c_obj->ObjectID[k] = cv0[k]; } for (k = 0; k < 10; k++) { d0 = muDoubleScalarFloor(varargin_1[k]); if (muDoubleScalarIsNaN(d0) || muDoubleScalarIsInf(d0)) { d0 = 0.0; } else { d0 = muDoubleScalarRem(d0, 256.0); } if (d0 < 0.0) { c_obj->ObjectID[k + 5] = (int8_T)-(int8_T)(uint8_T)-d0; } else { c_obj->ObjectID[k + 5] = (int8_T)(uint8_T)d0; } } b_st.site = &h_emlrtRSI; c_st.site = &j_emlrtRSI; d_st.site = &j_emlrtRSI; e_st.site = &n_emlrtRSI; c_obj->CenterFrequency = 1.285E+9; e_st.site = &n_emlrtRSI; c_obj->Gain = 15.0; e_st.site = &n_emlrtRSI; c_obj->InterpolationFactor = 500.0; e_st.site = &n_emlrtRSI; f_st.site = &h_emlrtRSI; checkIPAddressFormat(&f_st); e_st.site = &n_emlrtRSI; c_obj->LocalOscillatorOffset = 0.0; return b_obj; }
/* Function Definitions */ comm_SDRuReceiver *SDRuReceiver_SDRuReceiver(const emlrtStack *sp, comm_SDRuReceiver *obj) { comm_SDRuReceiver *b_obj; comm_SDRuReceiver *c_obj; real_T varargin_1[10]; int32_T k; int32_T i9; static const char_T cv10[5] = { 'S', 'D', 'R', 'u', '_' }; real_T d1; boolean_T flag; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; emlrtStack e_st; emlrtStack f_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; b_obj = obj; st.site = &ab_emlrtRSI; c_obj = b_obj; c_obj->LocalOscillatorOffset = 0.0; c_obj->pSubDevice = RxId; b_st.site = &h_emlrtRSI; c_st.site = &i_emlrtRSI; d_st.site = &j_emlrtRSI; c_st.site = &i_emlrtRSI; c_obj->isInitialized = false; c_obj->isReleased = false; d_st.site = &k_emlrtRSI; b_st.site = &h_emlrtRSI; c_st.site = &l_emlrtRSI; b_st.site = &h_emlrtRSI; c_st.site = &m_emlrtRSI; b_rand(varargin_1); for (k = 0; k < 10; k++) { varargin_1[k] = 48.0 + muDoubleScalarFloor(varargin_1[k] * 10.0); } b_st.site = &h_emlrtRSI; for (k = 0; k < 10; k++) { i9 = (int32_T)varargin_1[k]; emlrtDynamicBoundsCheckFastR2012b(i9, 0, 255, &emlrtBCI, &b_st); } for (k = 0; k < 5; k++) { c_obj->ObjectID[k] = cv10[k]; } for (k = 0; k < 10; k++) { d1 = muDoubleScalarFloor(varargin_1[k]); if (muDoubleScalarIsNaN(d1) || muDoubleScalarIsInf(d1)) { d1 = 0.0; } else { d1 = muDoubleScalarRem(d1, 256.0); } if (d1 < 0.0) { c_obj->ObjectID[k + 5] = (int8_T)-(int8_T)(uint8_T)-d1; } else { c_obj->ObjectID[k + 5] = (int8_T)(uint8_T)d1; } } b_st.site = &h_emlrtRSI; c_st.site = &j_emlrtRSI; d_st.site = &j_emlrtRSI; e_st.site = &o_emlrtRSI; if (c_obj->isInitialized && (!c_obj->isReleased)) { flag = true; } else { flag = false; } if (flag) { c_obj->TunablePropsChanged = true; } e_st.site = &o_emlrtRSI; c_obj->CenterFrequency = 9.05E+8; e_st.site = &o_emlrtRSI; if (c_obj->isInitialized && (!c_obj->isReleased)) { flag = true; } else { flag = false; } if (flag) { c_obj->TunablePropsChanged = true; } e_st.site = &o_emlrtRSI; c_obj->DecimationFactor = 500.0; e_st.site = &o_emlrtRSI; if (c_obj->isInitialized && (!c_obj->isReleased)) { flag = true; } else { flag = false; } if (flag) { c_obj->TunablePropsChanged = true; } e_st.site = &o_emlrtRSI; c_obj->Gain = 35.0; e_st.site = &o_emlrtRSI; f_st.site = &h_emlrtRSI; checkIPAddressFormat(&f_st); return b_obj; }
/* Function Definitions */ void linearODESSEP2X4(const emxArray_real_T *T, const emxArray_real_T *I) { int32_T i; real_T hoistedGlobal[9]; int32_T j; int32_T b_i; real_T normA; real_T y[81]; real_T F[81]; boolean_T exitg2; real_T s; boolean_T exitg1; static const real_T theta[5] = { 0.01495585217958292, 0.253939833006323, 0.95041789961629319, 2.097847961257068, 5.3719203511481517 }; static const int8_T iv2[5] = { 3, 5, 7, 9, 13 }; int32_T eint; real_T b_y[81]; real_T beta1; char_T TRANSB; char_T TRANSA; ptrdiff_t m_t; ptrdiff_t n_t; ptrdiff_t k_t; ptrdiff_t lda_t; ptrdiff_t ldb_t; ptrdiff_t ldc_t; double * alpha1_t; double * Aia0_t; double * Bib0_t; double * beta1_t; double * Cic0_t; emlrtPushRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal); /* global k1 k2 k3 k4 k5 k6 k7 k8 k9 k10 k11 k12 L1 L2 L3 L4 H1 H2 H3 H4 g1 g2 E1 E2 alpha A J Q; */ /* Right */ /* [C1,C2,C3,Q1,Q2,Q3,D1,D2,Z] */ Q[0] = -k2 * A - L2 * J; Q[9] = L2 * J; Q[18] = 0.0; Q[27] = k2 * A; Q[36] = 0.0; Q[45] = 0.0; Q[54] = 0.0; Q[63] = 0.0; Q[72] = 0.0; Q[1] = L1; Q[10] = (-k4 * A - L1) - L4 * J; Q[19] = L4 * J; Q[28] = 0.0; Q[37] = k4 * A; Q[46] = 0.0; Q[55] = 0.0; Q[64] = 0.0; Q[73] = 0.0; Q[2] = 0.0; Q[11] = L3; Q[20] = -k6 * A - L3; Q[29] = 0.0; Q[38] = 0.0; Q[47] = k6 * A; Q[56] = 0.0; Q[65] = 0.0; Q[74] = 0.0; Q[3] = k1; Q[12] = 0.0; Q[21] = 0.0; Q[30] = (-k1 - L2 * J) - H2; Q[39] = L2 * J; Q[48] = 0.0; Q[57] = 0.0; Q[66] = H2; Q[75] = 0.0; Q[4] = 0.0; Q[13] = k3; Q[22] = 0.0; Q[31] = L1; Q[40] = (-k3 - L1) - L4 * J; Q[49] = L4 * J; Q[58] = 0.0; Q[67] = 0.0; Q[76] = 0.0; Q[5] = 0.0; Q[14] = 0.0; Q[23] = k5; Q[32] = 0.0; Q[41] = L3; Q[50] = -k5 - L3; Q[59] = 0.0; Q[68] = 0.0; Q[77] = 0.0; Q[6] = H1; Q[15] = 0.0; Q[24] = 0.0; Q[33] = 0.0; Q[42] = 0.0; Q[51] = 0.0; Q[60] = -k2 * A - H1; Q[69] = k2 * A; Q[78] = 0.0; Q[7] = 0.0; Q[16] = 0.0; Q[25] = 0.0; Q[34] = 0.0; Q[43] = 0.0; Q[52] = 0.0; Q[61] = k1; Q[70] = -k1 - H3; Q[79] = H3; Q[8] = H4; Q[17] = 0.0; Q[26] = 0.0; Q[35] = 0.0; Q[44] = 0.0; Q[53] = 0.0; Q[62] = 0.0; Q[71] = 0.0; Q[80] = -H4; Q_dirty |= 1U; emlrtPopRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal); i = 0; while (i <= T->size[0] - 1) { emlrtPushRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal); memcpy(&hoistedGlobal[0], &p0[0], 9U * sizeof(real_T)); j = T->size[0]; b_i = (int32_T)(1.0 + (real_T)i); emlrtDynamicBoundsCheckFastR2012b(b_i, 1, j, &t_emlrtBCI, emlrtRootTLSGlobal); normA = T->data[i]; for (j = 0; j < 81; j++) { y[j] = Q[j] * normA; } normA = 0.0; j = 0; exitg2 = FALSE; while ((exitg2 == FALSE) && (j < 9)) { s = 0.0; for (b_i = 0; b_i < 9; b_i++) { s += muDoubleScalarAbs(y[b_i + 9 * j]); } if (muDoubleScalarIsNaN(s)) { normA = rtNaN; exitg2 = TRUE; } else { if (s > normA) { normA = s; } j++; } } if (normA <= 5.3719203511481517) { b_i = 0; exitg1 = FALSE; while ((exitg1 == FALSE) && (b_i < 5)) { if (normA <= theta[b_i]) { emlrtPushRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal); PadeApproximantOfDegree(y, iv2[b_i], F); emlrtPopRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal); exitg1 = TRUE; } else { b_i++; } } } else { normA /= 5.3719203511481517; if ((!muDoubleScalarIsInf(normA)) && (!muDoubleScalarIsNaN(normA))) { normA = frexp(normA, &eint); j = eint; } else { j = 0; } s = j; if (normA == 0.5) { s = (real_T)j - 1.0; } normA = muDoubleScalarPower(2.0, s); emlrtPushRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal); for (j = 0; j < 81; j++) { b_y[j] = y[j] / normA; } PadeApproximantOfDegree(b_y, 13.0, F); emlrtPopRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal); emlrtForLoopVectorCheckR2012b(1.0, 1.0, s, mxDOUBLE_CLASS, (int32_T)s, &g_emlrtRTEI, emlrtRootTLSGlobal); for (j = 0; j < (int32_T)s; j++) { emlrtPushRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&cb_emlrtRSI, emlrtRootTLSGlobal); memcpy(&y[0], &F[0], 81U * sizeof(real_T)); emlrtPushRtStackR2012b(&db_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal); normA = 1.0; beta1 = 0.0; TRANSB = 'N'; TRANSA = 'N'; memset(&F[0], 0, 81U * sizeof(real_T)); emlrtPushRtStackR2012b(&fb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&rb_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); m_t = (ptrdiff_t)(9); emlrtPopRtStackR2012b(&rb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&fb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&gb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&rb_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); n_t = (ptrdiff_t)(9); emlrtPopRtStackR2012b(&rb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&gb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&rb_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); k_t = (ptrdiff_t)(9); emlrtPopRtStackR2012b(&rb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ib_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&rb_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); lda_t = (ptrdiff_t)(9); emlrtPopRtStackR2012b(&rb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&ib_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&jb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&rb_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); ldb_t = (ptrdiff_t)(9); emlrtPopRtStackR2012b(&rb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&jb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&kb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&rb_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); ldc_t = (ptrdiff_t)(9); emlrtPopRtStackR2012b(&rb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&kb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&lb_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); alpha1_t = (double *)(&normA); emlrtPopRtStackR2012b(&lb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&mb_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); Aia0_t = (double *)(&y[0]); emlrtPopRtStackR2012b(&mb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&nb_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); Bib0_t = (double *)(&y[0]); emlrtPopRtStackR2012b(&nb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); beta1_t = (double *)(&beta1); emlrtPopRtStackR2012b(&ob_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&pb_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); Cic0_t = (double *)(&F[0]); emlrtPopRtStackR2012b(&pb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&qb_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); dgemm(&TRANSA, &TRANSB, &m_t, &n_t, &k_t, alpha1_t, Aia0_t, &lda_t, Bib0_t, &ldb_t, beta1_t, Cic0_t, &ldc_t); emlrtPopRtStackR2012b(&qb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&db_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&cb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal); } } for (j = 0; j < 9; j++) { p0[j] = 0.0; for (b_i = 0; b_i < 9; b_i++) { p0[j] += hoistedGlobal[b_i] * F[b_i + 9 * j]; } } p0_dirty |= 1U; emlrtPopRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal); j = I->size[0]; b_i = 1 + i; normA = Acell * 1.0E+12 * (g1 * p0[3] * (V - E1) + g2 * (p0[4] + p0[5]) * (V - E2)) - I->data[emlrtDynamicBoundsCheckFastR2012b(b_i, 1, j, &u_emlrtBCI, emlrtRootTLSGlobal) - 1]; normA = muDoubleScalarAbs(normA); err += normA * normA; err_dirty |= 1U; i++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, emlrtRootTLSGlobal); } }
/* Function Definitions */ void linearODESSEP2X4(const emxArray_real_T *T, const emxArray_real_T *I) { int32_T i; real_T hoistedGlobal[17]; int32_T j; int32_T b_i; real_T normA; real_T y[289]; real_T F[289]; boolean_T exitg2; real_T s; boolean_T exitg1; static const real_T theta[5] = { 0.01495585217958292, 0.253939833006323, 0.95041789961629319, 2.097847961257068, 5.3719203511481517 }; static const int8_T iv2[5] = { 3, 5, 7, 9, 13 }; int32_T eint; real_T b_y[289]; real_T beta1; char_T TRANSB; char_T TRANSA; ptrdiff_t m_t; ptrdiff_t n_t; ptrdiff_t k_t; ptrdiff_t lda_t; ptrdiff_t ldb_t; ptrdiff_t ldc_t; double * alpha1_t; double * Aia0_t; double * Bib0_t; double * beta1_t; double * Cic0_t; emlrtPushRtStackR2012b(&db_emlrtRSI, emlrtRootTLSGlobal); Q[0] = -k2 * A - L2 * J; Q[17] = k2 * A; Q[34] = L2 * J; Q[51] = 0.0; Q[68] = 0.0; Q[85] = 0.0; Q[102] = 0.0; Q[119] = 0.0; Q[136] = 0.0; Q[153] = 0.0; Q[170] = 0.0; Q[187] = 0.0; Q[204] = 0.0; Q[221] = 0.0; Q[238] = 0.0; Q[255] = 0.0; Q[272] = 0.0; Q[1] = k1; Q[18] = ((-k1 - k4 * A) - H2) - L2 * J; Q[35] = 0.0; Q[52] = L2 * J; Q[69] = 0.0; Q[86] = 0.0; Q[103] = k4 * A; Q[120] = 0.0; Q[137] = 0.0; Q[154] = 0.0; Q[171] = 0.0; Q[188] = 0.0; Q[205] = 0.0; Q[222] = H2; Q[239] = 0.0; Q[256] = 0.0; Q[273] = 0.0; Q[2] = L1; Q[19] = 0.0; Q[36] = (-k8 * A - L1) - L4 * J; Q[53] = k8 * A; Q[70] = L4 * J; Q[87] = 0.0; Q[104] = 0.0; Q[121] = 0.0; Q[138] = 0.0; Q[155] = 0.0; Q[172] = 0.0; Q[189] = 0.0; Q[206] = 0.0; Q[223] = 0.0; Q[240] = 0.0; Q[257] = 0.0; Q[274] = 0.0; Q[3] = 0.0; Q[20] = L1; Q[37] = k7; Q[54] = ((-k7 - k10 * A) - L1) - L4 * J; Q[71] = 0.0; Q[88] = L4 * J; Q[105] = 0.0; Q[122] = 0.0; Q[139] = k10 * A; Q[156] = 0.0; Q[173] = 0.0; Q[190] = 0.0; Q[207] = 0.0; Q[224] = 0.0; Q[241] = 0.0; Q[258] = 0.0; Q[275] = 0.0; Q[4] = 0.0; Q[21] = 0.0; Q[38] = L3; Q[55] = 0.0; Q[72] = -k8 * alpha * A - L3; Q[89] = k8 * alpha * A; Q[106] = 0.0; Q[123] = 0.0; Q[140] = 0.0; Q[157] = 0.0; Q[174] = 0.0; Q[191] = 0.0; Q[208] = 0.0; Q[225] = 0.0; Q[242] = 0.0; Q[259] = 0.0; Q[276] = 0.0; Q[5] = 0.0; Q[22] = 0.0; Q[39] = 0.0; Q[56] = L3; Q[73] = k7; Q[90] = (-k7 - k10 * alpha * A) - L3; Q[107] = 0.0; Q[124] = 0.0; Q[141] = 0.0; Q[158] = 0.0; Q[175] = k10 * alpha * A; Q[192] = 0.0; Q[209] = 0.0; Q[226] = 0.0; Q[243] = 0.0; Q[260] = 0.0; Q[277] = 0.0; Q[6] = 0.0; Q[23] = k3; Q[40] = 0.0; Q[57] = 0.0; Q[74] = 0.0; Q[91] = 0.0; Q[108] = ((-k3 - k6 * A) - H2) - L2 * J; Q[125] = k6 * A; Q[142] = L2 * J; Q[159] = 0.0; Q[176] = 0.0; Q[193] = 0.0; Q[210] = 0.0; Q[227] = 0.0; Q[244] = H2; Q[261] = 0.0; Q[278] = 0.0; Q[7] = 0.0; Q[24] = 0.0; Q[41] = 0.0; Q[58] = 0.0; Q[75] = 0.0; Q[92] = 0.0; Q[109] = k5; Q[126] = (-k5 - H2) - L2 * J; Q[143] = 0.0; Q[160] = L2 * J; Q[177] = 0.0; Q[194] = 0.0; Q[211] = 0.0; Q[228] = 0.0; Q[245] = 0.0; Q[262] = H2; Q[279] = 0.0; Q[8] = 0.0; Q[25] = 0.0; Q[42] = 0.0; Q[59] = k9; Q[76] = 0.0; Q[93] = 0.0; Q[110] = L1; Q[127] = 0.0; Q[144] = ((-k9 - k12 * A) - L1) - L4 * J; Q[161] = k12 * A; Q[178] = L4 * J; Q[195] = 0.0; Q[212] = 0.0; Q[229] = 0.0; Q[246] = 0.0; Q[263] = 0.0; Q[280] = 0.0; Q[9] = 0.0; Q[26] = 0.0; Q[43] = 0.0; Q[60] = 0.0; Q[77] = 0.0; Q[94] = 0.0; Q[111] = 0.0; Q[128] = L1; Q[145] = k11; Q[162] = (-k11 - L1) - L4 * J; Q[179] = 0.0; Q[196] = L4 * J; Q[213] = 0.0; Q[230] = 0.0; Q[247] = 0.0; Q[264] = 0.0; Q[281] = 0.0; Q[10] = 0.0; Q[27] = 0.0; Q[44] = 0.0; Q[61] = 0.0; Q[78] = 0.0; Q[95] = k9; Q[112] = 0.0; Q[129] = 0.0; Q[146] = L3; Q[163] = 0.0; Q[180] = (-k9 - k12 * alpha * A) - L3; Q[197] = k12 * alpha * A; Q[214] = 0.0; Q[231] = 0.0; Q[248] = 0.0; Q[265] = 0.0; Q[282] = 0.0; Q[11] = 0.0; Q[28] = 0.0; Q[45] = 0.0; Q[62] = 0.0; Q[79] = 0.0; Q[96] = 0.0; Q[113] = 0.0; Q[130] = 0.0; Q[147] = 0.0; Q[164] = L3; Q[181] = k11; Q[198] = -k11 - L3; Q[215] = 0.0; Q[232] = 0.0; Q[249] = 0.0; Q[266] = 0.0; Q[283] = 0.0; Q[12] = H1; Q[29] = 0.0; Q[46] = 0.0; Q[63] = 0.0; Q[80] = 0.0; Q[97] = 0.0; Q[114] = 0.0; Q[131] = 0.0; Q[148] = 0.0; Q[165] = 0.0; Q[182] = 0.0; Q[199] = 0.0; Q[216] = -k2 * A - H1; Q[233] = k2 * A; Q[250] = 0.0; Q[267] = 0.0; Q[284] = 0.0; Q[13] = 0.0; Q[30] = 0.0; Q[47] = 0.0; Q[64] = 0.0; Q[81] = 0.0; Q[98] = 0.0; Q[115] = 0.0; Q[132] = 0.0; Q[149] = 0.0; Q[166] = 0.0; Q[183] = 0.0; Q[200] = 0.0; Q[217] = k1; Q[234] = -k1 - k4 * A; Q[251] = k4 * A; Q[268] = 0.0; Q[285] = 0.0; Q[14] = 0.0; Q[31] = 0.0; Q[48] = 0.0; Q[65] = 0.0; Q[82] = 0.0; Q[99] = 0.0; Q[116] = 0.0; Q[133] = 0.0; Q[150] = 0.0; Q[167] = 0.0; Q[184] = 0.0; Q[201] = 0.0; Q[218] = 0.0; Q[235] = k3; Q[252] = -k3 - k6 * A; Q[269] = k6 * A; Q[286] = 0.0; Q[15] = 0.0; Q[32] = 0.0; Q[49] = 0.0; Q[66] = 0.0; Q[83] = 0.0; Q[100] = 0.0; Q[117] = 0.0; Q[134] = 0.0; Q[151] = 0.0; Q[168] = 0.0; Q[185] = 0.0; Q[202] = 0.0; Q[219] = 0.0; Q[236] = 0.0; Q[253] = k5; Q[270] = -k5 - H3; Q[287] = H3; Q[16] = H4; Q[33] = 0.0; Q[50] = 0.0; Q[67] = 0.0; Q[84] = 0.0; Q[101] = 0.0; Q[118] = 0.0; Q[135] = 0.0; Q[152] = 0.0; Q[169] = 0.0; Q[186] = 0.0; Q[203] = 0.0; Q[220] = 0.0; Q[237] = 0.0; Q[254] = 0.0; Q[271] = 0.0; Q[288] = -H4; Q_dirty |= 1U; emlrtPopRtStackR2012b(&db_emlrtRSI, emlrtRootTLSGlobal); i = 0; while (i <= T->size[0] - 1) { emlrtPushRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal); memcpy(&hoistedGlobal[0], &p0[0], 17U * sizeof(real_T)); j = T->size[0]; b_i = (int32_T)(1.0 + (real_T)i); emlrtDynamicBoundsCheckFastR2012b(b_i, 1, j, &bd_emlrtBCI, emlrtRootTLSGlobal); normA = T->data[i]; for (j = 0; j < 289; j++) { y[j] = Q[j] * normA; } normA = 0.0; j = 0; exitg2 = FALSE; while ((exitg2 == FALSE) && (j < 17)) { s = 0.0; for (b_i = 0; b_i < 17; b_i++) { s += muDoubleScalarAbs(y[b_i + 17 * j]); } if (muDoubleScalarIsNaN(s)) { normA = rtNaN; exitg2 = TRUE; } else { if (s > normA) { normA = s; } j++; } } if (normA <= 5.3719203511481517) { b_i = 0; exitg1 = FALSE; while ((exitg1 == FALSE) && (b_i < 5)) { if (normA <= theta[b_i]) { emlrtPushRtStackR2012b(&fb_emlrtRSI, emlrtRootTLSGlobal); PadeApproximantOfDegree(y, iv2[b_i], F); emlrtPopRtStackR2012b(&fb_emlrtRSI, emlrtRootTLSGlobal); exitg1 = TRUE; } else { b_i++; } } } else { normA /= 5.3719203511481517; if ((!muDoubleScalarIsInf(normA)) && (!muDoubleScalarIsNaN(normA))) { normA = frexp(normA, &eint); j = eint; } else { j = 0; } s = j; if (normA == 0.5) { s = (real_T)j - 1.0; } normA = muDoubleScalarPower(2.0, s); emlrtPushRtStackR2012b(&gb_emlrtRSI, emlrtRootTLSGlobal); for (j = 0; j < 289; j++) { b_y[j] = y[j] / normA; } PadeApproximantOfDegree(b_y, 13.0, F); emlrtPopRtStackR2012b(&gb_emlrtRSI, emlrtRootTLSGlobal); emlrtForLoopVectorCheckR2012b(1.0, 1.0, s, mxDOUBLE_CLASS, (int32_T)s, &l_emlrtRTEI, emlrtRootTLSGlobal); for (j = 0; j < (int32_T)s; j++) { emlrtPushRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&tb_emlrtRSI, emlrtRootTLSGlobal); memcpy(&y[0], &F[0], 289U * sizeof(real_T)); emlrtPushRtStackR2012b(&ub_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&vb_emlrtRSI, emlrtRootTLSGlobal); normA = 1.0; beta1 = 0.0; TRANSB = 'N'; TRANSA = 'N'; memset(&F[0], 0, 289U * sizeof(real_T)); emlrtPushRtStackR2012b(&wb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&jc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); m_t = (ptrdiff_t)(17); emlrtPopRtStackR2012b(&jc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&wb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&xb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&jc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); n_t = (ptrdiff_t)(17); emlrtPopRtStackR2012b(&jc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&xb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&yb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&jc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); k_t = (ptrdiff_t)(17); emlrtPopRtStackR2012b(&jc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&yb_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ac_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&jc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); lda_t = (ptrdiff_t)(17); emlrtPopRtStackR2012b(&jc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&ac_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&bc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&jc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); ldb_t = (ptrdiff_t)(17); emlrtPopRtStackR2012b(&jc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&bc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&cc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&jc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); ldc_t = (ptrdiff_t)(17); emlrtPopRtStackR2012b(&jc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&cc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&dc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); alpha1_t = (double *)(&normA); emlrtPopRtStackR2012b(&dc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ec_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); Aia0_t = (double *)(&y[0]); emlrtPopRtStackR2012b(&ec_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&fc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); Bib0_t = (double *)(&y[0]); emlrtPopRtStackR2012b(&fc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&gc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); beta1_t = (double *)(&beta1); emlrtPopRtStackR2012b(&gc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hc_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); Cic0_t = (double *)(&F[0]); emlrtPopRtStackR2012b(&hc_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ic_emlrtRSI, emlrtRootTLSGlobal); emlrt_checkEscapedGlobals(); dgemm(&TRANSA, &TRANSB, &m_t, &n_t, &k_t, alpha1_t, Aia0_t, &lda_t, Bib0_t, &ldb_t, beta1_t, Cic0_t, &ldc_t); emlrtPopRtStackR2012b(&ic_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&vb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&ub_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&tb_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&hb_emlrtRSI, emlrtRootTLSGlobal); } } for (j = 0; j < 17; j++) { p0[j] = 0.0; for (b_i = 0; b_i < 17; b_i++) { p0[j] += hoistedGlobal[b_i] * F[b_i + 17 * j]; } } p0_dirty |= 1U; emlrtPopRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal); j = I->size[0]; b_i = 1 + i; normA = Acell * 1.0E+12 * (g1 * (p0[6] + p0[7]) * (V - E1) + g2 * (((p0[8] + p0[9]) + p0[10]) + p0[11]) * (V - E2)) - I-> data[emlrtDynamicBoundsCheckFastR2012b(b_i, 1, j, &cd_emlrtBCI, emlrtRootTLSGlobal) - 1]; normA = muDoubleScalarAbs(normA); err += normA * normA; err_dirty |= 1U; i++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, emlrtRootTLSGlobal); } }
real_T b_scalar_erf(real_T x) { real_T y; real_T absx; real_T s; real_T S; real_T R; int32_T eint; /* ========================== COPYRIGHT NOTICE ============================ */ /* The algorithms for calculating ERF(X) and ERFC(X) are derived */ /* from FDLIBM, which has the following notice: */ /* */ /* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. */ /* */ /* Developed at SunSoft, a Sun Microsystems, Inc. business. */ /* Permission to use, copy, modify, and distribute this */ /* software is freely granted, provided that this notice */ /* is preserved. */ /* ============================= END ================================ */ absx = muDoubleScalarAbs(x); if (muDoubleScalarIsNaN(x)) { y = x; } else if (muDoubleScalarIsInf(x)) { if (x < 0.0) { y = -1.0; } else { y = 1.0; } } else if (absx < 0.84375) { if (absx < 3.7252902984619141E-9) { if (absx < 2.8480945388892178E-306) { y = 0.125 * (8.0 * x + 1.0270333367641007 * x); } else { y = x + 0.12837916709551259 * x; } } else { s = x * x; y = x + x * ((0.12837916709551256 + s * (-0.3250421072470015 + s * (-0.02848174957559851 + s * (-0.0057702702964894416 + s * -2.3763016656650163E-5)))) / (1.0 + s * (0.39791722395915535 + s * (0.0650222499887673 + s * (0.0050813062818757656 + s * (0.00013249473800432164 + s * -3.9602282787753681E-6)))))); } } else if (absx < 1.25) { S = -0.0023621185607526594 + (absx - 1.0) * (0.41485611868374833 + (absx - 1.0) * (-0.37220787603570132 + (absx - 1.0) * (0.31834661990116175 + (absx - 1.0) * (-0.11089469428239668 + (absx - 1.0) * (0.035478304325618236 + (absx - 1.0) * -0.0021663755948687908))))); s = 1.0 + (absx - 1.0) * (0.10642088040084423 + (absx - 1.0) * (0.540397917702171 + (absx - 1.0) * (0.071828654414196266 + (absx - 1.0) * (0.12617121980876164 + (absx - 1.0) * (0.013637083912029051 + (absx - 1.0) * 0.011984499846799107))))); if (x >= 0.0) { y = 0.84506291151046753 + S / s; } else { y = -0.84506291151046753 - S / s; } } else if (absx > 6.0) { if (x < 0.0) { y = -1.0; } else { y = 1.0; } } else { s = 1.0 / (absx * absx); if (absx < 2.8571434020996094) { R = -0.0098649440348471482 + s * (-0.69385857270718176 + s * (-10.558626225323291 + s * (-62.375332450326006 + s * (-162.39666946257347 + s * (-184.60509290671104 + s * (-81.2874355063066 + s * -9.8143293441691455)))))); S = 1.0 + s * (19.651271667439257 + s * (137.65775414351904 + s * (434.56587747522923 + s * (645.38727173326788 + s * (429.00814002756783 + s * (108.63500554177944 + s * (6.5702497703192817 + s * -0.0604244152148581))))))); } else { R = -0.0098649429247001 + s * (-0.799283237680523 + s * (-17.757954917754752 + s * (-160.63638485582192 + s * (-637.56644336838963 + s * (-1025.0951316110772 + s * -483.5191916086514))))); S = 1.0 + s * (30.338060743482458 + s * (325.79251299657392 + s * (1536.729586084437 + s * (3199.8582195085955 + s * (2553.0504064331644 + s * (474.52854120695537 + s * -22.440952446585818)))))); } if ((!muDoubleScalarIsInf(absx)) && (!muDoubleScalarIsNaN(absx))) { s = frexp(absx, &eint); } else { s = absx; eint = 0; } s = muDoubleScalarFloor(s * 2.097152E+6) / 2.097152E+6 * muDoubleScalarPower (2.0, eint); y = muDoubleScalarExp(-s * s - 0.5625) * muDoubleScalarExp((s - absx) * (s + absx) + R / S) / absx; if (x < 0.0) { y--; } else { y = 1.0 - y; } } return y; }
/* Function Definitions */ void do_vectors(const emlrtStack *sp, const real_T a_data[1224], const int32_T a_size[1], const real_T b[8], real_T c_data[8], int32_T c_size[1], int32_T ia_data[8], int32_T ia_size[1], int32_T ib_data[8], int32_T ib_size[1]) { int32_T ncmax; boolean_T y; int32_T ialast; boolean_T exitg4; boolean_T guard9 = FALSE; boolean_T p; boolean_T exitg3; boolean_T guard8 = FALSE; int32_T nc; int32_T iafirst; int32_T ibfirst; int32_T iblast; int32_T b_ialast; real_T ak; boolean_T exitg2; real_T absxk; int32_T exponent; boolean_T guard6 = FALSE; boolean_T guard7 = FALSE; int32_T b_iblast; real_T bk; boolean_T exitg1; int32_T b_exponent; boolean_T guard4 = FALSE; boolean_T guard5 = FALSE; int32_T c_exponent; boolean_T guard2 = FALSE; boolean_T guard3 = FALSE; boolean_T guard1 = FALSE; const mxArray *b_y; const mxArray *m20; int32_T b_ia_data[8]; const mxArray *c_y; const mxArray *d_y; real_T b_c_data[8]; emlrtStack st; st.prev = sp; st.tls = sp->tls; st.site = &fp_emlrtRSI; ncmax = muIntScalarMin_sint32(a_size[0], 8); c_size[0] = (int8_T)ncmax; ia_size[0] = ncmax; ib_size[0] = ncmax; st.site = &gp_emlrtRSI; y = TRUE; if (a_size[0] == 0) { } else { ialast = 1; exitg4 = FALSE; while ((exitg4 == FALSE) && (ialast <= a_size[0] - 1)) { guard9 = FALSE; if (a_data[ialast - 1] <= a_data[ialast]) { guard9 = TRUE; } else if (muDoubleScalarIsNaN(a_data[ialast])) { guard9 = TRUE; } else { p = FALSE; } if (guard9 == TRUE) { p = TRUE; } if (!p) { y = FALSE; exitg4 = TRUE; } else { ialast++; } } } if (!y) { st.site = &hp_emlrtRSI; eml_error(&st); } st.site = &ip_emlrtRSI; y = TRUE; ialast = 1; exitg3 = FALSE; while ((exitg3 == FALSE) && (ialast < 8)) { guard8 = FALSE; if (b[ialast - 1] <= b[ialast]) { guard8 = TRUE; } else if (muDoubleScalarIsNaN(b[ialast])) { guard8 = TRUE; } else { p = FALSE; } if (guard8 == TRUE) { p = TRUE; } if (!p) { y = FALSE; exitg3 = TRUE; } else { ialast++; } } if (!y) { st.site = &jp_emlrtRSI; b_eml_error(&st); } nc = 0; iafirst = 0; ialast = 0; ibfirst = 0; iblast = 0; while ((ialast + 1 <= a_size[0]) && (iblast + 1 <= 8)) { st.site = &kp_emlrtRSI; b_ialast = ialast + 1; ak = a_data[ialast]; exitg2 = FALSE; while ((exitg2 == FALSE) && (b_ialast < a_size[0])) { absxk = muDoubleScalarAbs(a_data[ialast] / 2.0); if ((!muDoubleScalarIsInf(absxk)) && (!muDoubleScalarIsNaN(absxk))) { if (absxk <= 2.2250738585072014E-308) { absxk = 4.94065645841247E-324; } else { frexp(absxk, &exponent); absxk = ldexp(1.0, exponent - 53); } } else { absxk = rtNaN; } guard6 = FALSE; guard7 = FALSE; if (muDoubleScalarAbs(a_data[ialast] - a_data[b_ialast]) < absxk) { guard7 = TRUE; } else if (muDoubleScalarIsInf(a_data[b_ialast])) { if (muDoubleScalarIsInf(a_data[ialast]) && ((a_data[b_ialast] > 0.0) == (a_data[ialast] > 0.0))) { guard7 = TRUE; } else { guard6 = TRUE; } } else { guard6 = TRUE; } if (guard7 == TRUE) { p = TRUE; } if (guard6 == TRUE) { p = FALSE; } if (p) { b_ialast++; } else { exitg2 = TRUE; } } ialast = b_ialast - 1; st.site = &lp_emlrtRSI; b_iblast = iblast + 1; bk = b[iblast]; exitg1 = FALSE; while ((exitg1 == FALSE) && (b_iblast < 8)) { absxk = muDoubleScalarAbs(b[iblast] / 2.0); if ((!muDoubleScalarIsInf(absxk)) && (!muDoubleScalarIsNaN(absxk))) { if (absxk <= 2.2250738585072014E-308) { absxk = 4.94065645841247E-324; } else { frexp(absxk, &b_exponent); absxk = ldexp(1.0, b_exponent - 53); } } else { absxk = rtNaN; } guard4 = FALSE; guard5 = FALSE; if (muDoubleScalarAbs(b[iblast] - b[b_iblast]) < absxk) { guard5 = TRUE; } else if (muDoubleScalarIsInf(b[b_iblast])) { if (muDoubleScalarIsInf(b[iblast]) && ((b[b_iblast] > 0.0) == (b[iblast] > 0.0))) { guard5 = TRUE; } else { guard4 = TRUE; } } else { guard4 = TRUE; } if (guard5 == TRUE) { p = TRUE; } if (guard4 == TRUE) { p = FALSE; } if (p) { b_iblast++; } else { exitg1 = TRUE; } } iblast = b_iblast - 1; st.site = &mp_emlrtRSI; absxk = muDoubleScalarAbs(bk / 2.0); if ((!muDoubleScalarIsInf(absxk)) && (!muDoubleScalarIsNaN(absxk))) { if (absxk <= 2.2250738585072014E-308) { absxk = 4.94065645841247E-324; } else { frexp(absxk, &c_exponent); absxk = ldexp(1.0, c_exponent - 53); } } else { absxk = rtNaN; } guard2 = FALSE; guard3 = FALSE; if (muDoubleScalarAbs(bk - ak) < absxk) { guard3 = TRUE; } else if (muDoubleScalarIsInf(ak)) { if (muDoubleScalarIsInf(bk) && ((ak > 0.0) == (bk > 0.0))) { guard3 = TRUE; } else { guard2 = TRUE; } } else { guard2 = TRUE; } if (guard3 == TRUE) { p = TRUE; } if (guard2 == TRUE) { p = FALSE; } if (p) { st.site = &np_emlrtRSI; nc++; c_data[nc - 1] = ak; ia_data[nc - 1] = iafirst + 1; ib_data[nc - 1] = ibfirst + 1; st.site = &op_emlrtRSI; ialast = b_ialast; iafirst = b_ialast; st.site = &pp_emlrtRSI; iblast = b_iblast; ibfirst = b_iblast; } else { st.site = &qp_emlrtRSI; guard1 = FALSE; if (ak < bk) { guard1 = TRUE; } else if (muDoubleScalarIsNaN(bk)) { guard1 = TRUE; } else { p = FALSE; } if (guard1 == TRUE) { p = TRUE; } if (p) { st.site = &rp_emlrtRSI; ialast = b_ialast; iafirst = b_ialast; } else { st.site = &sp_emlrtRSI; iblast = b_iblast; ibfirst = b_iblast; } } } if (ncmax > 0) { if (nc <= ncmax) { } else { b_y = NULL; m20 = mxCreateString("Assertion failed."); emlrtAssign(&b_y, m20); st.site = &yt_emlrtRSI; b_error(&st, b_y, &y_emlrtMCI); } if (1 > nc) { ialast = 0; } else { ialast = nc; } for (iafirst = 0; iafirst < ialast; iafirst++) { b_ia_data[iafirst] = ia_data[iafirst]; } ia_size[0] = ialast; for (iafirst = 0; iafirst < ialast; iafirst++) { ia_data[iafirst] = b_ia_data[iafirst]; } } if (ncmax > 0) { if (nc <= ncmax) { } else { c_y = NULL; m20 = mxCreateString("Assertion failed."); emlrtAssign(&c_y, m20); st.site = &xt_emlrtRSI; b_error(&st, c_y, &ab_emlrtMCI); } if (1 > nc) { ialast = 0; } else { ialast = nc; } for (iafirst = 0; iafirst < ialast; iafirst++) { b_ia_data[iafirst] = ib_data[iafirst]; } ib_size[0] = ialast; for (iafirst = 0; iafirst < ialast; iafirst++) { ib_data[iafirst] = b_ia_data[iafirst]; } } if (ncmax > 0) { if (nc <= ncmax) { } else { d_y = NULL; m20 = mxCreateString("Assertion failed."); emlrtAssign(&d_y, m20); st.site = &wt_emlrtRSI; b_error(&st, d_y, &bb_emlrtMCI); } if (1 > nc) { ialast = 0; } else { ialast = nc; } for (iafirst = 0; iafirst < ialast; iafirst++) { b_c_data[iafirst] = c_data[iafirst]; } c_size[0] = ialast; for (iafirst = 0; iafirst < ialast; iafirst++) { c_data[iafirst] = b_c_data[iafirst]; } } }
/* Function Definitions */ void NewtonRaphsonFR2dof(const emlrtStack *sp, real_T tol, real_T m1, real_T m2, real_T c1, real_T c2, real_T k1, real_T k2, real_T beta, real_T fc11, real_T fc12, real_T fc21, real_T fc22, real_T fMin, real_T fMax, real_T numAmplSamples, real_T numPulsSamples, real_T aMax, real_T maxIter, emxArray_real_T *Amplitude1FR, emxArray_real_T *Amplitude2FR, emxArray_real_T * A1amplitudeFR, emxArray_real_T *A2amplitudeFR, emxArray_real_T *B1amplitudeFR, emxArray_real_T *B2amplitudeFR, emxArray_real_T *W) { real_T kd; real_T d; real_T b; int32_T n; real_T anew; real_T apnd; boolean_T n_too_large; real_T ndbl; real_T cdiff; real_T absa; real_T absb; int32_T k; int32_T nm1d2; real_T b_kd; int32_T i; int32_T j; real_T b_n; real_T amplitude1[2]; real_T amplitude2[2]; real_T F[4]; int32_T exitg1; real_T scale; real_T absxk; real_T t; real_T delta[4]; real_T dv0[16]; real_T dv1[16]; int32_T b_j; int32_T c_n; int32_T c_j; int32_T d_n; int32_T d_j; int32_T e_n; int32_T e_j; int32_T f_n; int32_T f_j; int32_T g_n; int32_T g_j; int32_T h_n; emlrtStack st; emlrtStack b_st; emlrtStack c_st; st.prev = sp; st.tls = sp->tls; st.site = &emlrtRSI; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; kd = fMin * 2.0 * 3.1415926535897931; d = (fMax - fMin) / (numPulsSamples - 1.0) * 2.0 * 3.1415926535897931; b = fMax * 2.0 * 3.1415926535897931; b_st.site = &e_emlrtRSI; if (muDoubleScalarIsNaN(kd) || muDoubleScalarIsNaN(d) || muDoubleScalarIsNaN(b)) { n = 0; anew = rtNaN; apnd = b; n_too_large = false; } else if ((d == 0.0) || ((kd < b) && (d < 0.0)) || ((b < kd) && (d > 0.0))) { n = -1; anew = kd; apnd = b; n_too_large = false; } else if (muDoubleScalarIsInf(kd) || muDoubleScalarIsInf(b)) { n = 0; anew = rtNaN; apnd = b; if (muDoubleScalarIsInf(d) || (kd == b)) { n_too_large = true; } else { n_too_large = false; } n_too_large = !n_too_large; } else if (muDoubleScalarIsInf(d)) { n = 0; anew = kd; apnd = b; n_too_large = false; } else { anew = kd; ndbl = muDoubleScalarFloor((b - kd) / d + 0.5); apnd = kd + ndbl * d; if (d > 0.0) { cdiff = apnd - b; } else { cdiff = b - apnd; } absa = muDoubleScalarAbs(kd); absb = muDoubleScalarAbs(b); if (muDoubleScalarAbs(cdiff) < 4.4408920985006262E-16 * muDoubleScalarMax (absa, absb)) { ndbl++; apnd = b; } else if (cdiff > 0.0) { apnd = kd + (ndbl - 1.0) * d; } else { ndbl++; } n_too_large = (2.147483647E+9 < ndbl); if (ndbl >= 0.0) { n = (int32_T)ndbl - 1; } else { n = -1; } } c_st.site = &f_emlrtRSI; if (!n_too_large) { } else { emlrtErrorWithMessageIdR2012b(&c_st, &c_emlrtRTEI, "Coder:MATLAB:pmaxsize", 0); } k = W->size[0] * W->size[1]; W->size[0] = 1; W->size[1] = n + 1; emxEnsureCapacity(&b_st, (emxArray__common *)W, k, (int32_T)sizeof(real_T), &emlrtRTEI); if (n + 1 > 0) { W->data[0] = anew; if (n + 1 > 1) { W->data[n] = apnd; k = n + (n < 0); if (k >= 0) { nm1d2 = (int32_T)((uint32_T)k >> 1); } else {
void b_mpower(const emlrtStack *sp, const real_T a[36], real_T c[36]) { real_T x[36]; int32_T jBcol; int32_T ipiv[6]; int8_T p[6]; int32_T k; int32_T j; int32_T i; int32_T kAcol; real_T n1x; real_T n1xinv; real_T rc; static const char_T rfmt[6] = { '%', '1', '4', '.', '6', 'e' }; char_T u[6]; const mxArray *y; static const int32_T iv4[2] = { 1, 6 }; const mxArray *m0; const mxArray *b_y; char_T cv0[14]; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; emlrtStack e_st; emlrtStack f_st; st.prev = sp; st.tls = sp->tls; st.site = &l_emlrtRSI; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; d_st.prev = &c_st; d_st.tls = c_st.tls; e_st.prev = &d_st; e_st.tls = d_st.tls; f_st.prev = &e_st; f_st.tls = e_st.tls; b_st.site = &m_emlrtRSI; c_st.site = &n_emlrtRSI; c_st.site = &o_emlrtRSI; d_st.site = &p_emlrtRSI; for (jBcol = 0; jBcol < 36; jBcol++) { c[jBcol] = 0.0; x[jBcol] = a[jBcol]; } e_st.site = &r_emlrtRSI; xgetrf(&e_st, x, ipiv); for (jBcol = 0; jBcol < 6; jBcol++) { p[jBcol] = (int8_T)(1 + jBcol); } for (k = 0; k < 5; k++) { if (ipiv[k] > 1 + k) { jBcol = p[ipiv[k] - 1]; p[ipiv[k] - 1] = p[k]; p[k] = (int8_T)jBcol; } } for (k = 0; k < 6; k++) { jBcol = p[k] - 1; c[k + 6 * (p[k] - 1)] = 1.0; e_st.site = &s_emlrtRSI; for (j = k; j + 1 < 7; j++) { if (c[j + 6 * jBcol] != 0.0) { e_st.site = &t_emlrtRSI; for (i = j + 1; i + 1 < 7; i++) { c[i + 6 * jBcol] -= c[j + 6 * jBcol] * x[i + 6 * j]; } } } } e_st.site = &u_emlrtRSI; f_st.site = &ib_emlrtRSI; for (j = 0; j < 6; j++) { jBcol = 6 * j; for (k = 5; k >= 0; k += -1) { kAcol = 6 * k; if (c[k + jBcol] != 0.0) { c[k + jBcol] /= x[k + kAcol]; for (i = 0; i + 1 <= k; i++) { c[i + jBcol] -= c[k + jBcol] * x[i + kAcol]; } } } } d_st.site = &q_emlrtRSI; n1x = norm(a); n1xinv = norm(c); rc = 1.0 / (n1x * n1xinv); if ((n1x == 0.0) || (n1xinv == 0.0) || (rc == 0.0)) { e_st.site = &kb_emlrtRSI; warning(&e_st); } else { if (muDoubleScalarIsNaN(rc) || (rc < 2.2204460492503131E-16)) { e_st.site = &lb_emlrtRSI; for (jBcol = 0; jBcol < 6; jBcol++) { u[jBcol] = rfmt[jBcol]; } y = NULL; m0 = emlrtCreateCharArray(2, iv4); emlrtInitCharArrayR2013a(&e_st, 6, m0, &u[0]); emlrtAssign(&y, m0); b_y = NULL; m0 = emlrtCreateDoubleScalar(rc); emlrtAssign(&b_y, m0); f_st.site = &pb_emlrtRSI; emlrt_marshallIn(&f_st, b_sprintf(&f_st, y, b_y, &c_emlrtMCI), "sprintf", cv0); e_st.site = &lb_emlrtRSI; b_warning(&e_st, cv0); } } }
/* Function Definitions */ boolean_T relop(const creal_T a, const creal_T b) { boolean_T p; real_T absbi; real_T y; real_T absxk; int32_T exponent; real_T absar; real_T absbr; real_T Ma; int32_T b_exponent; int32_T c_exponent; int32_T d_exponent; if ((muDoubleScalarAbs(a.re) > 8.9884656743115785E+307) || (muDoubleScalarAbs (a.im) > 8.9884656743115785E+307) || (muDoubleScalarAbs(b.re) > 8.9884656743115785E+307) || (muDoubleScalarAbs(b.im) > 8.9884656743115785E+307)) { absbi = muDoubleScalarHypot(a.re / 2.0, a.im / 2.0); y = muDoubleScalarHypot(b.re / 2.0, b.im / 2.0); } else { absbi = muDoubleScalarHypot(a.re, a.im); y = muDoubleScalarHypot(b.re, b.im); } absxk = y / 2.0; if ((!muDoubleScalarIsInf(absxk)) && (!muDoubleScalarIsNaN(absxk))) { if (absxk <= 2.2250738585072014E-308) { absxk = 4.94065645841247E-324; } else { frexp(absxk, &exponent); absxk = ldexp(1.0, exponent - 53); } } else { absxk = rtNaN; } if ((muDoubleScalarAbs(y - absbi) < absxk) || (muDoubleScalarIsInf(absbi) && muDoubleScalarIsInf(y) && ((absbi > 0.0) == (y > 0.0)))) { p = true; } else { p = false; } if (p) { absar = muDoubleScalarAbs(a.re); absxk = muDoubleScalarAbs(a.im); absbr = muDoubleScalarAbs(b.re); absbi = muDoubleScalarAbs(b.im); if (absar > absxk) { Ma = absar; absar = absxk; } else { Ma = absxk; } if (absbr > absbi) { absxk = absbr; absbr = absbi; } else { absxk = absbi; } if (Ma > absxk) { if (absar < absbr) { absbi = Ma - absxk; y = (absar / 2.0 + absbr / 2.0) / (Ma / 2.0 + absxk / 2.0) * (absbr - absar); } else { absbi = Ma; y = absxk; } } else if (Ma < absxk) { if (absar > absbr) { y = absxk - Ma; absbi = (absar / 2.0 + absbr / 2.0) / (Ma / 2.0 + absxk / 2.0) * (absar - absbr); } else { absbi = Ma; y = absxk; } } else { absbi = absar; y = absbr; } absxk = muDoubleScalarAbs(y / 2.0); if ((!muDoubleScalarIsInf(absxk)) && (!muDoubleScalarIsNaN(absxk))) { if (absxk <= 2.2250738585072014E-308) { absxk = 4.94065645841247E-324; } else { frexp(absxk, &b_exponent); absxk = ldexp(1.0, b_exponent - 53); } } else { absxk = rtNaN; } if ((muDoubleScalarAbs(y - absbi) < absxk) || (muDoubleScalarIsInf(absbi) && muDoubleScalarIsInf(y) && ((absbi > 0.0) == (y > 0.0)))) { p = true; } else { p = false; } if (p) { absbi = muDoubleScalarAtan2(a.im, a.re); y = muDoubleScalarAtan2(b.im, b.re); absxk = muDoubleScalarAbs(y / 2.0); if ((!muDoubleScalarIsInf(absxk)) && (!muDoubleScalarIsNaN(absxk))) { if (absxk <= 2.2250738585072014E-308) { absxk = 4.94065645841247E-324; } else { frexp(absxk, &c_exponent); absxk = ldexp(1.0, c_exponent - 53); } } else { absxk = rtNaN; } if ((muDoubleScalarAbs(y - absbi) < absxk) || (muDoubleScalarIsInf(absbi) && muDoubleScalarIsInf(y) && ((absbi > 0.0) == (y > 0.0)))) { p = true; } else { p = false; } if (p) { if (absbi > 0.78539816339744828) { if (absbi > 2.3561944901923448) { absbi = -a.im; y = -b.im; } else { absbi = -a.re; y = -b.re; } } else if (absbi > -0.78539816339744828) { absbi = a.im; y = b.im; } else if (absbi > -2.3561944901923448) { absbi = a.re; y = b.re; } else { absbi = -a.im; y = -b.im; } absxk = muDoubleScalarAbs(y / 2.0); if ((!muDoubleScalarIsInf(absxk)) && (!muDoubleScalarIsNaN(absxk))) { if (absxk <= 2.2250738585072014E-308) { absxk = 4.94065645841247E-324; } else { frexp(absxk, &d_exponent); absxk = ldexp(1.0, d_exponent - 53); } } else { absxk = rtNaN; } if ((muDoubleScalarAbs(y - absbi) < absxk) || (muDoubleScalarIsInf(absbi) && muDoubleScalarIsInf(y) && ((absbi > 0.0) == (y > 0.0)))) { p = true; } else { p = false; } if (p) { absbi = 0.0; y = 0.0; } } } } return absbi <= y; }
void locateShortpreamble(const emlrtStack *sp, const real_T M_data[1224], real_T *preambleEstimatedLocation, real_T *numPeaks) { int32_T ixstart; real_T thresholdNorm; int32_T ix; boolean_T exitg1; boolean_T b_M_data[1224]; int32_T ii_size[1]; int32_T ii_data[1224]; int32_T MLocations_size_idx_0; int32_T loop_ub; real_T MLocations_data[1224]; int16_T unnamed_idx_0; int32_T peaks_data[1224]; int32_T i20; real_T b_MLocations_data[1224]; int32_T MLocations_size[1]; real_T MLocations[8]; int32_T ib_size[1]; int32_T ib_data[8]; int32_T ia_size[1]; int32_T ia_data[8]; int32_T c_size[1]; real_T c_data[8]; int32_T peaks_size[1]; emlrtStack st; emlrtStack b_st; emlrtStack c_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; /* Locate of the start of the actual preamble from timing metric */ /* % Find peaks of correlation */ /* Adjust threshold */ st.site = &pp_emlrtRSI; b_st.site = &we_emlrtRSI; ixstart = 1; thresholdNorm = M_data[0]; if (muDoubleScalarIsNaN(M_data[0])) { ix = 2; exitg1 = FALSE; while ((exitg1 == FALSE) && (ix <= 1224)) { ixstart = ix; if (!muDoubleScalarIsNaN(M_data[ix - 1])) { thresholdNorm = M_data[ix - 1]; exitg1 = TRUE; } else { ix++; } } } if (ixstart < 1224) { while (ixstart + 1 <= 1224) { if (M_data[ixstart] > thresholdNorm) { thresholdNorm = M_data[ixstart]; } ixstart++; } } st.site = &pp_emlrtRSI; thresholdNorm *= 0.6; st.site = &qp_emlrtRSI; for (ixstart = 0; ixstart < 1224; ixstart++) { b_M_data[ixstart] = (M_data[ixstart] > thresholdNorm); } b_st.site = &vc_emlrtRSI; b_eml_find(b_M_data, ii_data, ii_size); /* Correct estimate to start of preamble not its center */ MLocations_size_idx_0 = ii_size[0]; loop_ub = ii_size[0]; for (ixstart = 0; ixstart < loop_ub; ixstart++) { MLocations_data[ixstart] = (real_T)ii_data[ixstart] - 9.0; } /* Frame Detection */ unnamed_idx_0 = (int16_T)ii_size[0]; loop_ub = (int16_T)ii_size[0]; for (ixstart = 0; ixstart < loop_ub; ixstart++) { peaks_data[ixstart] = 0; } /* Determine correct peak */ st.site = &rp_emlrtRSI; ix = 0; while (ix <= ii_size[0] - 1) { ixstart = ix + 1; emlrtDynamicBoundsCheckFastR2012b(ixstart, 1, ii_size[0], &cb_emlrtBCI, sp); if (ix + 1 > ii_size[0]) { ixstart = 1; i20 = 1; } else { ixstart = emlrtDynamicBoundsCheckFastR2012b(ix + 1, 1, ii_size[0], &db_emlrtBCI, sp); i20 = emlrtDynamicBoundsCheckFastR2012b(ii_size[0], 1, ii_size[0], &db_emlrtBCI, sp) + 1; } emlrtVectorVectorIndexCheckR2012b(ii_size[0], 1, 1, i20 - ixstart, &s_emlrtECI, sp); st.site = &sp_emlrtRSI; b_st.site = &eq_emlrtRSI; MLocations_size[0] = i20 - ixstart; loop_ub = i20 - ixstart; for (i20 = 0; i20 < loop_ub; i20++) { b_MLocations_data[i20] = MLocations_data[(ixstart + i20) - 1]; } for (ixstart = 0; ixstart < 8; ixstart++) { MLocations[ixstart] = MLocations_data[ix] + (16.0 + 16.0 * (real_T)ixstart); } c_st.site = &fq_emlrtRSI; do_vectors(&c_st, b_MLocations_data, MLocations_size, MLocations, c_data, c_size, ia_data, ia_size, ib_data, ib_size); st.site = &sp_emlrtRSI; ixstart = (int16_T)ii_size[0]; peaks_data[emlrtDynamicBoundsCheckFastR2012b(ix + 1, 1, ixstart, &gb_emlrtBCI, sp) - 1] = c_size[0]; ix++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, sp); } /* Have at least 5 peaks for positive match */ /* (TUNABLE) */ peaks_size[0] = (int16_T)ii_size[0]; loop_ub = (int16_T)ii_size[0]; for (ixstart = 0; ixstart < loop_ub; ixstart++) { b_M_data[ixstart] = (peaks_data[ixstart] < 7); } st.site = &tp_emlrtRSI; eml_li_find(&st, b_M_data, peaks_size, ii_data, ii_size); loop_ub = ii_size[0]; for (ixstart = 0; ixstart < loop_ub; ixstart++) { i20 = (int16_T)MLocations_size_idx_0; peaks_data[emlrtDynamicBoundsCheckFastR2012b(ii_data[ixstart], 1, i20, &eb_emlrtBCI, sp) - 1] = 0; } /* Pick earliest peak in time */ if (!(unnamed_idx_0 == 0)) { st.site = &up_emlrtRSI; b_st.site = &ir_emlrtRSI; ixstart = peaks_data[0]; loop_ub = 1; if (unnamed_idx_0 > 1) { for (ix = 2; ix <= unnamed_idx_0; ix++) { if (peaks_data[ix - 1] > ixstart) { ixstart = peaks_data[ix - 1]; loop_ub = ix; } } } *numPeaks = ixstart; if (ixstart > 0) { *preambleEstimatedLocation = MLocations_data[emlrtDynamicBoundsCheckFastR2012b(loop_ub, 1, MLocations_size_idx_0, &fb_emlrtBCI, sp) - 1]; } else { *preambleEstimatedLocation = -1.0; /* no desirable location found */ } } else { *preambleEstimatedLocation = -1.0; *numPeaks = 0.0; } /* Normalize max peaks found */ st.site = &vp_emlrtRSI; b_st.site = &j_emlrtRSI; *numPeaks /= 8.0; }
/* 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); }
void drr_SK_Simplified(const emxArray_boolean_T *voxel_data, const real_T voxel_size_mm[3], const real_T detector_dimensions[2], real_T pixel_size_mm, const real_T voxel_corner_min[3], const real_T T_carm[16], emxArray_real_T *projection) { int32_T ix; int32_T i; uint32_T voxDim[3]; real_T voxPlanes__max[3]; real_T source[3]; real_T pixel_size_mmel__hn[3]; real_T pixel_size_mmel__wn[3]; real_T corner[3]; real_T b_ix; real_T iy; int32_T ih; int32_T iw; real_T tnext[3]; real_T tstep[3]; real_T b_voxPlanes__max[3]; real_T ray_source2pixel[3]; real_T b_ray_source2pixel[3]; real_T pixel_point_mm[3]; real_T t_plane_min[3]; real_T t_plane_max[3]; boolean_T exitg8; boolean_T exitg7; real_T iz; boolean_T exitg6; real_T t_larger[4]; boolean_T exitg5; boolean_T exitg4; boolean_T exitg3; real_T t_smaller[4]; real_T temp; int32_T itmp; boolean_T exitg2; real_T tmax; boolean_T exitg1; real_T tx; real_T ty; real_T tz; /* function [projection] = drr (voxel_data, voxel_size_mm, detector_dimensions, pixel_size_mm, isocenter_mm, cbct_angles_deg) */ /* Creates a 2D projection at each cbct_angle of voxel_data. the projection */ /* axis is defined by the isocenter to which the source and center of */ /* the detector are aligned. This simulation assumes standard Cone Beam CT */ /* geometry (source to isocenter distance is 100 cm and source to detector */ /* distance is 150cm). */ /* */ /* voxel_data: must be a 3 dimensional matrix (typically of CT data) */ /* voxel_size_mm: a 3 element vector listing the size (in mm) of the voxels */ /* along each dimension */ /* detector_dimension: a 2 element vector listing the dimensions (number of */ /* pixels) in each dimension (u,v) */ /* pixel_size_mm: a number defining the height and width of each pixel */ /* (assumes square pixel) */ /* isocenter_mm: a 3 element vector pointing from the origin (corner) of the */ /* matrix element(1,1,1) to the isocenter */ /* cbct_angles_deg: a list of angles to generate projections */ /* */ /* Retrun Variable */ /* projection: a 3D matrix with the 3rd dimension representing the angle of */ /* roatation */ /* */ /* { */ /* Author: Michael M. Folkerts [email protected] */ /* Institution: UCSD Physics, UTSW Radiation Oncology */ /* Updated: 2014-July. */ /* Notes: Siddon's Incremental algorithm | modified to read in 3D matlab matrix | Simplified Input | No guarantees!! */ /* */ /* References: */ /* R.L. Siddon, */ /* "Fast calculation of the exact radiological path for a three-dimensional CT */ /* array," Medical Physics 12, 252-255 (1985). */ /* */ /* F. Jacobs, E. Sundermann, B. De Sutter, M. Christiaens and I. Lemahieu, */ /* "A fast algorithm to calculate the exact radiological path through a pixel_size_mmel or voxel space," */ /* Journal of Computing and Information Technology 6, 89-94 (1998). */ /* */ /* G. Han, Z. Liang and J. You, */ /* "A fast ray tracing technique for TCT and ECT studies," */ /* IEEE Medical Imaging Conference 1999. */ /* } */ /* if(0) */ /* voxel_data = OUTPUTgrid; */ /* voxel_size_mm = voxel_size; */ /* detector_dimensions = detector_dimension; */ /* pixel_size_mm = pixel_size; */ /* isocenter_mm = isocenter; */ /* T_carm: Transformation matrix of C-arm (that is set at the middle of */ /* detector & source) with respect to Voxel coordinates */ /* tic; */ /* this will verify the size: */ if (eml_ndims_varsized(*(int32_T (*)[3])voxel_data->size) != 3) { EMLRTPUSHRTSTACK(&emlrtRSI); error(); EMLRTPOPRTSTACK(&emlrtRSI); } /* constants: */ /* .0001; */ /* .0001; */ /* sounce to imager(detector) distance */ /* source to axis distance %% RRI set the coordinate at the middle between source and the detector */ /* initialize memory for speed: */ ix = projection->size[0] * projection->size[1]; projection->size[0] = (int32_T)emlrtIntegerCheckR2009b (emlrtNonNegativeCheckR2009b(detector_dimensions[0], &b_emlrtDCI), &emlrtDCI); projection->size[1] = (int32_T)emlrtIntegerCheckR2009b (emlrtNonNegativeCheckR2009b(detector_dimensions[1], &d_emlrtDCI), &c_emlrtDCI); emxEnsureCapacity((emxArray__common *)projection, ix, (int32_T)sizeof(real_T), &emlrtRTEI); i = (int32_T)emlrtIntegerCheckR2009b(emlrtNonNegativeCheckR2009b (detector_dimensions[0], &f_emlrtDCI), &e_emlrtDCI) * (int32_T) emlrtIntegerCheckR2009b(emlrtNonNegativeCheckR2009b(detector_dimensions[1], &h_emlrtDCI), &g_emlrtDCI) - 1; for (ix = 0; ix <= i; ix++) { projection->data[ix] = 0.0; } for (ix = 0; ix < 3; ix++) { voxDim[ix] = (uint32_T)voxel_data->size[ix]; } /* [size(voxel_data,1), size(voxel_data,2), size(voxel_data,3)]; */ /* difine voxel boundaries: */ /* vector from origin to source */ /* vector from origin to CENTER of detector */ /* define pixel_size_mmel vectors: */ /* define upper lefthand corner of detector: */ for (i = 0; i < 3; i++) { voxPlanes__max[i] = voxel_corner_min[i] + voxel_size_mm[i] * (real_T) voxDim[i]; /* define up: */ /* up = [0,0,1]; */ /* width of projection image */ /* height of projection image */ /* direction from the detector to the source */ /* end initialization timer: */ /* init_time = toc */ /* start tracing timer: */ /* tic; */ source[i] = 550.0 * T_carm[4 + i] + T_carm[12 + i]; b_ix = -pixel_size_mm * T_carm[i]; /* length of pixel_size_mmel */ iy = pixel_size_mm * T_carm[8 + i]; /* vector pointing left, parallel to detector */ /* define incremental vectors: */ pixel_size_mmel__hn[i] = -iy; pixel_size_mmel__wn[i] = -b_ix; corner[i] = (-550.0 * T_carm[4 + i] + T_carm[12 + i]) + (detector_dimensions[0] * b_ix + detector_dimensions[1] * iy) / 2.0; } emlrtForLoopVectorCheckR2011b(1.0, 1.0, detector_dimensions[0], mxDOUBLE_CLASS, (int32_T)detector_dimensions[0], &d_emlrtRTEI, &emlrtContextGlobal, 0); ih = 0; while (ih <= (int32_T)detector_dimensions[0] - 1) { /* if(mod(ih,100)==0),fprintf('height:\t%i...\n',ih);end */ emlrtForLoopVectorCheckR2011b(1.0, 1.0, detector_dimensions[1], mxDOUBLE_CLASS, (int32_T)detector_dimensions[1], &c_emlrtRTEI, &emlrtContextGlobal, 0); iw = 0; while (iw <= (int32_T)detector_dimensions[1] - 1) { /* ray to be traced */ /* find parametrized (t) voxel plane (min or max) intersections: */ /* PLANE = P1 + t(P2-P1) */ /* SK added */ /* t_x = (i-x1) / (x2-x1), t_y = (j-y1) / (y2-y1), t_z = (k-z1) / (z2-z1) */ for (i = 0; i < 3; i++) { b_ix = (corner[i] + ((1.0 + (real_T)ih) - 1.0) * pixel_size_mmel__hn[i]) + ((1.0 + (real_T)iw) - 1.0) * pixel_size_mmel__wn[i]; /* ray end point */ iy = b_ix - source[i]; tnext[i] = voxel_corner_min[i] - source[i]; tstep[i] = iy + 2.2250738585072014E-308; b_voxPlanes__max[i] = voxPlanes__max[i] - source[i]; ray_source2pixel[i] = iy + 2.2250738585072014E-308; b_ray_source2pixel[i] = iy; pixel_point_mm[i] = b_ix; } rdivide(tnext, tstep, t_plane_min); rdivide(b_voxPlanes__max, ray_source2pixel, t_plane_max); /* compute (parametric) intersection values */ /* tmin = max { min{tx(0), tx(Nx)}, min{ty(0), ty(Ny)], min{tz(0), tz(Nz)}, 0.0 } */ /* tmax = min { max{tx(0), tx(Nx)}, max{ty(0), ty(Ny)], max{tz(0), tz(Nz)}, 1.0 } */ /* t_larger = [ max([t_plane_min(1), t_plane_max(1)]), max([t_plane_min(2), t_plane_max(2)]), max([t_plane_min(3), t_plane_max(3)]), 1.0 ]; */ /* t_smaller = [ min([t_plane_min(1), t_plane_max(1)]), min([t_plane_min(2), t_plane_max(2)]), min([t_plane_min(3), t_plane_max(3)]), 0.0 ]; */ i = 1; b_ix = t_plane_min[0]; if (muDoubleScalarIsNaN(t_plane_min[0])) { ix = 2; exitg8 = FALSE; while ((exitg8 == 0U) && (ix < 3)) { i = 2; if (!muDoubleScalarIsNaN(t_plane_max[0])) { b_ix = t_plane_max[0]; exitg8 = TRUE; } else { ix = 3; } } } if ((i < 2) && (t_plane_max[0] > b_ix)) { b_ix = t_plane_max[0]; } i = 1; iy = t_plane_min[1]; if (muDoubleScalarIsNaN(t_plane_min[1])) { ix = 2; exitg7 = FALSE; while ((exitg7 == 0U) && (ix < 3)) { i = 2; if (!muDoubleScalarIsNaN(t_plane_max[1])) { iy = t_plane_max[1]; exitg7 = TRUE; } else { ix = 3; } } } if ((i < 2) && (t_plane_max[1] > iy)) { iy = t_plane_max[1]; } i = 1; iz = t_plane_min[2]; if (muDoubleScalarIsNaN(t_plane_min[2])) { ix = 2; exitg6 = FALSE; while ((exitg6 == 0U) && (ix < 3)) { i = 2; if (!muDoubleScalarIsNaN(t_plane_max[2])) { iz = t_plane_max[2]; exitg6 = TRUE; } else { ix = 3; } } } if ((i < 2) && (t_plane_max[2] > iz)) { iz = t_plane_max[2]; } t_larger[0] = b_ix; t_larger[1] = iy; t_larger[2] = iz; t_larger[3] = 1.0; i = 1; b_ix = t_plane_min[0]; if (muDoubleScalarIsNaN(t_plane_min[0])) { ix = 2; exitg5 = FALSE; while ((exitg5 == 0U) && (ix < 3)) { i = 2; if (!muDoubleScalarIsNaN(t_plane_max[0])) { b_ix = t_plane_max[0]; exitg5 = TRUE; } else { ix = 3; } } } if ((i < 2) && (t_plane_max[0] < b_ix)) { b_ix = t_plane_max[0]; } i = 1; iy = t_plane_min[1]; if (muDoubleScalarIsNaN(t_plane_min[1])) { ix = 2; exitg4 = FALSE; while ((exitg4 == 0U) && (ix < 3)) { i = 2; if (!muDoubleScalarIsNaN(t_plane_max[1])) { iy = t_plane_max[1]; exitg4 = TRUE; } else { ix = 3; } } } if ((i < 2) && (t_plane_max[1] < iy)) { iy = t_plane_max[1]; } i = 1; iz = t_plane_min[2]; if (muDoubleScalarIsNaN(t_plane_min[2])) { ix = 2; exitg3 = FALSE; while ((exitg3 == 0U) && (ix < 3)) { i = 2; if (!muDoubleScalarIsNaN(t_plane_max[2])) { iz = t_plane_max[2]; exitg3 = TRUE; } else { ix = 3; } } } if ((i < 2) && (t_plane_max[2] < iz)) { iz = t_plane_max[2]; } t_smaller[0] = b_ix; t_smaller[1] = iy; t_smaller[2] = iz; t_smaller[3] = 0.0; i = 1; temp = t_smaller[0]; itmp = 0; if (muDoubleScalarIsNaN(t_smaller[0])) { ix = 2; exitg2 = FALSE; while ((exitg2 == 0U) && (ix < 5)) { i = ix; if (!muDoubleScalarIsNaN(t_smaller[ix - 1])) { temp = t_smaller[ix - 1]; exitg2 = TRUE; } else { ix++; } } } if (i < 4) { while (i + 1 < 5) { if (t_smaller[i] > temp) { temp = t_smaller[i]; itmp = i; } i++; } } i = 1; tmax = t_larger[0]; if (muDoubleScalarIsNaN(t_larger[0])) { ix = 2; exitg1 = FALSE; while ((exitg1 == 0U) && (ix < 5)) { i = ix; if (!muDoubleScalarIsNaN(t_larger[ix - 1])) { tmax = t_larger[ix - 1]; exitg1 = TRUE; } else { ix++; } } } if (i < 4) { while (i + 1 < 5) { if (t_larger[i] < tmax) { tmax = t_larger[i]; } i++; } } for (ix = 0; ix < 3; ix++) { pixel_point_mm[ix] = (real_T)(pixel_point_mm[ix] < source[ix]) * -2.0 + 1.0; } if (temp < tmax) { /* if ray intersects volume */ /* find index for each dimension: */ for (i = 0; i < 3; i++) { b_ix = muDoubleScalarFloor((((b_ray_source2pixel[i] * temp + source[i]) - voxel_corner_min[i]) + 2.2250738585072014E-308) / voxel_size_mm[i]); /* (parametric) intersection values... */ /* makes 0 or 1 */ tnext[i] = (voxel_corner_min[i] + ((b_ix + (pixel_point_mm[i] + 1.0) / 2.0) * voxel_size_mm[i] - source[i])) / (b_ray_source2pixel[i] + 2.2250738585072014E-308); /* parametric value for next plane intersection */ iy = voxel_size_mm[i] / (b_ray_source2pixel[i] + 2.2250738585072014E-308); tstep[i] = muDoubleScalarAbs(iy); b_ray_source2pixel[i] = iy; t_plane_min[i] = b_ix; } /* parametric step size */ /* address special cases... */ if (temp == t_plane_max[emlrtBoundsCheck(itmp + 1, &c_emlrtBCI) - 1]) { /* if intersection is a "max" plane */ if (itmp + 1 == 1) { t_plane_min[0] = (real_T)voxDim[0] - 1.0; } else if (itmp + 1 == 2) { t_plane_min[1] = (real_T)voxDim[1] - 2.0; } else { t_plane_min[2] = (real_T)voxDim[2] - 2.0; } tnext[itmp] = temp + tstep[itmp]; /* next plane crossing */ } else { t_plane_min[itmp] = 0.0; tnext[itmp] = temp + tstep[itmp]; /* next plane crossing */ } /* voxel index values(add one for matlab): */ b_ix = t_plane_min[0] + 1.0; iy = t_plane_min[1] + 1.0; iz = t_plane_min[2] + 1.0; tx = tnext[0]; ty = tnext[1]; tz = tnext[2]; i = 0; /* uncomment to generate P-matrix: */ /* pixel_size_mmNum = 1; */ /* len = norm(ray_source2pixel); % ray length */ while ((temp + 0.0001 < tmax) && (!(b_ix * iy * iz == 0.0))) { if ((tx < ty) && (tx < tz)) { /* 실제 DRR을 그리지 않고, 한점이라도 지나면 해당 점에 포함시킴 */ if (voxel_data->data[((emlrtDynamicBoundsCheck((int32_T) emlrtIntegerCheckR2009b(b_ix, &o_emlrtDCI), 1, voxel_data->size[0], &j_emlrtBCI) + voxel_data->size[0] * (emlrtDynamicBoundsCheck((int32_T) emlrtIntegerCheckR2009b(iy, &p_emlrtDCI), 1, voxel_data->size[1], &k_emlrtBCI) - 1)) + voxel_data->size[0] * voxel_data->size[1] * (emlrtDynamicBoundsCheck((int32_T) emlrtIntegerCheckR2009b(iz, &q_emlrtDCI), 1, voxel_data-> size[2], &l_emlrtBCI) - 1)) - 1]) { i = 255; tmax = rtMinusInf; } temp = tx; tx += tstep[0]; b_ix += pixel_point_mm[0]; } else if (ty < tz) { /* 실제 DRR을 그리지 않고, 한점이라도 지나면 해당 점에 포함시킴 */ if (voxel_data->data[((emlrtDynamicBoundsCheck((int32_T) emlrtIntegerCheckR2009b(b_ix, &l_emlrtDCI), 1, voxel_data->size[0], &g_emlrtBCI) + voxel_data->size[0] * (emlrtDynamicBoundsCheck((int32_T) emlrtIntegerCheckR2009b(iy, &m_emlrtDCI), 1, voxel_data->size[1], &h_emlrtBCI) - 1)) + voxel_data->size[0] * voxel_data->size[1] * (emlrtDynamicBoundsCheck((int32_T) emlrtIntegerCheckR2009b(iz, &n_emlrtDCI), 1, voxel_data-> size[2], &i_emlrtBCI) - 1)) - 1]) { i = 255; tmax = rtMinusInf; } temp = ty; ty += tstep[1]; iy += pixel_point_mm[1]; } else { /* 실제 DRR을 그리지 않고, 한점이라도 지나면 해당 점에 포함시킴 */ if (voxel_data->data[((emlrtDynamicBoundsCheck((int32_T) emlrtIntegerCheckR2009b(b_ix, &i_emlrtDCI), 1, voxel_data->size[0], &d_emlrtBCI) + voxel_data->size[0] * (emlrtDynamicBoundsCheck((int32_T) emlrtIntegerCheckR2009b(iy, &j_emlrtDCI), 1, voxel_data->size[1], &e_emlrtBCI) - 1)) + voxel_data->size[0] * voxel_data->size[1] * (emlrtDynamicBoundsCheck((int32_T) emlrtIntegerCheckR2009b(iz, &k_emlrtDCI), 1, voxel_data-> size[2], &f_emlrtBCI) - 1)) - 1]) { i = 255; tmax = rtMinusInf; } temp = tz; tz += tstep[2]; iz += pixel_point_mm[2]; } emlrtBreakCheck(); } /* end while */ projection->data[(emlrtDynamicBoundsCheck((int32_T)(1.0 + (real_T)ih), 1, projection->size[0], &m_emlrtBCI) + projection->size[0] * (emlrtDynamicBoundsCheck((int32_T)(1.0 + (real_T)iw), 1, projection->size[1], &n_emlrtBCI) - 1)) - 1] = (real_T)i; } else { /* if no intersections */ projection->data[(emlrtDynamicBoundsCheck((int32_T)(1.0 + (real_T)ih), 1, projection->size[0], &emlrtBCI) + projection->size[0] * (emlrtDynamicBoundsCheck((int32_T)(1.0 + (real_T)iw), 1, projection->size[1], &b_emlrtBCI) - 1)) - 1] = 0.0; } /* if intersections */ /* uncomment to generate P-matrix: */ /* rayCount = rayCount + 1; */ iw++; emlrtBreakCheck(); } /* width */ /* fprintf('\n'); */ ih++; emlrtBreakCheck(); } /* height */ /* uncomment to generate P-matrix: */ /* matrix = matrix(1:mtxCount-1,:); */ /* stop trace timer: */ /* trace_time = toc */ /* fprintf('\n') */ /* function */ /* } */ }
static void sf_c9_QPSK_Transmit_v12d(SFc9_QPSK_Transmit_v12dInstanceStruct *chartInstance) { creal_T c9_d_in; uint32_T c9_debug_family_var_map[5]; const mxArray *c9_fm = NULL; real_T c9_nargin = 1.0; real_T c9_nargout = 1.0; cint16_T c9_d_out; creal_T c9_varargin_1; real_T c9_d0; real_T c9_d1; int16_T c9_i0; cint16_T c9_b_varargin_1; real_T c9_d2; real_T c9_d3; int16_T c9_i1; const mxArray *c9_T = NULL; const mxArray *c9_F = NULL; const mxArray *c9_ERR = NULL; const mxArray *c9_val = NULL; const mxArray *c9_isautoscaled = NULL; const mxArray *c9_pvpairsetdata = NULL; const mxArray *c9_isfimathlocal = NULL; cint16_T *c9_b_d_out; creal_T *c9_b_d_in; c9_b_d_out = (cint16_T *)ssGetOutputPortSignal(chartInstance->S, 1); c9_b_d_in = (creal_T *)ssGetInputPortSignal(chartInstance->S, 0); _sfTime_ = (real_T)ssGetT(chartInstance->S); _SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 1U, chartInstance->c9_sfEvent); chartInstance->c9_sfEvent = CALL_EVENT; _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 1U, chartInstance->c9_sfEvent); c9_d_in.re = c9_b_d_in->re; c9_d_in.im = c9_b_d_in->im; sf_debug_symbol_scope_push_eml(0U, 5U, 5U, c9_debug_family_names, c9_debug_family_var_map); sf_debug_symbol_scope_add_eml(&c9_fm, 0U, c9_d_sf_marshallOut); sf_debug_symbol_scope_add_eml_importable(&c9_nargin, 1U, c9_c_sf_marshallOut, c9_b_sf_marshallIn); sf_debug_symbol_scope_add_eml_importable(&c9_nargout, 2U, c9_c_sf_marshallOut, c9_b_sf_marshallIn); sf_debug_symbol_scope_add_eml(&c9_d_in, 3U, c9_b_sf_marshallOut); sf_debug_symbol_scope_add_eml_importable(&c9_d_out, 4U, c9_sf_marshallOut, c9_sf_marshallIn); CV_EML_FCN(0, 0); _SFD_EML_CALL(0U, chartInstance->c9_sfEvent, 3); c9_fm = c9_eml_mx; _SFD_EML_CALL(0U, chartInstance->c9_sfEvent, 5); c9_varargin_1 = c9_d_in; c9_d0 = muDoubleScalarFloor(c9_varargin_1.re * 2048.0); if (muDoubleScalarIsNaN(c9_d0) || muDoubleScalarIsInf(c9_d0)) { c9_d1 = 0.0; } else { c9_d1 = muDoubleScalarRem(c9_d0, 4096.0); } c9_i0 = (int16_T)muDoubleScalarFloor(c9_d1); if ((int16_T)(c9_i0 & 2048) != 0) { c9_b_varargin_1.re = (int16_T)(c9_i0 | -2048); } else { c9_b_varargin_1.re = (int16_T)(c9_i0 & 2047); } c9_d2 = muDoubleScalarFloor(c9_varargin_1.im * 2048.0); if (muDoubleScalarIsNaN(c9_d2) || muDoubleScalarIsInf(c9_d2)) { c9_d3 = 0.0; } else { c9_d3 = muDoubleScalarRem(c9_d2, 4096.0); } c9_i1 = (int16_T)muDoubleScalarFloor(c9_d3); if ((int16_T)(c9_i1 & 2048) != 0) { c9_b_varargin_1.im = (int16_T)(c9_i1 | -2048); } else { c9_b_varargin_1.im = (int16_T)(c9_i1 & 2047); } c9_d_out = c9_b_varargin_1; sf_mex_destroy(&c9_T); sf_mex_destroy(&c9_F); sf_mex_destroy(&c9_ERR); sf_mex_destroy(&c9_val); sf_mex_destroy(&c9_isautoscaled); sf_mex_destroy(&c9_pvpairsetdata); sf_mex_destroy(&c9_isfimathlocal); _SFD_EML_CALL(0U, chartInstance->c9_sfEvent, -5); sf_debug_symbol_scope_pop(); c9_b_d_out->re = c9_d_out.re; c9_b_d_out->im = c9_d_out.im; _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 1U, chartInstance->c9_sfEvent); sf_debug_check_for_state_inconsistency(_QPSK_Transmit_v12dMachineNumber_, chartInstance->chartNumber, chartInstance->instanceNumber); }
void drr_151213_XRayInParam(const emlrtStack *sp, const emxArray_boolean_T *voxel_data, const real_T voxel_size_mm[3], const real_T detector_dimensions[2], const real_T XRayIntrinsicParam[12], const real_T voxel_corner_min[3], const real_T T_carm[16], emxArray_real_T *projection) { const mxArray *y; static const int32_T iv0[2] = { 1, 32 }; const mxArray *m0; char_T cv0[32]; int32_T i; static const char_T cv1[32] = { 'v', 'o', 'x', 'e', 'l', '_', 'd', 'a', 't', 'a', ' ', 'm', 'u', 's', 't', ' ', 'b', 'e', ' ', '3', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n', 'a', 'l' }; int32_T i0; real_T pixel_size_mm_h; real_T pixel_size_mm_w; uint32_T voxDim[3]; real_T voxPlanes__max[3]; real_T source[3]; real_T pixel_size_mmel_wn[3]; real_T pixel_size_mmel_hn[3]; real_T corner[3]; int32_T ih; int32_T iw; real_T tstep[3]; real_T tnext[3]; real_T pixel_point_mm[3]; real_T ray_source2pixel[3]; real_T b_voxPlanes__max[3]; real_T b_ray_source2pixel[3]; real_T t_plane_min[3]; real_T t_plane_max[3]; real_T tmax; int32_T pixel_size_mmIntensity; boolean_T exitg8; boolean_T exitg7; boolean_T exitg6; real_T t_larger[4]; real_T temp; boolean_T exitg5; boolean_T exitg4; boolean_T exitg3; real_T t_smaller[4]; int32_T itmp; boolean_T exitg2; boolean_T exitg1; real_T iz; real_T tx; real_T ty; real_T tz; int32_T i1; int32_T i2; int32_T i3; emlrtStack st; emlrtStack b_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; /* % Modificiation Notes */ /* 15.12.04 */ /* - Release 기존의 파일을 참고로 하여 고성영이 수정하였음. */ /* - DRR을 완벽하게 하지 않고, voxel에 한점이라도 만나면 on으로 계산함 */ /* - 계산속도가 향상되었음 */ /* - 젬스에 있는 X-ray와 테스트하여 검증하였음 */ /* 15 12 13 : The function input has been changed to utilize the x-ray */ /* intrinsic parameter provided by GEMSS % 151213 kosy */ /* %function [projection] = drr (voxel_data, voxel_size_mm, detector_dimensions, pixel_size_mm, isocenter_mm, cbct_angles_deg) */ /* Creates a 2D projection at each cbct_angle of voxel_data. the projection */ /* axis is defined by the isocenter to which the source and center of */ /* the detector are aligned. This simulation assumes standard Cone Beam CT */ /* geometry (source to isocenter distance is 100 cm and source to detector */ /* distance is 150cm). */ /* */ /* voxel_data: must be a 3 dimensional matrix (typically of CT data) */ /* voxel_size_mm: a 3 element vector listing the size (in mm) of the voxels */ /* along each dimension */ /* detector_dimension: a 2 element vector listing the dimensions (number of */ /* pixels) in each dimension (u,v) */ /* pixel_size_mm: a number defining the height and width of each pixel */ /* (assumes square pixel) */ /* isocenter_mm: a 3 element vector pointing from the origin (corner) of the */ /* matrix element(1,1,1) to the isocenter */ /* cbct_angles_deg: a list of angles to generate projections */ /* */ /* Retrun Variable */ /* projection: a 3D matrix with the 3rd dimension representing the angle of */ /* roatation */ /* */ /* { */ /* Author: Michael M. Folkerts [email protected] */ /* Institution: UCSD Physics, UTSW Radiation Oncology */ /* Updated: 2014-July. */ /* Notes: Siddon's Incremental algorithm | modified to read in 3D matlab matrix | Simplified Input | No guarantees!! */ /* */ /* References: */ /* R.L. Siddon, */ /* "Fast calculation of the exact radiological path for a three-dimensional CT */ /* array," Medical Physics 12, 252-255 (1985). */ /* */ /* F. Jacobs, E. Sundermann, B. De Sutter, M. Christiaens and I. Lemahieu, */ /* "A fast algorithm to calculate the exact radiological path through a pixel_size_mmel or voxel space," */ /* Journal of Computing and Information Technology 6, 89-94 (1998). */ /* */ /* G. Han, Z. Liang and J. You, */ /* "A fast ray tracing technique for TCT and ECT studies," */ /* IEEE Medical Imaging Conference 1999. */ /* } */ /* function [projection] = drr_good_151204 (voxel_data, voxel_size_mm, detector_dimensions, pixel_size_mm, voxel_corner_min, T_carm) */ /* if(0) */ /* voxel_data = OUTPUTgrid; */ /* voxel_size_mm = voxel_size; */ /* detector_dimensions = detector_dimension; */ /* pixel_size_mm = pixel_size; */ /* isocenter_mm = isocenter; */ /* T_carm: Transformation matrix of C-arm (that is set at the middle of */ /* detector & source) with respect to Voxel coordinates */ /* tic; */ /* this will verify the size: */ if (eml_ndims_varsized(*(int32_T (*)[3])voxel_data->size) != 3) { st.site = &emlrtRSI; y = NULL; m0 = emlrtCreateCharArray(2, iv0); for (i = 0; i < 32; i++) { cv0[i] = cv1[i]; } emlrtInitCharArrayR2013a(&st, 32, m0, cv0); emlrtAssign(&y, m0); b_st.site = &b_emlrtRSI; error(&b_st, y, &emlrtMCI); } /* constants: */ /* .0001; */ /* .0001; */ /* sounce to imager(detector) distance */ /* source to axis distance %% RRI set the coordinate at the middle between source and the detector */ /* initialize memory for speed: */ i0 = projection->size[0] * projection->size[1]; pixel_size_mm_h = emlrtNonNegativeCheckFastR2012b(detector_dimensions[0], &b_emlrtDCI, sp); projection->size[0] = (int32_T)emlrtIntegerCheckFastR2012b(pixel_size_mm_h, &emlrtDCI, sp); pixel_size_mm_h = emlrtNonNegativeCheckFastR2012b(detector_dimensions[1], &d_emlrtDCI, sp); projection->size[1] = (int32_T)emlrtIntegerCheckFastR2012b(pixel_size_mm_h, &c_emlrtDCI, sp); emxEnsureCapacity(sp, (emxArray__common *)projection, i0, (int32_T)sizeof (real_T), &emlrtRTEI); pixel_size_mm_h = emlrtNonNegativeCheckFastR2012b(detector_dimensions[0], &b_emlrtDCI, sp); pixel_size_mm_w = emlrtNonNegativeCheckFastR2012b(detector_dimensions[1], &d_emlrtDCI, sp); i = (int32_T)emlrtIntegerCheckFastR2012b(pixel_size_mm_h, &emlrtDCI, sp) * (int32_T)emlrtIntegerCheckFastR2012b(pixel_size_mm_w, &c_emlrtDCI, sp); for (i0 = 0; i0 < i; i0++) { projection->data[i0] = 0.0; } for (i0 = 0; i0 < 3; i0++) { voxDim[i0] = (uint32_T)voxel_data->size[i0]; } /* [size(voxel_data,1), size(voxel_data,2), size(voxel_data,3)]; */ /* voxDim_x = voxDim(1); */ /* voxDim_y = voxDim(2); */ /* voxDim_z = voxDim(3); */ /* difine voxel boundaries: */ /* vector from origin to source */ /* vector from origin to CENTER of detector */ /* extract the key information from the intrinsic parameters % 151213 kosy modi */ pixel_size_mm_h = 1105.0 / XRayIntrinsicParam[0]; pixel_size_mm_w = 1105.0 / XRayIntrinsicParam[4]; /* vector pointing left, parallel to detector */ /* define incremental vectors: */ /* define upper lefthand corner of detector: */ /* corner = detector + ( center_pixel_w*pixel_size_mmel.wn + center_pixel_h*pixel_size_mmel.hn ); */ for (i = 0; i < 3; i++) { voxPlanes__max[i] = voxel_corner_min[i] + voxel_size_mm[i] * (real_T) voxDim[i]; /* define up: */ /* up = [0,0,1]; */ /* width of projection image */ /* height of projection image */ /* direction from the detector to the source */ /* end initialization timer: */ /* init_time = toc */ /* start tracing timer: */ /* tic; */ source[i] = 552.5 * T_carm[4 + i] + T_carm[12 + i]; /* define pixel_size_mmel vectors: */ /* length of pixel_size_mmel */ pixel_size_mmel_wn[i] = -pixel_size_mm_w * T_carm[i]; pixel_size_mmel_hn[i] = -pixel_size_mm_h * T_carm[8 + i]; corner[i] = (-552.5 * T_carm[4 + i] + T_carm[12 + i]) + (detector_dimensions[0] * (pixel_size_mm_w * T_carm[i]) + detector_dimensions[1] * (pixel_size_mm_h * T_carm[8 + i])) / 2.0; } emlrtForLoopVectorCheckR2012b(1.0, 1.0, detector_dimensions[0], mxDOUBLE_CLASS, (int32_T)detector_dimensions[0], &d_emlrtRTEI, sp); ih = 1; while (ih - 1 <= (int32_T)detector_dimensions[0] - 1) { /* if(mod(ih,100)==0),fprintf('height:\t%i...\n',ih);end */ emlrtForLoopVectorCheckR2012b(1.0, 1.0, detector_dimensions[1], mxDOUBLE_CLASS, (int32_T)detector_dimensions[1], &c_emlrtRTEI, sp); iw = 1; while (iw - 1 <= (int32_T)detector_dimensions[1] - 1) { /* pixel_point_mm = corner + (ih-1)*pixel_size_mmel.hp + (iw-1)*pixel_size_mmel.wp; %ray end point */ /* ray to be traced */ /* find parametrized (t) voxel plane (min or max) intersections: */ /* PLANE = P1 + t(P2-P1) */ /* SK added */ /* t_x = (i-x1) / (x2-x1), t_y = (j-y1) / (y2-y1), t_z = (k-z1) / (z2-z1) */ for (i = 0; i < 3; i++) { pixel_size_mm_h = (corner[i] + ((1.0 + (real_T)(ih - 1)) - 1.0) * pixel_size_mmel_hn[i]) + ((1.0 + (real_T)(iw - 1)) - 1.0) * pixel_size_mmel_wn[i]; /* ray end point */ pixel_size_mm_w = pixel_size_mm_h - source[i]; tstep[i] = voxel_corner_min[i] - source[i]; tnext[i] = pixel_size_mm_w + 2.2250738585072014E-308; b_voxPlanes__max[i] = voxPlanes__max[i] - source[i]; b_ray_source2pixel[i] = pixel_size_mm_w + 2.2250738585072014E-308; pixel_point_mm[i] = pixel_size_mm_h; ray_source2pixel[i] = pixel_size_mm_w; } rdivide(tstep, tnext, t_plane_min); rdivide(b_voxPlanes__max, b_ray_source2pixel, t_plane_max); /* compute (parametric) intersection values */ /* tmin = max { min{tx(0), tx(Nx)}, min{ty(0), ty(Ny)], min{tz(0), tz(Nz)}, 0.0 } */ /* tmax = min { max{tx(0), tx(Nx)}, max{ty(0), ty(Ny)], max{tz(0), tz(Nz)}, 1.0 } */ /* t_larger = [ max([t_plane_min(1), t_plane_max(1)]), max([t_plane_min(2), t_plane_max(2)]), max([t_plane_min(3), t_plane_max(3)]), 1.0 ]; */ /* t_smaller = [ min([t_plane_min(1), t_plane_max(1)]), min([t_plane_min(2), t_plane_max(2)]), min([t_plane_min(3), t_plane_max(3)]), 0.0 ]; */ i = 1; tmax = t_plane_min[0]; if (muDoubleScalarIsNaN(t_plane_min[0])) { pixel_size_mmIntensity = 2; exitg8 = false; while ((!exitg8) && (pixel_size_mmIntensity < 3)) { i = 2; if (!muDoubleScalarIsNaN(t_plane_max[0])) { tmax = t_plane_max[0]; exitg8 = true; } else { pixel_size_mmIntensity = 3; } } } if ((i < 2) && (t_plane_max[0] > tmax)) { tmax = t_plane_max[0]; } i = 1; pixel_size_mm_h = t_plane_min[1]; if (muDoubleScalarIsNaN(t_plane_min[1])) { pixel_size_mmIntensity = 2; exitg7 = false; while ((!exitg7) && (pixel_size_mmIntensity < 3)) { i = 2; if (!muDoubleScalarIsNaN(t_plane_max[1])) { pixel_size_mm_h = t_plane_max[1]; exitg7 = true; } else { pixel_size_mmIntensity = 3; } } } if ((i < 2) && (t_plane_max[1] > pixel_size_mm_h)) { pixel_size_mm_h = t_plane_max[1]; } i = 1; pixel_size_mm_w = t_plane_min[2]; if (muDoubleScalarIsNaN(t_plane_min[2])) { pixel_size_mmIntensity = 2; exitg6 = false; while ((!exitg6) && (pixel_size_mmIntensity < 3)) { i = 2; if (!muDoubleScalarIsNaN(t_plane_max[2])) { pixel_size_mm_w = t_plane_max[2]; exitg6 = true; } else { pixel_size_mmIntensity = 3; } } } if ((i < 2) && (t_plane_max[2] > pixel_size_mm_w)) { pixel_size_mm_w = t_plane_max[2]; } t_larger[0] = tmax; t_larger[1] = pixel_size_mm_h; t_larger[2] = pixel_size_mm_w; t_larger[3] = 1.0; i = 1; temp = t_plane_min[0]; if (muDoubleScalarIsNaN(t_plane_min[0])) { pixel_size_mmIntensity = 2; exitg5 = false; while ((!exitg5) && (pixel_size_mmIntensity < 3)) { i = 2; if (!muDoubleScalarIsNaN(t_plane_max[0])) { temp = t_plane_max[0]; exitg5 = true; } else { pixel_size_mmIntensity = 3; } } } if ((i < 2) && (t_plane_max[0] < temp)) { temp = t_plane_max[0]; } i = 1; pixel_size_mm_h = t_plane_min[1]; if (muDoubleScalarIsNaN(t_plane_min[1])) { pixel_size_mmIntensity = 2; exitg4 = false; while ((!exitg4) && (pixel_size_mmIntensity < 3)) { i = 2; if (!muDoubleScalarIsNaN(t_plane_max[1])) { pixel_size_mm_h = t_plane_max[1]; exitg4 = true; } else { pixel_size_mmIntensity = 3; } } } if ((i < 2) && (t_plane_max[1] < pixel_size_mm_h)) { pixel_size_mm_h = t_plane_max[1]; } i = 1; pixel_size_mm_w = t_plane_min[2]; if (muDoubleScalarIsNaN(t_plane_min[2])) { pixel_size_mmIntensity = 2; exitg3 = false; while ((!exitg3) && (pixel_size_mmIntensity < 3)) { i = 2; if (!muDoubleScalarIsNaN(t_plane_max[2])) { pixel_size_mm_w = t_plane_max[2]; exitg3 = true; } else { pixel_size_mmIntensity = 3; } } } if ((i < 2) && (t_plane_max[2] < pixel_size_mm_w)) { pixel_size_mm_w = t_plane_max[2]; } t_smaller[0] = temp; t_smaller[1] = pixel_size_mm_h; t_smaller[2] = pixel_size_mm_w; t_smaller[3] = 0.0; i = 1; itmp = 0; if (muDoubleScalarIsNaN(temp)) { pixel_size_mmIntensity = 1; exitg2 = false; while ((!exitg2) && (pixel_size_mmIntensity + 1 < 5)) { i = pixel_size_mmIntensity + 1; if (!muDoubleScalarIsNaN(t_smaller[pixel_size_mmIntensity])) { temp = t_smaller[pixel_size_mmIntensity]; itmp = pixel_size_mmIntensity; exitg2 = true; } else { pixel_size_mmIntensity++; } } } if (i < 4) { while (i + 1 < 5) { if (t_smaller[i] > temp) { temp = t_smaller[i]; itmp = i; } i++; } } i = 1; if (muDoubleScalarIsNaN(tmax)) { pixel_size_mmIntensity = 2; exitg1 = false; while ((!exitg1) && (pixel_size_mmIntensity < 5)) { i = pixel_size_mmIntensity; if (!muDoubleScalarIsNaN(t_larger[pixel_size_mmIntensity - 1])) { tmax = t_larger[pixel_size_mmIntensity - 1]; exitg1 = true; } else { pixel_size_mmIntensity++; } } } if (i < 4) { while (i + 1 < 5) { if (t_larger[i] < tmax) { tmax = t_larger[i]; } i++; } } for (i0 = 0; i0 < 3; i0++) { pixel_point_mm[i0] = (real_T)(pixel_point_mm[i0] < source[i0]) * -2.0 + 1.0; } if (temp < tmax) { /* if ray intersects volume */ /* find index for each dimension: */ for (i = 0; i < 3; i++) { pixel_size_mm_h = muDoubleScalarFloor((((ray_source2pixel[i] * temp + source[i]) - voxel_corner_min[i]) + 2.2250738585072014E-308) / voxel_size_mm[i]); /* (parametric) intersection values... */ /* makes 0 or 1 */ tnext[i] = (voxel_corner_min[i] + ((pixel_size_mm_h + (pixel_point_mm[i] + 1.0) / 2.0) * voxel_size_mm[i] - source[i])) / (ray_source2pixel[i] + 2.2250738585072014E-308); /* parametric value for next plane intersection */ tstep[i] = muDoubleScalarAbs(voxel_size_mm[i] / (ray_source2pixel[i] + 2.2250738585072014E-308)); t_plane_min[i] = pixel_size_mm_h; } /* parametric step size */ /* address special cases... */ if (temp == t_plane_max[emlrtDynamicBoundsCheckFastR2012b(itmp + 1, 1, 3, &c_emlrtBCI, sp) - 1]) { /* if intersection is a "max" plane */ t_plane_min[itmp] = (real_T)voxDim[itmp] - 1.0; tnext[itmp] = temp + tstep[itmp]; /* next plane crossing */ } else { t_plane_min[itmp] = 0.0; tnext[itmp] = temp + tstep[itmp]; /* next plane crossing */ } /* voxel index values(add one for matlab): */ pixel_size_mm_h = t_plane_min[0] + 1.0; pixel_size_mm_w = t_plane_min[1] + 1.0; iz = t_plane_min[2] + 1.0; tx = tnext[0]; ty = tnext[1]; tz = tnext[2]; pixel_size_mmIntensity = 0; /* uncomment to generate P-matrix: */ /* pixel_size_mmNum = 1; */ /* len = norm(ray_source2pixel); % ray length */ while ((temp + 0.0001 < tmax) && (!(pixel_size_mm_h * pixel_size_mm_w * iz == 0.0))) { if ((tx < ty) && (tx < tz)) { /* 실제 DRR을 그리지 않고, 한점이라도 지나면 해당 점에 포함시킴 */ i0 = voxel_data->size[0]; i = (int32_T)emlrtIntegerCheckFastR2012b(pixel_size_mm_h, &k_emlrtDCI, sp); itmp = voxel_data->size[1]; i1 = (int32_T)emlrtIntegerCheckFastR2012b(pixel_size_mm_w, &l_emlrtDCI, sp); i2 = voxel_data->size[2]; i3 = (int32_T)emlrtIntegerCheckFastR2012b(iz, &m_emlrtDCI, sp); if (voxel_data->data[((emlrtDynamicBoundsCheckFastR2012b(i, 1, i0, &j_emlrtBCI, sp) + voxel_data->size[0] * (emlrtDynamicBoundsCheckFastR2012b(i1, 1, itmp, &k_emlrtBCI, sp) - 1)) + voxel_data->size[0] * voxel_data->size[1] * (emlrtDynamicBoundsCheckFastR2012b(i3, 1, i2, &l_emlrtBCI, sp) - 1)) - 1]) { pixel_size_mmIntensity = 255; tmax = rtMinusInf; } temp = tx; tx += tstep[0]; pixel_size_mm_h += pixel_point_mm[0]; } else if (ty < tz) { /* 실제 DRR을 그리지 않고, 한점이라도 지나면 해당 점에 포함시킴 */ i0 = voxel_data->size[0]; i = (int32_T)emlrtIntegerCheckFastR2012b(pixel_size_mm_h, &h_emlrtDCI, sp); itmp = voxel_data->size[1]; i1 = (int32_T)emlrtIntegerCheckFastR2012b(pixel_size_mm_w, &i_emlrtDCI, sp); i2 = voxel_data->size[2]; i3 = (int32_T)emlrtIntegerCheckFastR2012b(iz, &j_emlrtDCI, sp); if (voxel_data->data[((emlrtDynamicBoundsCheckFastR2012b(i, 1, i0, &g_emlrtBCI, sp) + voxel_data->size[0] * (emlrtDynamicBoundsCheckFastR2012b(i1, 1, itmp, &h_emlrtBCI, sp) - 1)) + voxel_data->size[0] * voxel_data->size[1] * (emlrtDynamicBoundsCheckFastR2012b(i3, 1, i2, &i_emlrtBCI, sp) - 1)) - 1]) { pixel_size_mmIntensity = 255; tmax = rtMinusInf; } temp = ty; ty += tstep[1]; pixel_size_mm_w += pixel_point_mm[1]; } else { /* 실제 DRR을 그리지 않고, 한점이라도 지나면 해당 점에 포함시킴 */ i0 = voxel_data->size[0]; i = (int32_T)emlrtIntegerCheckFastR2012b(pixel_size_mm_h, &e_emlrtDCI, sp); itmp = voxel_data->size[1]; i1 = (int32_T)emlrtIntegerCheckFastR2012b(pixel_size_mm_w, &f_emlrtDCI, sp); i2 = voxel_data->size[2]; i3 = (int32_T)emlrtIntegerCheckFastR2012b(iz, &g_emlrtDCI, sp); if (voxel_data->data[((emlrtDynamicBoundsCheckFastR2012b(i, 1, i0, &d_emlrtBCI, sp) + voxel_data->size[0] * (emlrtDynamicBoundsCheckFastR2012b(i1, 1, itmp, &e_emlrtBCI, sp) - 1)) + voxel_data->size[0] * voxel_data->size[1] * (emlrtDynamicBoundsCheckFastR2012b(i3, 1, i2, &f_emlrtBCI, sp) - 1)) - 1]) { pixel_size_mmIntensity = 255; tmax = rtMinusInf; } temp = tz; tz += tstep[2]; iz += pixel_point_mm[2]; } emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, sp); } /* end while */ i0 = projection->size[0]; i = projection->size[1]; projection->data[(emlrtDynamicBoundsCheckFastR2012b(ih, 1, i0, &m_emlrtBCI, sp) + projection->size[0] * (emlrtDynamicBoundsCheckFastR2012b(iw, 1, i, &n_emlrtBCI, sp) - 1)) - 1] = pixel_size_mmIntensity; } else { /* if no intersections */ i0 = projection->size[0]; i = projection->size[1]; projection->data[(emlrtDynamicBoundsCheckFastR2012b(ih, 1, i0, &emlrtBCI, sp) + projection->size[0] * (emlrtDynamicBoundsCheckFastR2012b(iw, 1, i, &b_emlrtBCI, sp) - 1)) - 1] = 0.0; } /* if intersections */ /* uncomment to generate P-matrix: */ /* rayCount = rayCount + 1; */ iw++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, sp); } /* width */ /* fprintf('\n'); */ ih++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, sp); } /* height */ /* uncomment to generate P-matrix: */ /* matrix = matrix(1:mtxCount-1,:); */ /* stop trace timer: */ /* trace_time = toc */ /* fprintf('\n') */ /* function */ /* } */ }
/* Function Definitions */ comm_AGC *AGC_AGC(const emlrtStack *sp, comm_AGC *obj, real_T varargin_4) { comm_AGC *b_obj; comm_AGC *c_obj; boolean_T flag; static const char_T cv0[43] = { 'E', 'x', 'p', 'e', 'c', 't', 'e', 'd', ' ', 'A', 'd', 'a', 'p', 't', 'a', 't', 'i', 'o', 'n', 'S', 't', 'e', 'p', 'S', 'i', 'z', 'e', ' ', 't', 'o', ' ', 'b', 'e', ' ', 'p', 'o', 's', 'i', 't', 'i', 'v', 'e', '.' }; static const char_T cv1[42] = { 'E', 'x', 'p', 'e', 'c', 't', 'e', 'd', ' ', 'A', 'd', 'a', 'p', 't', 'a', 't', 'i', 'o', 'n', 'S', 't', 'e', 'p', 'S', 'i', 'z', 'e', ' ', 't', 'o', ' ', 'b', 'e', ' ', 'n', 'o', 'n', '-', 'N', 'a', 'N', '.' }; static const char_T cv2[41] = { 'E', 'x', 'p', 'e', 'c', 't', 'e', 'd', ' ', 'A', 'd', 'a', 'p', 't', 'a', 't', 'i', 'o', 'n', 'S', 't', 'e', 'p', 'S', 'i', 'z', 'e', ' ', 't', 'o', ' ', 'b', 'e', ' ', 'f', 'i', 'n', 'i', 't', 'e', '.' }; 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; b_obj = obj; b_obj->pStepSizeSet = false; b_obj->pDetectorMethodSet = false; b_obj->pLoopMethodSet = false; b_obj->pUpdatePeriodSet = false; b_obj->pGainOutputPortSet = false; st.site = &p_emlrtRSI; c_obj = b_obj; b_st.site = &r_emlrtRSI; c_st.site = &s_emlrtRSI; d_st.site = &t_emlrtRSI; c_st.site = &s_emlrtRSI; c_obj->isInitialized = 0; d_st.site = &u_emlrtRSI; st.site = &p_emlrtRSI; b_st.site = &v_emlrtRSI; st.site = &p_emlrtRSI; b_st.site = &w_emlrtRSI; st.site = &q_emlrtRSI; c_obj = b_obj; b_st.site = &t_emlrtRSI; c_st.site = &t_emlrtRSI; d_st.site = &x_emlrtRSI; flag = (c_obj->isInitialized == 1); if (flag) { c_obj->TunablePropsChanged = true; } d_st.site = &x_emlrtRSI; e_st.site = &y_emlrtRSI; flag = true; if (!(varargin_4 <= 0.0)) { } else { flag = false; } if (flag) { } else { emlrtErrMsgIdAndExplicitTxt(&e_st, &emlrtRTEI, "MATLAB:expectedPositive", 43, cv0); } flag = true; if (!muDoubleScalarIsNaN(varargin_4)) { } else { flag = false; } if (flag) { } else { emlrtErrMsgIdAndExplicitTxt(&e_st, &b_emlrtRTEI, "MATLAB:expectedNonNaN", 42, cv1); } flag = true; if ((!muDoubleScalarIsInf(varargin_4)) && (!muDoubleScalarIsNaN(varargin_4))) { } else { flag = false; } if (flag) { } else { emlrtErrMsgIdAndExplicitTxt(&e_st, &c_emlrtRTEI, "MATLAB:expectedFinite", 41, cv2); } c_obj->AdaptationStepSize = varargin_4; return b_obj; }
/* Function Definitions */ void clcPMP_olyHyb_tmp(const emlrtStack *sp, real_T engKinPre, real_T engKinAct, real_T gea, real_T slp, real_T batEng, real_T psiBatEng, real_T psiTim, real_T batPwrAux, real_T batEngStp, real_T wayStp, const struct0_T *par, real_T *cosHamMin, real_T *batFrcOut, real_T *fulFrcOut) { real_T mtmp; real_T vehVel; real_T b_engKinPre[2]; real_T crsSpdVec[2]; int32_T i18; int32_T k; boolean_T y; boolean_T exitg3; boolean_T exitg2; real_T crsSpd; real_T whlTrq; real_T crsTrq; real_T iceTrqMax; real_T iceTrqMin; real_T b_par[100]; real_T emoTrqMaxPos; real_T emoTrqMinPos; real_T emoTrqMax; real_T emoTrqMin; real_T batPwrMax; real_T batPwrMin; real_T batOcv; real_T batEngDltMin; real_T batEngDltMax; real_T batEngDltMinInx; real_T batEngDltMaxInx; real_T batEngDlt; real_T fulFrc; real_T batFrc; real_T b_batFrc; real_T batPwr; real_T emoTrq; real_T iceTrq; real_T fulPwr; int32_T ixstart; int32_T itmp; int32_T ix; boolean_T exitg1; emlrtStack st; emlrtStack b_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; /* CLCPMP Minimizing Hamiltonian: Co-States for soc and time */ /* Erstellungsdatum der ersten Version 19.08.2015 - Stephan Uebel */ /* */ /* Batterieleistungsgrenzen hinzugefügt am 13.12.2015 */ /* ^^added battery power limit */ /* */ /* Massenaufschlag durch Trägheitsmoment herausgenommen */ /* ^^Mass increment removed by inertia */ /* */ /* % Inputdefinition */ /* */ /* engKinPre - Double(1,1) - kinetische Energie am Intervallanfang in J */ /* ^^ kinetic energy at start of interval (J) */ /* engKinAct - Double(1,1) - kinetische Energie am Intervallende in J */ /* ^^ kinetic energe at end of interval (J) */ /* gea - Double(1,1) - Gang */ /* ^^ gear */ /* slp - Double(1,1) - Steigung in rad */ /* ^^ slope in radians */ /* iceFlg - Boolean(1,1) - Flag für Motorzustand */ /* ^^ flag for motor condition */ /* batEng - Double(1,1) - Batterieenergie in J */ /* ^^ battery energy (J) */ /* psibatEng - Double(1,1) - Costate für Batterieenergie ohne Einheit */ /* ^^ costate for battery energy w/o unity */ /* psiTim - Double(1,1) - Costate für die Zeit ohne Einheit */ /* ^^ costate for time without unity */ /* batPwrAux - Double(1,1) - elektr. Nebenverbraucherleistung in W */ /* ^^ electric auxiliary power consumed (W) */ /* batEngStp - Double(1,1) - Drehmomentschritt */ /* ^^ torque step <- no, it's a battery step */ /* wayStp - Double(1,1) - Intervallschrittweite in m */ /* ^^ interval step distance (m) */ /* par - Struct(1,1) - Modelldaten */ /* ^^ model data */ /* % Initialisieren der Ausgabe der Funktion */ /* initializing function output */ /* Ausgabewert des Minimums der Hamiltonfunktion */ /* output for minimizing the hamiltonian */ *cosHamMin = rtInf; /* Batterieladungsänderung im Wegschritt beir minimaler Hamiltonfunktion */ /* battery change in path_idx step with the minial hamiltonian */ *batFrcOut = rtInf; /* Kraftstoffkraftänderung im Wegschritt bei minimaler Hamiltonfunktion */ /* fuel change in path_idx step with the minimal hamiltonian */ *fulFrcOut = 0.0; /* % Initialisieren der persistent Größen */ /* initialize the persistance variables */ /* Diese werden die nur einmal für die Funktion berechnet */ /* only calculated once for the function */ if (!crsSpdHybMax_not_empty) { /* maximale Drehzahl Elektrommotor */ /* maximum electric motor rotational speed */ /* maximale Drehzahl der Kurbelwelle */ /* maximum crankshaft rotational speed */ crsSpdHybMax = muDoubleScalarMin(par->iceSpdMgd[14850], par->emoSpdMgd[14850]); crsSpdHybMax_not_empty = true; /* minimale Drehzahl der Kurbelwelle */ /* minimum crankshaft rotational speed */ crsSpdHybMin = par->iceSpdMgd[0]; } /* % Initialisieren der allgemein benötigten Kenngrößen */ /* initializing the commonly required parameters */ /* mittlere kinetische Energie im Wegschritt berechnen */ /* define the average kinetic energy at path_idx step - is just previous KE */ /* mittlere Geschwindigkeit im Wegschritt berechnen */ /* define the average speed at path_idx step */ mtmp = 2.0 * engKinPre / par->vehMas; st.site = &g_emlrtRSI; if (mtmp < 0.0) { b_st.site = &h_emlrtRSI; eml_error(&b_st); } vehVel = muDoubleScalarSqrt(mtmp); /* % vorzeitiger Funktionsabbruch? */ /* premature function termination? */ /* Drehzahl der Kurbelwelle und Grenzen */ /* crankshaft speed and limits */ /* Aus den kinetischen Energien des Fahrzeugs wird über die Raddrehzahl */ /* und die übersetzung vom Getriebe die Kurbelwellendrehzahl berechnet. */ /* Zeilenrichtung entspricht den Gängen. (Zeilenvektor) */ /* from the vehicle's kinetic energy, the crankshaft speed is calculated */ /* by the speed and gearbox translation. Line direction corresponding to */ /* the aisles (row rector). EQUATION 1 */ b_engKinPre[0] = engKinPre; b_engKinPre[1] = engKinAct; for (i18 = 0; i18 < 2; i18++) { crsSpdVec[i18] = 2.0 * b_engKinPre[i18] / par->vehMas; } st.site = &f_emlrtRSI; for (k = 0; k < 2; k++) { if (crsSpdVec[k] < 0.0) { b_st.site = &h_emlrtRSI; eml_error(&b_st); } } for (k = 0; k < 2; k++) { crsSpdVec[k] = muDoubleScalarSqrt(crsSpdVec[k]); } i18 = par->geaRat->size[1]; k = (int32_T)gea; emlrtDynamicBoundsCheckR2012b(k, 1, i18, &mb_emlrtBCI, sp); mtmp = par->geaRat->data[(int32_T)gea - 1]; for (i18 = 0; i18 < 2; i18++) { crsSpdVec[i18] = mtmp * crsSpdVec[i18] / par->whlDrr; } /* Abbruch, wenn die Drehzahlen der Kurbelwelle zu hoch im hybridischen */ /* Modus */ /* stop if the crankshaft rotatoinal speed is too high in hybrid mode */ y = false; k = 0; exitg3 = false; while ((!exitg3) && (k < 2)) { if (!!(crsSpdVec[k] > crsSpdHybMax)) { y = true; exitg3 = true; } else { k++; } } if (y) { } else { /* Falls die Drehzahl des Verbrennungsmotors niedriger als die */ /* Leerlaufdrehzahl ist, */ /* stop if crankhaft rotional speed is lower than the idling speed */ y = false; k = 0; exitg2 = false; while ((!exitg2) && (k < 2)) { if (!!(crsSpdVec[k] < crsSpdHybMin)) { y = true; exitg2 = true; } else { k++; } } if (y) { } else { /* Prüfen, ob die Drehzahlgrenze des Elektromotors eingehalten wird */ /* check if electric motor speed limit is maintained */ /* mittlere Kurbelwellendrehzahlen berechnen */ /* calculate average crankshaft rotational speed */ /* - really just selecting the previous path_idx KE crankshaft speed */ crsSpd = crsSpdVec[0]; /* % Längsdynamik berechnen */ /* calculate longitundinal dynamics */ /* Es wird eine konstante Beschleunigung angenommen, die im Wegschritt */ /* wayStp das Fahrzeug von velPre auf velAct beschleunigt. */ /* constant acceleration assumed when transitioning from velPre to velAct */ /* for the selected wayStp path_idx step distance */ /* Berechnen der konstanten Beschleunigung */ /* calculate the constant acceleration */ /* Aus der mittleren kinetischen Energie im Intervall, der mittleren */ /* Steigung und dem Gang lässt sich über die Fahrwiderstandsgleichung */ /* die nötige Fahrwiderstandskraft berechnen, die aufgebracht werden */ /* muss, um diese zu realisieren. */ /* from the (avg) kinetic energy in the interval, the (avg) slope and */ /* transition can calculate the necessary traction force on the driving */ /* resistance equation (PART OF EQUATION 5) */ /* Steigungskraft aus der mittleren Steigung berechnen (Skalar) */ /* gradiant force from the calculated (average) gradient */ /* Rollreibungskraft berechnen (Skalar) */ /* calculated rolling friction force - not included in EQ 5??? */ /* Luftwiderstandskraft berechnen (2*c_a/m * E_kin) (Skalar) */ /* calculated air resistance force */ /* % Berechnung der minimalen kosten der Hamiltonfunktion */ /* Calculating the minimum cost of the Hamiltonian */ /* % Berechnen der Kraft am Rad für Antriebsstrangmodus */ /* calculate the force on the wheel for the drivetrain mode */ /* % dynamische Fahrzeugmasse bei Fahrzeugmotor an berechnen. Das */ /* % heißt es werden Trägheitsmoment von Verbrennungsmotor, */ /* % Elektromotor und Rädern mit einbezogen. */ /* calculate dynamic vehicle mass with the vehicle engine (with the moment */ /* of intertia of the ICE, electric motor, and wheels) */ /* vehMasDyn = (par.iceMoi_geaRat(gea) +... */ /* par.emoGeaMoi_geaRat(gea) + par.whlMoi)/par.whlDrr^2 ... */ /* + par.vehMas; */ /* Radkraft berechnen (Beschleunigungskraft + Steigungskraft + */ /* Rollwiderstandskraft + Luftwiderstandskraft) */ /* caluclating wheel forces (accerlation force + gradient force + rolling */ /* resistance + air resistance) EQUATION 5 */ /* % Getriebeübersetzung und -verlust */ /* gear ratio and loss */ /* Das Drehmoment des Rades ergibt sich über den Radhalbmesser aus */ /* der Fahrwiderstandskraft. */ /* the weel torque is obtained from the wheel radius of the rolling */ /* resistance force (torque = force * distance (in this case, radius) */ whlTrq = ((((engKinAct - engKinPre) / (par->vehMas * wayStp) * par->vehMas + par->vehMas * 9.81 * muDoubleScalarSin(slp)) + par->whlRolResCof * par->vehMas * 9.81 * muDoubleScalarCos(slp)) + 2.0 * par->drgCof / par->vehMas * engKinPre) * par->whlDrr; /* Berechnung des Kurbelwellenmoments */ /* Hier muss unterschieden werden, ob das Radmoment positiv oder */ /* negativ ist, da nur ein einfacher Wirkungsgrad für das Getriebe */ /* genutzt wird */ /* it's important to determine sign of crankshaft torque (positive or */ /* negative), since only a simple efficiency is used for the transmission */ /* PART OF EQ4 <- perhaps reversed? not too sure */ if (whlTrq < 0.0) { i18 = par->geaRat->size[1]; k = (int32_T)gea; emlrtDynamicBoundsCheckR2012b(k, 1, i18, &nb_emlrtBCI, sp); crsTrq = whlTrq / par->geaRat->data[(int32_T)gea - 1] * par->geaEfy; } else { i18 = par->geaRat->size[1]; k = (int32_T)gea; emlrtDynamicBoundsCheckR2012b(k, 1, i18, &ob_emlrtBCI, sp); crsTrq = whlTrq / par->geaRat->data[(int32_T)gea - 1] / par->geaEfy; } /* % Verbrennungsmotor */ /* internal combustion engine */ /* maximales Moment des Verbrennungsmotors berechnen */ /* calculate max torque of the engine (quadratic based on rotation speed) */ iceTrqMax = (par->iceTrqMaxCof[0] * (crsSpdVec[0] * crsSpdVec[0]) + par->iceTrqMaxCof[1] * crsSpdVec[0]) + par->iceTrqMaxCof[2]; /* minimales Moment des Verbrennungsmotors berechnen */ /* calculating mimimum ICE moment */ iceTrqMin = (par->iceTrqMinCof[0] * (crsSpdVec[0] * crsSpdVec[0]) + par->iceTrqMinCof[1] * crsSpdVec[0]) + par->iceTrqMinCof[2]; /* % Elektromotor */ /* electric motor */ /* maximales Moment, dass die E-Maschine liefern kann */ /* max torque that the electric motor can provide - from interpolation */ /* emoTrqMaxPos = ... */ /* lininterp1(par.emoSpdMgd(1,:)',par.emoTrqMax_emoSpd,crsSpd); */ for (i18 = 0; i18 < 100; i18++) { b_par[i18] = par->emoSpdMgd[150 * i18]; } emoTrqMaxPos = interp1q(b_par, par->emoTrqMax_emoSpd, crsSpdVec[0]); /* Die gültigen Kurbelwellenmomente müssen kleiner sein als das */ /* Gesamtmoment von E-Motor und Verbrennungsmotor */ /* The valid crankshaft moments must be less than the total moment of the */ /* electric motor and the ICE.Otherwise, leave the function */ if (crsTrq > iceTrqMax + emoTrqMaxPos) { } else { /* % %% Optimaler Momentensplit - Minimierung der Hamiltonfunktion */ /* optimum torque split - minimizing the Hamiltonian */ /* Die Vorgehensweise ist ähnlich wie bei der ECMS. Es wird ein Vektor der */ /* möglichen Batterieenergieänderungen aufgestellt. Aus diesen lässt sich */ /* eine Batterieklemmleistung berechnen. Aus der über das */ /* Kurbelwellenmoment, ein Elektromotormoment berechnet werden kann. */ /* Über das geforderte Kurbelwellenmoment, kann für jedes Moment des */ /* Elektromotors ein Moment des Verbrennungsmotors gefunden werden. Für */ /* jedes Momentenpaar kann die Hamiltonfunktion berechnet werden. */ /* Ausgegeben wird der minimale Wert der Hamiltonfunktion und die */ /* durch das dabei verwendete Elektromotormoment verursachte */ /* Batterieladungsänderung. */ /* The procedure is similar to ECMS. It's based on a vector of possible */ /* battery energy changes, from which a battery terminal power can be */ /* calculated. */ /* From the crankshaft torque, an electric motor torque can be */ /* calculated, and an engine torque can be found for every electric motor */ /* moment. */ /* For every moment-pair the Hamiltonian can be calculated. It */ /* outputs the minimum Hamilotnian value and the battery charge change */ /* caused by the electric motor torque used. */ /* % Elektromotor - Aufstellen des Batterienergievektors */ /* electric motor - positioning the battery energy vectors */ if (batEngStp > 0.0) { /* Skalar - änderung der minimalen Batterieenergieänderung */ /* Skalar - änderung der maximalen Batterieenergieänderung */ /* FUNCTION CALL */ /* Skalar - Wegschrittweite */ /* Skalar - mittlere Geschwindigkeit im Intervall */ /* Skalar - Nebenverbraucherlast */ /* Skalar - Batterieenergie */ /* struct - Fahrzeugparameter */ /* Skalar - crankshaft rotational speed */ /* Skalar - crankshaft torque */ /* Skalar - min ICE torque allowed */ /* Skalar - max ICE torque allowed */ /* Skalar - max EM torque possible */ st.site = &e_emlrtRSI; /* Skalar - änderung der minimalen Batterieenergieänderung */ /* Skalar - änderung der maximalen Batterieenergieänderung */ /* Skalar - Wegschrittweite */ /* Skalar - Geschwindigkeit im Intervall */ /* Skalar - Nebenverbraucherlast */ /* Skalar - Batterieenergie */ /* struct - Fahrzeugparameter */ /* Skalar - crankshaft rotational speed */ /* Skalar - crankshaft torque */ /* Skalar - min ICE torque allowed */ /* Skalar - max ICE torque */ /* Skalar - max EM torque possible */ /* BatEngDltClc Calculates the change in battery energy */ /* */ /* Erstellungsdatum der ersten Version 17.11.2015 - Stephan Uebel */ /* Berechnung der Verluste des Elektromotors bei voller rein elektrischer */ /* Fahrt (voller Lastpunktabsenkung) und bei voller Lastpunktanhebung */ /* Calculations of loss of electric motor at purely full electric */ /* Driving (full load point lowering) and at full load point raising */ /* */ /* Version vom 17.02.2016: Keine Einbeziehung von Rotationsmassen */ /* ^^ No inclusion of rotational masses */ /* */ /* Version vom 25.05.2016: Zero-Order-Hold (keine mittlere Geschwindigkeit) */ /* ^^ Zero-Order-Hold (no average velocities) */ /* % Initialisieren der Ausgabe der Funktion */ /* initializing the function output (delta battery_energy min and max) */ /* % Elektromotor */ /* minimales Moment, dass die E-Maschine liefern kann */ /* minimum moment that the EM can provide (max is an input to function) */ /* emoTrqMinPos = ... */ /* lininterp1(par.emoSpdMgd(1,:)',par.emoTrqMin_emoSpd,crsSpd); */ for (i18 = 0; i18 < 100; i18++) { b_par[i18] = par->emoSpdMgd[150 * i18]; } emoTrqMinPos = interp1q(b_par, par->emoTrqMin_emoSpd, crsSpdVec[0]); /* % Verbrennungsmotor berechnen */ /* Durch EM zu lieferndes Kurbelwellenmoment */ /* crankshaft torque to be delivered by the electric motor (min and max) */ emoTrqMax = crsTrq - iceTrqMin; emoTrqMin = crsTrq - iceTrqMax; /* % Elektromotor berechnen */ /* calculate the electric motor */ if (emoTrqMaxPos < emoTrqMax) { /* Moment des Elektromotors bei maximaler Entladung der Batterie */ /* EM torque at max battery discharge */ emoTrqMax = emoTrqMaxPos; } if (emoTrqMaxPos < emoTrqMin) { /* Moment des Elektromotors bei minimaler Entladung der Batterie */ /* EM torque at min battery discharge */ emoTrqMin = emoTrqMaxPos; } emoTrqMax = muDoubleScalarMax(emoTrqMinPos, emoTrqMax); emoTrqMin = muDoubleScalarMax(emoTrqMinPos, emoTrqMin); /* % Berechnung der änderung der Batterieladung */ /* calculating the change in battery charge */ /* Interpolation der benötigten Batterieklemmleistung für das */ /* EM-Moment. Stellen die nicht definiert sind, werden mit inf */ /* ausgegeben. Positive Werte entsprechen entladen der Batterie. */ /* interpolating the required battery terminal power for the EM torque. */ /* Assign undefined values to inf. Positive values coresspond with battery */ /* discharge. */ /* batPwrMax = lininterp2(par.emoSpdMgd(1,:),par.emoTrqMgd(:,1),... */ /* par.emoPwr_emoSpd_emoTrq',crsSpd,emoTrqMax) + batPwrAux; */ /* */ /* batPwrMin = lininterp2(par.emoSpdMgd(1,:),par.emoTrqMgd(:,1),... */ /* par.emoPwr_emoSpd_emoTrq',crsSpd,emoTrqMin) + batPwrAux; */ b_st.site = &i_emlrtRSI; batPwrMax = codegen_interp2(&b_st, par->emoSpdMgd, par->emoTrqMgd, par->emoPwr_emoSpd_emoTrq, crsSpdVec[0], emoTrqMax) + batPwrAux; b_st.site = &j_emlrtRSI; batPwrMin = codegen_interp2(&b_st, par->emoSpdMgd, par->emoTrqMgd, par->emoPwr_emoSpd_emoTrq, crsSpdVec[0], emoTrqMin) + batPwrAux; /* überprüfen, ob Batterieleistung möglich */ /* make sure that current battery max power is not above bat max bounds */ if (batPwrMax > par->batPwrMax) { batPwrMax = par->batPwrMax; } /* überprüfen, ob Batterieleistung möglich */ /* make sure that current battery min power is not below bat min bounds */ if (batPwrMin > par->batPwrMax) { batPwrMin = par->batPwrMax; } /* Es kann vorkommen, dass mehr Leistung gespeist werden soll, als */ /* möglich ist. */ /* double check that the max and min still remain within the other bounds */ if (batPwrMax < par->batPwrMin) { batPwrMax = par->batPwrMin; } if (batPwrMin < par->batPwrMin) { batPwrMin = par->batPwrMin; } /* Batteriespannung aus Kennkurve berechnen */ /* calculating battery voltage of characteristic curve - eq?-------------- */ batOcv = batEng * par->batOcvCof_batEng[0] + par->batOcvCof_batEng[1]; /* FUNCTION CALL - min delta bat.energy */ /* Skalar - Batterieklemmleistung */ /* Skalar - mittlere Geschwindigkeit im Intervall */ /* Skalar - Entladewiderstand */ /* Skalar - Ladewiderstand */ /* Skalar - battery open-circuit voltage */ batEngDltMin = batFrcClc_tmp(batPwrMax, vehVel, par->batRstDch, par->batRstChr, batOcv) * wayStp; /* <-multiply by delta_S */ /* FUNCTION CALL - max delta bat.energy */ /* Skalar - Batterieklemmleistung */ /* Skalar - mittlere Geschwindigkeit im Intervall */ /* Skalar - Entladewiderstand */ /* Skalar - Ladewiderstand */ /* Skalar - battery open-circuit voltage */ batEngDltMax = batFrcClc_tmp(batPwrMin, vehVel, par->batRstDch, par->batRstChr, batOcv) * wayStp; /* Es werden 2 Fälle unterschieden: */ /* there are 2 different cases */ if ((batEngDltMin > 0.0) && (batEngDltMax > 0.0)) { /* %% konventionelles Bremsen + Rekuperieren */ /* conventional brakes + recuperation */ /* */ /* set change in energy to discretized integer values w/ ceil and */ /* floor. This also helps for easy looping */ /* Konventionelles Bremsen wird ebenfalls untersucht. */ /* Hier liegt eventuell noch Beschleunigungspotential, da diese */ /* Zustandswechsel u.U. ausgeschlossen werden können. */ /* NOTE: u.U. = unter Ümständen = circumstances permitting */ /* convetional breaks also investigated. An accelerating potential */ /* is still possible, as these states can be excluded */ /* (circumstances permitting) <- ??? not sure what above means */ /* */ /* so if both min and max changes in battery energy are */ /* increasing, then set the delta min to zero */ batEngDltMinInx = 0.0; batEngDltMaxInx = muDoubleScalarFloor(batEngDltMax / batEngStp); } else { batEngDltMinInx = muDoubleScalarCeil(batEngDltMin / batEngStp); batEngDltMaxInx = muDoubleScalarFloor(batEngDltMax / batEngStp); } } else { batEngDltMinInx = 0.0; batEngDltMaxInx = 0.0; } /* you got a larger min chnage and a max change, you're out of bounds. Leave */ /* the function */ if (batEngDltMaxInx < batEngDltMinInx) { } else { /* % Schleife über alle Elektromotormomente */ /* now loop through all the electric-motor torques */ i18 = (int32_T)(batEngDltMaxInx + (1.0 - batEngDltMinInx)); emlrtForLoopVectorCheckR2012b(batEngDltMinInx, 1.0, batEngDltMaxInx, mxDOUBLE_CLASS, i18, &o_emlrtRTEI, sp); k = 0; while (k <= i18 - 1) { batEngDlt = (batEngDltMinInx + (real_T)k) * batEngStp; /* open circuit voltage over each iteration */ batOcv = (batEng + batEngDlt) * par->batOcvCof_batEng[0] + par->batOcvCof_batEng[1]; /* Skalar für die Batterieleistung in W */ /* Skalar Krafstoffkraft in N */ /* FUNCTION CALL */ /* Skalar für die Wegschrittweite in m, */ /* Skalar - vehicular velocity */ /* Nebenverbraucherlast */ /* Skalar - battery open circuit voltage */ /* Skalar - Batterieenergie�nderung, */ /* Skalar - crankshaft speed at given path_idx */ /* Skalar - crankshaft torque at given path_idx */ /* Skalar - min ICE torque allowed */ /* Skalar - max ICE torque */ /* struct der Fahrzeugparameter */ st.site = &d_emlrtRSI; /* Skalar für die Batterieleistung */ /* Skalar Kraftstoffkraft */ /* Skalar für die Wegschrittweite in m */ /* vehicular velocity */ /* Nebenverbraucherlast */ /* Skalar - battery open circuit voltage */ /* Skalar - Batterieenergieänderung */ /* Skalar - crankshaft speed at given path_idx */ /* Skalar - crankshaft torque at given path_idx */ /* Skalar - min ICE torque allowed */ /* Skalar - max ICE torque */ /* struct der Fahrzeugparameter */ /* */ /* FULENGCLC Calculating fuel consumption */ /* Erstellungsdatum der ersten Version 04.09.2015 - Stephan Uebel */ /* */ /* Diese Funktion berechnet den Kraftstoffverbrauch für einen gegebenen */ /* Wegschritt der kinetischen Energie, der Batterieenergie und des */ /* Antriebsstrangzustands über dem Weg. */ /* this function calculates fuel consumption for a given route step of */ /* KE, the battery energy, and drivetrain state of the current path_idx */ /* */ /* Version vom 17.02.2016 : Rotationsmassen vernachlässigt */ /* ^^ neglected rotatary masses */ /* */ /* Version vom 25.05.2016: Zero-Order-Hold (keine mittlere Geschwindigkeit) */ /* */ /* version from 1.06.2016 - removed crsTrq calulations - they are already */ /* done in parent function (clcPMP_olHyb_tmp) and do not change w/ each */ /* iteration, making the caluclation here unnecessary */ /* % Initialisieren der Ausgabe der Funktion */ /* initializing function output */ /* Skalar - electric battery power (W) */ fulFrc = rtInf; /* Skalar - fuel force intialization (N) */ /* % Batterie */ /* Batterieenergieänderung über dem Weg (Batteriekraft) */ /* Change in battery energy over the path_idx way (ie battery power) */ batFrc = batEngDlt / wayStp; /* Fallunterscheidung, ob Batterie geladen oder entladen wird */ /* Case analysis - check if battery is charging or discharging. Set */ /* resistance accordingly */ /* elektrische Leistung des Elektromotors */ /* electric power from electric motor - DERIVATION? dunno */ /* innere Batterieleistung / internal batt power */ /* dissipat. Leist. / dissipated */ if (batFrc < 0.0) { b_batFrc = par->batRstDch; } else { b_batFrc = par->batRstChr; } batPwr = (-batFrc * vehVel - batFrc * batFrc * (vehVel * vehVel) / (batOcv * batOcv) * b_batFrc) - batPwrAux; /* Nebenverbrauchlast / auxiliary power */ /* % Elektromotor */ /* Ermitteln des Kurbelwellenmoments durch EM aus Batterieleistung */ /* determine crankshaft torque cauesd by EM's battery power */ /* switching out codegen_interp2 for lininterp2-just might work! */ /* */ b_st.site = &k_emlrtRSI; emoTrq = codegen_interp2(&b_st, par->emoSpdMgd, par->emoPwrMgd, par->emoTrq_emoSpd_emoPwr, crsSpd, batPwr); /* emoTrq = lininterp2(par.emoSpdMgd(1,:), par.emoPwrMgd(:,1),... */ /* par.emoTrq_emoSpd_emoPwr',crsSpd,emoPwrEle); */ if (muDoubleScalarIsInf(emoTrq)) { } else { /* Grenzen des Elektromotors müssen hier nicht überprüft werden, da die */ /* Ladungsdeltas schon so gewählt wurden, dass das maximale Motormoment */ /* nicht überstiegen wird. */ /* Electric motor limits need not be checked here, since the charge deltas */ /* have been chosen so that the max torque is not exceeded. */ /* % Verbrennungsmotor */ /* Ermitteln des Kurbelwellenmoments durch den Verbrennungsmotor */ /* Determining the crankshaft moment from the ICE */ iceTrq = crsTrq - emoTrq; /* Wenn das Verbrennungsmotormoment kleiner als das minimale */ /* Moment ist, ist dieser in der Schubabschaltung. Das */ /* verbleibende Moment liefern die Bremsen */ /* If engine torque is less than the min torque, fuel is cut. The */ /* remaining torque is deliver the brakes. */ if (iceTrq < iceTrqMin) { fulPwr = 0.0; } else if (iceTrq > iceTrqMax) { fulPwr = rtInf; } else { /* replacing another coden_interp2 */ b_st.site = &l_emlrtRSI; fulPwr = codegen_interp2(&b_st, par->iceSpdMgd, par->iceTrqMgd, par->iceFulPwr_iceSpd_iceTrq, crsSpd, iceTrq); /* fulPwr = lininterp2(par.iceSpdMgd(1,:), par.iceTrqMgd(:,1), ... */ /* par.iceFulPwr_iceSpd_iceTrq', crsSpd, iceTrq); */ } /* Berechnen der Kraftstoffkraft */ /* calculate fuel force */ fulFrc = fulPwr / vehVel; /* Berechnen der Kraftstoffvolumenänderung */ /* caluclate change in fuel volume - energy, no? */ /* % Ende der Funktion */ } /* FUNCTION CALL */ /* Skalar - Batterieklemmleistung */ /* Skalar - mittlere Geschwindigkeit im Intervall */ /* Skalar - Entladewiderstand */ /* Skalar - Ladewiderstand */ /* Skalar - battery open circuit voltage */ batFrc = batFrcClc_tmp(batPwr, vehVel, par->batRstDch, par->batRstChr, batOcv); /* %% Hamiltonfunktion bestimmen */ /* determine the hamiltonian */ /* Eq (29b) */ crsSpdVec[0] = (fulFrc + psiBatEng * batFrc) + psiTim / vehVel; ixstart = 1; mtmp = crsSpdVec[0]; itmp = 1; if (muDoubleScalarIsNaN(crsSpdVec[0])) { ix = 2; exitg1 = false; while ((!exitg1) && (ix < 3)) { ixstart = 2; if (!muDoubleScalarIsNaN(*cosHamMin)) { mtmp = *cosHamMin; itmp = 2; exitg1 = true; } else { ix = 3; } } } if ((ixstart < 2) && (*cosHamMin < mtmp)) { mtmp = *cosHamMin; itmp = 2; } *cosHamMin = mtmp; /* Wenn der aktuelle Punkt besser ist, als der in cosHamMin */ /* gespeicherte Wert, werden die Ausgabegrößen neu beschrieben. */ /* if the current point is better than the stored cosHamMin value, */ /* then the output values are rewritten (selected prev. value is = 2) */ if (itmp == 1) { *batFrcOut = batFrc; *fulFrcOut = fulFrc; } k++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } } } } } /* end of function */ }
/* Function Definitions */ comm_SDRuTransmitter *SDRuTransmitter_SDRuTransmitter(const emlrtStack *sp, comm_SDRuTransmitter *obj) { comm_SDRuTransmitter *b_obj; comm_SDRuTransmitter *c_obj; int32_T k; real_T varargin_1[10]; int32_T i5; static const char_T cv52[5] = { 'S', 'D', 'R', 'u', '_' }; real_T d0; boolean_T flag; 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; b_obj = obj; st.site = &rj_emlrtRSI; c_obj = b_obj; c_obj->LocalOscillatorOffset = 0.0; c_obj->pSubDevice = TxId; b_st.site = &sj_emlrtRSI; c_st.site = &bb_emlrtRSI; c_st.site = &bb_emlrtRSI; c_obj->isInitialized = FALSE; c_obj->isReleased = FALSE; d_st.site = &cb_emlrtRSI; e_st.site = &db_emlrtRSI; for (k = 0; k < 4; k++) { c_obj->tunablePropertyChanged[k] = FALSE; } f_st.site = &db_emlrtRSI; d_st.site = &cb_emlrtRSI; e_st.site = &db_emlrtRSI; b_st.site = &sj_emlrtRSI; b_st.site = &sj_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &sj_emlrtRSI; c_st.site = &u_emlrtRSI; emlrtRandu(varargin_1, 10); for (k = 0; k < 10; k++) { c_st.site = &v_emlrtRSI; c_st.site = &v_emlrtRSI; d_st.site = &p_emlrtRSI; varargin_1[k] = 48.0 + muDoubleScalarFloor(varargin_1[k] * 10.0); } b_st.site = &sj_emlrtRSI; for (k = 0; k < 10; k++) { i5 = (int32_T)varargin_1[k]; emlrtDynamicBoundsCheckFastR2012b(i5, 0, 255, &i_emlrtBCI, &b_st); } b_st.site = &sj_emlrtRSI; for (k = 0; k < 5; k++) { c_obj->ObjectID[k] = cv52[k]; } for (k = 0; k < 10; k++) { d0 = muDoubleScalarFloor(varargin_1[k]); if (muDoubleScalarIsNaN(d0) || muDoubleScalarIsInf(d0)) { d0 = 0.0; } else { d0 = muDoubleScalarRem(d0, 256.0); } if (d0 < 0.0) { c_obj->ObjectID[k + 5] = (int8_T)-(int8_T)(uint8_T)-d0; } else { c_obj->ObjectID[k + 5] = (int8_T)(uint8_T)d0; } } c_st.site = &db_emlrtRSI; b_st.site = &sj_emlrtRSI; c_st.site = &db_emlrtRSI; d_st.site = &db_emlrtRSI; e_st.site = &db_emlrtRSI; f_st.site = &eg_emlrtRSI; g_st.site = &db_emlrtRSI; h_st.site = &sj_emlrtRSI; checkIPAddressFormat(&h_st); g_st.site = &db_emlrtRSI; d_st.site = &db_emlrtRSI; e_st.site = &ob_emlrtRSI; f_st.site = &db_emlrtRSI; c_obj->CenterFrequency = 2.24E+9; g_st.site = &sj_emlrtRSI; f_st.site = &db_emlrtRSI; if (c_obj->isInitialized && (!c_obj->isReleased)) { flag = TRUE; } else { flag = FALSE; } if (flag) { c_obj->TunablePropsChanged = TRUE; c_obj->tunablePropertyChanged[1] = TRUE; } e_st.site = &ob_emlrtRSI; f_st.site = &db_emlrtRSI; c_obj->InterpolationFactor = 20.0; g_st.site = &rj_emlrtRSI; f_st.site = &db_emlrtRSI; if (c_obj->isInitialized && (!c_obj->isReleased)) { flag = TRUE; } else { flag = FALSE; } if (flag) { c_obj->TunablePropsChanged = TRUE; c_obj->tunablePropertyChanged[0] = TRUE; } e_st.site = &ob_emlrtRSI; f_st.site = &db_emlrtRSI; c_obj->Gain = 25.0; g_st.site = &sj_emlrtRSI; f_st.site = &db_emlrtRSI; if (c_obj->isInitialized && (!c_obj->isReleased)) { flag = TRUE; } else { flag = FALSE; } if (flag) { c_obj->TunablePropsChanged = TRUE; c_obj->tunablePropertyChanged[3] = TRUE; } return b_obj; }
/* Function Definitions */ comm_SDRuReceiver *SDRuReceiver_SDRuReceiver(const emlrtStack *sp, comm_SDRuReceiver *obj, real_T varargin_2, real_T varargin_4, real_T varargin_8) { comm_SDRuReceiver *b_obj; comm_SDRuReceiver *c_obj; real_T varargin_1[10]; int32_T k; int32_T i10; static const char_T cv6[5] = { 'S', 'D', 'R', 'u', '_' }; real_T d1; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; emlrtStack e_st; emlrtStack f_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; b_obj = obj; st.site = &w_emlrtRSI; c_obj = b_obj; c_obj->LocalOscillatorOffset = 0.0; c_obj->pSubDevice = RxId; b_st.site = &j_emlrtRSI; c_st.site = &k_emlrtRSI; d_st.site = &l_emlrtRSI; c_st.site = &k_emlrtRSI; c_obj->isInitialized = 0; d_st.site = &m_emlrtRSI; b_st.site = &j_emlrtRSI; c_st.site = &n_emlrtRSI; b_st.site = &j_emlrtRSI; c_st.site = &o_emlrtRSI; b_rand(varargin_1); for (k = 0; k < 10; k++) { varargin_1[k] = 48.0 + muDoubleScalarFloor(varargin_1[k] * 10.0); } b_st.site = &j_emlrtRSI; for (k = 0; k < 10; k++) { i10 = (int32_T)varargin_1[k]; if (!((i10 >= 0) && (i10 <= 255))) { emlrtDynamicBoundsCheckR2012b(i10, 0, 255, &emlrtBCI, &b_st); } } for (k = 0; k < 5; k++) { c_obj->ObjectID[k] = cv6[k]; } for (k = 0; k < 10; k++) { d1 = muDoubleScalarFloor(varargin_1[k]); if (muDoubleScalarIsNaN(d1) || muDoubleScalarIsInf(d1)) { d1 = 0.0; } else { d1 = muDoubleScalarRem(d1, 256.0); } if (d1 < 0.0) { c_obj->ObjectID[k + 5] = (int8_T)-(int8_T)(uint8_T)-d1; } else { c_obj->ObjectID[k + 5] = (int8_T)(uint8_T)d1; } } b_st.site = &j_emlrtRSI; c_st.site = &l_emlrtRSI; d_st.site = &l_emlrtRSI; e_st.site = &p_emlrtRSI; c_obj->CenterFrequency = varargin_2; e_st.site = &p_emlrtRSI; if (varargin_4 > 512.0) { f_st.site = &w_emlrtRSI; b_warning(&f_st); } c_obj->DecimationFactor = varargin_4; e_st.site = &p_emlrtRSI; c_obj->Gain = varargin_8; e_st.site = &p_emlrtRSI; f_st.site = &j_emlrtRSI; checkIPAddressFormat(&f_st); return b_obj; }