/* Function Definitions */ void JenkinsCompare(JenkinsCompareStackData *SD, const emlrtStack *sp, const real_T x[78596], real_T sampleRate, emxArray_real_T *y) { emlrtStack st; emlrtStack b_st; st.prev = sp; st.tls = sp->tls; st.site = &emlrtRSI; b_st.prev = &st; b_st.tls = st.tls; if (sampleRate < 0.0) { b_st.site = &b_emlrtRSI; eml_error(&b_st); } st.site = &emlrtRSI; melcepst(SD, &st, x, sampleRate, muDoubleScalarFloor(3.0 * muDoubleScalarLog (sampleRate)), y); }
/* 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; }
static void c5_chartstep_c5_testing_Control(SFc5_testing_ControlInstanceStruct *chartInstance) { real_T c5_hoistedGlobal; real_T c5_lambda; uint32_T c5_debug_family_var_map[5]; boolean_T c5_positiveInput; real_T c5_nargin = 1.0; real_T c5_nargout = 1.0; real_T c5_lambda1; real_T c5_x; real_T c5_xk; real_T c5_b_x; real_T c5_c_x; real_T c5_d_x; real_T c5_e_x; real_T c5_f_x; real_T c5_y; real_T c5_g_x; real_T c5_b_y; real_T c5_b; real_T c5_c_y; real_T c5_h_x; real_T c5_i_x; real_T c5_dv0[1]; boolean_T c5_b0; boolean_T c5_b_positiveInput; boolean_T c5_j_x; boolean_T c5_k_x; int32_T c5_k; int32_T c5_tmp_sizes[2]; int32_T c5_iv0[2]; int32_T c5_i0; int32_T c5_i1; int32_T c5_loop_ub; int32_T c5_i2; int32_T c5_tmp_data[1]; int32_T c5_i3; int32_T c5_b_tmp_sizes[2]; int32_T c5_b_tmp_data[1]; int32_T c5_b_loop_ub; int32_T c5_i4; real_T *c5_b_lambda1; real_T *c5_b_lambda; c5_b_lambda1 = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1); c5_b_lambda = (real_T *)ssGetInputPortSignal(chartInstance->S, 0); _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 2U, chartInstance->c5_sfEvent); c5_hoistedGlobal = *c5_b_lambda; c5_lambda = c5_hoistedGlobal; sf_debug_symbol_scope_push_eml(0U, 5U, 5U, c5_debug_family_names, c5_debug_family_var_map); sf_debug_symbol_scope_add_eml_importable(&c5_positiveInput, 0U, c5_b_sf_marshallOut, c5_b_sf_marshallIn); sf_debug_symbol_scope_add_eml_importable(&c5_nargin, 1U, c5_sf_marshallOut, c5_sf_marshallIn); sf_debug_symbol_scope_add_eml_importable(&c5_nargout, 2U, c5_sf_marshallOut, c5_sf_marshallIn); sf_debug_symbol_scope_add_eml(&c5_lambda, 3U, c5_sf_marshallOut); sf_debug_symbol_scope_add_eml_importable(&c5_lambda1, 4U, c5_sf_marshallOut, c5_sf_marshallIn); CV_EML_FCN(0, 0); _SFD_EML_CALL(0U, chartInstance->c5_sfEvent, 15); c5_positiveInput = (c5_lambda > 0.0); _SFD_EML_CALL(0U, chartInstance->c5_sfEvent, 16); c5_x = c5_lambda; c5_xk = c5_x; c5_b_x = c5_xk; c5_c_x = c5_b_x; c5_lambda = c5_c_x / 6.2831853071795862; c5_d_x = c5_lambda; c5_e_x = c5_d_x; c5_e_x = muDoubleScalarRound(c5_e_x); c5_f_x = c5_lambda - c5_e_x; c5_y = muDoubleScalarAbs(c5_f_x); c5_g_x = c5_lambda; c5_b_y = muDoubleScalarAbs(c5_g_x); c5_b = c5_b_y; c5_c_y = 2.2204460492503131E-16 * c5_b; if (c5_y <= c5_c_y) { c5_lambda = 0.0; } else { c5_h_x = c5_lambda; c5_i_x = c5_h_x; c5_i_x = muDoubleScalarFloor(c5_i_x); c5_lambda = (c5_lambda - c5_i_x) * 6.2831853071795862; } _SFD_EML_CALL(0U, chartInstance->c5_sfEvent, 17); c5_dv0[0] = c5_lambda; c5_b0 = (c5_lambda == 0.0); c5_b_positiveInput = c5_positiveInput; c5_j_x = (c5_b0 && c5_b_positiveInput); c5_k_x = c5_j_x; c5_k = 0; if (c5_k_x) { c5_k = 1; } c5_tmp_sizes[0] = 1; c5_iv0[0] = 1; c5_iv0[1] = c5_k; c5_tmp_sizes[1] = c5_iv0[1]; c5_i0 = c5_tmp_sizes[0]; c5_i1 = c5_tmp_sizes[1]; c5_loop_ub = c5_k - 1; for (c5_i2 = 0; c5_i2 <= c5_loop_ub; c5_i2++) { c5_tmp_data[c5_i2] = 0; } for (c5_i3 = 0; c5_i3 < 2; c5_i3++) { c5_b_tmp_sizes[c5_i3] = c5_tmp_sizes[c5_i3]; } if (c5_j_x) { _SFD_EML_ARRAY_BOUNDS_CHECK("", 1, 1, c5_b_tmp_sizes[1], 1, 0); c5_b_tmp_data[0] = 1; } c5_b_loop_ub = c5_b_tmp_sizes[0] * c5_b_tmp_sizes[1] - 1; for (c5_i4 = 0; c5_i4 <= c5_b_loop_ub; c5_i4++) { c5_dv0[c5_b_tmp_data[c5_i4] - 1] = 6.2831853071795862; } c5_lambda = c5_dv0[0]; _SFD_EML_CALL(0U, chartInstance->c5_sfEvent, 18); c5_lambda1 = c5_lambda; _SFD_EML_CALL(0U, chartInstance->c5_sfEvent, -18); sf_debug_symbol_scope_pop(); *c5_b_lambda1 = c5_lambda1; _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 2U, chartInstance->c5_sfEvent); }
/* 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 generateOFDMSignal(const emlrtStack *sp, OFDMDemodulator_1 *iobj_0, OFDMDemodulator_1 *iobj_1, OFDMDemodulator_1 **hPreambleDemod, OFDMDemodulator_1 **hDataDemod, creal_T r[25600], d_struct_T *tx) { OFDMModulator_1 hDataMod; OFDMModulator hPreambleMod; creal_T shortPreambleOFDM[64]; int32_T i; creal_T completeShortPreambleOFDM[160]; creal_T longPreambleOFDM[64]; creal_T completeLongPreambleOFDM[160]; real_T originalData[560]; real_T x[560]; int32_T ib; real_T b_originalData[560]; commcodegen_CRCGenerator_6 hGen; real_T dataWithCRC[563]; commcodegen_BPSKModulator_1 hMod; creal_T modData[563]; real_T varargin_1[13]; int32_T k; commcodegen_BPSKModulator_1 *obj; const mxArray *y; static const int32_T iv54[2] = { 1, 45 }; const mxArray *m10; char_T cv58[45]; static const char_T cv59[45] = { 'M', 'A', 'T', 'L', 'A', 'B', ':', 's', 'y', 's', 't', 'e', 'm', ':', 'm', 'e', 't', 'h', 'o', 'd', 'C', 'a', 'l', 'l', 'e', 'd', 'W', 'h', 'e', 'n', 'R', 'e', 'l', 'e', 'a', 's', 'e', 'd', 'C', 'o', 'd', 'e', 'g', 'e', 'n' }; const mxArray *b_y; static const int32_T iv55[2] = { 1, 4 }; char_T cv60[4]; static const char_T cv61[4] = { 's', 't', 'e', 'p' }; const mxArray *c_y; static const int32_T iv56[2] = { 1, 51 }; char_T cv62[51]; static const char_T cv63[51] = { 'M', 'A', 'T', 'L', 'A', 'B', ':', 's', 'y', 's', 't', 'e', 'm', ':', 'm', 'e', 't', 'h', 'o', 'd', 'C', 'a', 'l', 'l', 'e', 'd', 'W', 'h', 'e', 'n', 'L', 'o', 'c', 'k', 'e', 'd', 'R', 'e', 'l', 'e', 'a', 's', 'e', 'd', 'C', 'o', 'd', 'e', 'g', 'e', 'n' }; const mxArray *d_y; static const int32_T iv57[2] = { 1, 5 }; char_T cv64[5]; static const char_T cv65[5] = { 's', 'e', 't', 'u', 'p' }; static const int8_T value[8] = { 13, 1, 1, 1, 1, 1, 1, 1 }; boolean_T anyInputSizeChanged; boolean_T exitg2; static const int8_T iv58[8] = { 13, 1, 1, 1, 1, 1, 1, 1 }; creal_T varargout_1[13]; creal_T b_modData[576]; creal_T ofdmData[576]; comm_PNSequence_5 hPN; comm_PNSequence_5 *b_obj; static const int8_T iv59[8] = { 1, 0, 0, 0, 1, 0, 0, 1 }; static const int8_T iv60[7] = { 0, 0, 0, 0, 0, 0, 1 }; int8_T pilot[12]; uint8_T tmp; uint8_T tmp2; int8_T pilots[48]; int32_T ia; real_T b_pilots[48]; creal_T b_r[960]; creal_T preambles[320]; creal_T c_r[1280]; OFDMDemodulator_1 *object; int8_T b_data[4]; int32_T exitg1; int32_T exponent; boolean_T b2; int32_T i12; const mxArray *e_y; static const int32_T iv61[2] = { 1, 13 }; char_T cv66[13]; static const char_T cv67[13] = { 'c', 'o', 'm', 'm', ':', 'O', 'F', 'D', 'M', ':', 'x', 'x', 'x' }; static const creal_T dcv3[53] = { { 0.0, 0.0 }, { 0.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { -1.0, -1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { -1.0, -1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { -1.0, -1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { -1.0, -1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { - 1.0, -1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 0.0 }, { 0.0, 0.0 } }; static const int8_T iv62[53] = { 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 0, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1 }; static const int8_T iv63[48] = { 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53 }; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; emlrtStack e_st; emlrtStack f_st; emlrtStack g_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; d_st.prev = &c_st; d_st.tls = c_st.tls; e_st.prev = &d_st; e_st.tls = d_st.tls; f_st.prev = &e_st; f_st.tls = e_st.tls; g_st.prev = &f_st; g_st.tls = f_st.tls; emlrtHeapReferenceStackEnterFcnR2012b(sp); emxInitStruct_OFDMModulator_1(sp, &hDataMod, &s_emlrtRTEI, TRUE); emxInitStruct_OFDMModulator(sp, &hPreambleMod, &t_emlrtRTEI, TRUE); /* generateOFDMSignal: Generate OFDM signal based on the 802.11a standard. */ /* This function returns the time domain signal and a structure containing */ /* details about the signal itself. This information is required by the */ /* receiver to operate correctly. */ /* % System Parameters */ /* OFDM modulator FFT size */ /* Enable moving averages for estimates */ /* 1e3 */ /* Message to transmit */ /* String holder */ /* coder.varsize('payloadMessage', [1, 80], [0 1]); */ /* payloadMessage = ''; */ /* % Create Short Preamble */ /* % [-27:-17] */ /* % [-16:-1] */ /* % [0:15] */ /* [16:27] */ /* % Create modulator */ /* hPreambleMod = OFDMModulator(... */ /* 'NumGuardBandCarriers', [6; 5],... */ /* 'CyclicPrefixLength', 0,... */ /* 'FFTLength' , FFTLength,... */ /* 'NumSymbols', 1); */ /* Create modulator */ st.site = &lk_emlrtRSI; OFDMModulator_OFDMModulator(&hPreambleMod); /* Modulate and scale */ st.site = &mk_emlrtRSI; SystemCore_step(&st, &hPreambleMod, shortPreambleOFDM); st.site = &mk_emlrtRSI; for (i = 0; i < 64; i++) { shortPreambleOFDM[i].re *= 1.4719601443879744; shortPreambleOFDM[i].im *= 1.4719601443879744; } /* Form 10 Short Preambles */ memcpy(&completeShortPreambleOFDM[0], &shortPreambleOFDM[0], sizeof(creal_T) << 6); memcpy(&completeShortPreambleOFDM[64], &shortPreambleOFDM[0], sizeof(creal_T) << 6); memcpy(&completeShortPreambleOFDM[128], &shortPreambleOFDM[0], sizeof(creal_T) << 5); /* % Create Long Preamble */ /* Modulate */ st.site = &nk_emlrtRSI; b_SystemCore_step(&st, &hPreambleMod, longPreambleOFDM); /* Form 2 Long Preambles */ memcpy(&completeLongPreambleOFDM[0], &longPreambleOFDM[32], sizeof(creal_T) << 5); memcpy(&completeLongPreambleOFDM[32], &longPreambleOFDM[0], sizeof(creal_T) << 6); memcpy(&completeLongPreambleOFDM[96], &longPreambleOFDM[0], sizeof(creal_T) << 6); /* % Generate Data */ /* Use string as message */ st.site = &ok_emlrtRSI; b_OFDMletters2bits(&st, originalData); st.site = &pk_emlrtRSI; for (i = 0; i < 80; i++) { for (ib = 0; ib < 7; ib++) { x[ib + 7 * i] = originalData[i + 80 * ib]; } } memcpy(&b_originalData[0], &x[0], 560U * sizeof(real_T)); /* Generate CRC */ st.site = &qk_emlrtRSI; b_CRCGenerator_CRCGenerator(&hGen); st.site = &rk_emlrtRSI; e_SystemCore_step(&st, &hGen, b_originalData, dataWithCRC); /* Add CRC */ /* Construct modulator for each subcarrier */ st.site = &sk_emlrtRSI; BPSKModulator_BPSKModulator(&hMod); /* BPSK */ /* Apply modulator for each subcarrier */ st.site = &tk_emlrtRSI; f_SystemCore_step(&st, &hMod, dataWithCRC, modData); /* Pad IFFT */ st.site = &uk_emlrtRSI; b_st.site = &u_emlrtRSI; emlrtRandu(varargin_1, 13); for (k = 0; k < 13; k++) { b_st.site = &v_emlrtRSI; b_st.site = &v_emlrtRSI; c_st.site = &p_emlrtRSI; varargin_1[k] = muDoubleScalarFloor(varargin_1[k] * 2.0); } st.site = &uk_emlrtRSI; obj = &hMod; if (!obj->isReleased) { } else { y = NULL; m10 = mxCreateCharArray(2, iv54); for (i = 0; i < 45; i++) { cv58[i] = cv59[i]; } emlrtInitCharArrayR2013a(&st, 45, m10, cv58); emlrtAssign(&y, m10); b_y = NULL; m10 = mxCreateCharArray(2, iv55); for (i = 0; i < 4; i++) { cv60[i] = cv61[i]; } emlrtInitCharArrayR2013a(&st, 4, m10, cv60); emlrtAssign(&b_y, m10); b_st.site = &cb_emlrtRSI; c_error(&b_st, message(&b_st, y, b_y, &emlrtMCI), &emlrtMCI); } if (!obj->isInitialized) { b_st.site = &cb_emlrtRSI; if (!obj->isInitialized) { } else { c_y = NULL; m10 = mxCreateCharArray(2, iv56); for (i = 0; i < 51; i++) { cv62[i] = cv63[i]; } emlrtInitCharArrayR2013a(&b_st, 51, m10, cv62); emlrtAssign(&c_y, m10); d_y = NULL; m10 = mxCreateCharArray(2, iv57); for (i = 0; i < 5; i++) { cv64[i] = cv65[i]; } emlrtInitCharArrayR2013a(&b_st, 5, m10, cv64); emlrtAssign(&d_y, m10); c_st.site = &cb_emlrtRSI; c_error(&c_st, message(&c_st, c_y, d_y, &emlrtMCI), &emlrtMCI); } c_st.site = &cb_emlrtRSI; obj->isInitialized = TRUE; d_st.site = &db_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; e_st.site = &db_emlrtRSI; d_st.site = &cb_emlrtRSI; e_st.site = &db_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; e_st.site = &db_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; for (i = 0; i < 8; i++) { obj->inputVarSize1[i] = (uint32_T)value[i]; } e_st.site = &db_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; e_st.site = &cb_emlrtRSI; e_st.site = &cb_emlrtRSI; f_st.site = &gg_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; d_st.site = &cb_emlrtRSI; e_st.site = &gg_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &gg_emlrtRSI; d_st.site = &gg_emlrtRSI; e_st.site = &db_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &gg_emlrtRSI; e_st.site = NULL; } b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &gg_emlrtRSI; b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; anyInputSizeChanged = FALSE; k = 0; exitg2 = FALSE; while ((exitg2 == FALSE) && (k < 8)) { if (obj->inputVarSize1[k] != (uint32_T)iv58[k]) { anyInputSizeChanged = TRUE; c_st.site = &cb_emlrtRSI; for (i = 0; i < 8; i++) { obj->inputVarSize1[i] = (uint32_T)value[i]; } d_st.site = &db_emlrtRSI; exitg2 = TRUE; } else { k++; } } if (anyInputSizeChanged) { b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; } b_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; c_st.site = &cb_emlrtRSI; d_st.site = &gg_emlrtRSI; b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; b_st.site = &cb_emlrtRSI; d_Nondirect_stepImpl(obj, varargin_1, varargout_1); memcpy(&b_modData[0], &modData[0], 563U * sizeof(creal_T)); memcpy(&b_modData[563], &varargout_1[0], 13U * sizeof(creal_T)); /* Calculate required data sizes for correct receiver operation */ /* Save desired message size */ /* Save number of transmitted frames */ /* Convert data into subcarrier streams */ st.site = &vk_emlrtRSI; memcpy(&ofdmData[0], &b_modData[0], 576U * sizeof(creal_T)); /* Create Pilots */ st.site = &wk_emlrtRSI; b_obj = &hPN; /* System object Constructor function: comm.PNSequence */ b_obj->S0_isInitialized = FALSE; b_obj->S1_isReleased = FALSE; for (i = 0; i < 8; i++) { b_obj->P0_Polynomial[i] = (uint8_T)iv59[i]; } for (i = 0; i < 7; i++) { b_obj->P1_IniState[i] = 1; b_obj->P2_Mask[i] = (uint8_T)iv60[i]; } st.site = &xk_emlrtRSI; b_obj = &hPN; if (!b_obj->S0_isInitialized) { b_obj->S0_isInitialized = TRUE; if (b_obj->S1_isReleased) { emlrtErrorWithMessageIdR2012b(&st, &bc_emlrtRTEI, "MATLAB:system:runtimeMethodCalledWhenReleasedCodegen", 0); } b_st.site = NULL; b_st.site = NULL; /* System object Initialization function: comm.PNSequence */ for (ib = 0; ib < 7; ib++) { b_obj->W0_shiftReg[ib] = b_obj->P1_IniState[ib]; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, &b_st); } } b_st.site = NULL; /* System object Outputs function: comm.PNSequence */ for (ib = 0; ib < 12; ib++) { tmp = 0; for (i = 0; i < 7; i++) { tmp = (uint8_T)((uint32_T)tmp + (uint8_T)((uint32_T)b_obj->P0_Polynomial[i + 1] * b_obj->W0_shiftReg[i])); } tmp &= 1; tmp2 = 0; for (i = 0; i < 7; i++) { tmp2 = (uint8_T)((uint32_T)tmp2 + (uint8_T)((uint32_T)b_obj->W0_shiftReg[i] * b_obj->P2_Mask[i])); } pilot[ib] = (int8_T)(tmp2 & 1); for (i = 5; i > -1; i += -1) { b_obj->W0_shiftReg[i + 1] = b_obj->W0_shiftReg[i]; } b_obj->W0_shiftReg[0U] = tmp; } /* Create pilot */ st.site = &yk_emlrtRSI; ib = 0; for (i = 0; i < 4; i++) { ia = 0; for (k = 0; k < 12; k++) { pilots[ib] = pilot[ia]; b_st.site = &ng_emlrtRSI; ia++; b_st.site = &og_emlrtRSI; ib++; } } /* Expand to all pilot tones */ st.site = &al_emlrtRSI; for (i = 0; i < 12; i++) { for (ib = 0; ib < 4; ib++) { b_pilots[ib + (i << 2)] = 2.0 * (real_T)(pilots[i + 12 * ib] < 1) - 1.0; } } /* Bipolar to unipolar */ st.site = &bl_emlrtRSI; for (i = 0; i < 12; i++) { b_pilots[3 + (i << 2)] = -b_pilots[3 + (i << 2)]; } /* Invert last pilot */ /* Construct Modulator */ st.site = &cl_emlrtRSI; b_OFDMModulator_OFDMModulator(&st, &hDataMod); /* Modulate */ st.site = &dl_emlrtRSI; d_SystemCore_step(&st, &hDataMod, ofdmData, b_pilots, b_r); /* Add preambles to data */ memcpy(&preambles[0], &completeShortPreambleOFDM[0], 160U * sizeof(creal_T)); memcpy(&preambles[160], &completeLongPreambleOFDM[0], 160U * sizeof(creal_T)); memcpy(&c_r[0], &preambles[0], 320U * sizeof(creal_T)); memcpy(&c_r[320], &b_r[0], 960U * sizeof(creal_T)); /* Repeat frame */ st.site = &el_emlrtRSI; ib = 0; for (i = 0; i < 20; i++) { ia = 0; for (k = 0; k < 1280; k++) { r[ib] = c_r[ia]; b_st.site = &ng_emlrtRSI; ia++; b_st.site = &og_emlrtRSI; ib++; } } /* Save Demodulator object data for receiver */ /* hDataDemod = get(OFDMDemodulator(hDataMod)); */ /* hPreambleDemod = get(OFDMDemodulator(hPreambleMod)); */ st.site = &fl_emlrtRSI; object = iobj_0; *hDataDemod = object; b_st.site = &jj_emlrtRSI; object = *hDataDemod; c_st.site = &y_emlrtRSI; d_st.site = &bb_emlrtRSI; d_st.site = &bb_emlrtRSI; object->isInitialized = FALSE; object->isReleased = FALSE; e_st.site = &cb_emlrtRSI; f_st.site = &db_emlrtRSI; e_st.site = &cb_emlrtRSI; f_st.site = &db_emlrtRSI; c_st.site = &y_emlrtRSI; c_st.site = &ab_emlrtRSI; b_st.site = &kj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &lj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &mj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &nj_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &oj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &pj_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &qj_emlrtRSI; c_st.site = &db_emlrtRSI; /* OFDMBase Base object for OFDMModulator and OFDMDemodulator System objects */ /* Copyright 2013 The MathWorks, Inc. */ /* FFTLength FFT length */ /* Specify the IFFT length. This property can be set to an integer */ /* scalar. The value must be a power of two. The default value of */ /* this property is 64. */ /* CyclicPrefixLength Cyclic prefix length */ /* Specify the cyclic prefix length. This property can be set to a */ /* non-negative interher scalar. The default value of this property is 16. */ /* NumGuardBandCarriers Number of guard bands */ /* Specify the lower and upper guard bands in frequency domain.This */ /* property can be set to a non-nagative two-element vector. */ /* The default setting of this property is [6 5]. */ /* NumSymbols Number of OFDM symbols */ /* Specify the number of OFDM symbols at the output. The default value */ /* of this property is 1. */ /* PilotCarrierIndices Pilot subcarrier indices */ /* Specify the locations where pilots are to be inserted. You can */ /* set this property to a numeric scalar, column vector, matrix, or */ /* 3-D array. The defalut value of the property is [-21; -7; 7; 21]. */ /* Nontunable ideally */ /* Constructor */ /* validateattributes(fftLen, {'numeric'}, ... */ /* {'real','scalar','integer','finite','>=',8}, ... */ /* [class(obj) '.' propName], propName); */ /* validateattributes(CPLen, {'numeric'}, ... */ /* {'real','row','integer','nonnegative','finite'}, ... */ /* [class(obj) '.' propName], propName); */ /* validateattributes(guardBands, {'numeric'}, ... */ /* {'real','integer','nonnegative','finite','size', [2, 1]}, ... */ /* [class(obj) '.' propName], propName); */ /* validateattributes(numSym, {'numeric'}, ... */ /* {'real','scalar','integer','positive','finite'}, ... */ /* [class(obj) '.' propName], propName); */ /* validateattributes(pilotIdx, {'numeric'}, ... */ /* {'real','integer','positive','finite','3d'}, ... */ /* [class(obj) '.' propName], propName); */ /* Check the 3rd dimension for numTx */ d_st.site = &uh_emlrtRSI; e_st.site = &vh_emlrtRSI; for (k = 0; k < 4; k++) { b_data[k] = (int8_T)(12 + 14 * k); } f_st.site = &mi_emlrtRSI; i = 0; f_st.site = &ki_emlrtRSI; f_st.site = &ji_emlrtRSI; k = 1; while (k <= 4) { ib = b_data[k - 1]; do { exitg1 = 0; f_st.site = &ii_emlrtRSI; k++; if (k > 4) { exitg1 = 1; } else { f_st.site = &hi_emlrtRSI; frexp((real_T)ib / 2.0, &exponent); if (muDoubleScalarAbs(ib - b_data[k - 1]) < ldexp(1.0, exponent - 53)) { anyInputSizeChanged = TRUE; } else { anyInputSizeChanged = FALSE; } if (!anyInputSizeChanged) { exitg1 = 1; } } } while (exitg1 == 0); f_st.site = &gi_emlrtRSI; i++; b_data[i - 1] = (int8_T)ib; f_st.site = &fi_emlrtRSI; f_st.site = &fi_emlrtRSI; } f_st.site = &bi_emlrtRSI; f_st.site = &ai_emlrtRSI; f_st.site = &wh_emlrtRSI; if (1 > i) { b2 = FALSE; } else { b2 = (i > 2147483646); } if (b2) { g_st.site = &bg_emlrtRSI; check_forloop_overflow_error(&g_st); } d_st.site = &uh_emlrtRSI; d_st.site = &uh_emlrtRSI; if (1 > i) { i12 = 0; } else { i12 = i; } if (!(4 != i12)) { } else { e_y = NULL; m10 = mxCreateCharArray(2, iv61); for (i = 0; i < 13; i++) { cv66[i] = cv67[i]; } emlrtInitCharArrayR2013a(&d_st, 13, m10, cv66); emlrtAssign(&e_y, m10); e_st.site = &mv_emlrtRSI; c_error(&e_st, b_message(&e_st, e_y, &g_emlrtMCI), &g_emlrtMCI); } /* Error message: */ /* If pilot index is 2-D, the indices per symbol must be unique; */ /* If pilot index is 3-D, the indices across transmit antennas per symbol must be unique. */ c_st.site = &db_emlrtRSI; st.site = &gl_emlrtRSI; object = iobj_1; *hPreambleDemod = object; b_st.site = &jj_emlrtRSI; object = *hPreambleDemod; c_st.site = &y_emlrtRSI; d_st.site = &bb_emlrtRSI; d_st.site = &bb_emlrtRSI; object->isInitialized = FALSE; object->isReleased = FALSE; e_st.site = &cb_emlrtRSI; f_st.site = &db_emlrtRSI; e_st.site = &cb_emlrtRSI; f_st.site = &db_emlrtRSI; c_st.site = &y_emlrtRSI; c_st.site = &ab_emlrtRSI; b_st.site = &kj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &lj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &mj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &nj_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &oj_emlrtRSI; c_st.site = &db_emlrtRSI; c_st.site = &db_emlrtRSI; b_st.site = &pj_emlrtRSI; c_st.site = &db_emlrtRSI; /* Calcuate OFDM frequency bin size */ /* Calculate locations of pilots without guardbands */ /* Calculate locations of subcarrier datastreams without guardbands */ /* Remove guardband offsets */ /* Remove index offsets for pilots and guardbands */ /* dataSubcarrierIndexies([pilotLocationsWithoutGuardbands;DCNullLocation]) = [];%Remove pilot and DCNull locations */ /* Create return structure */ for (i = 0; i < 560; i++) { tx->originalData[i] = b_originalData[i]; } for (i = 0; i < 64; i++) { tx->shortPreambleOFDM[i] = shortPreambleOFDM[i]; } for (i = 0; i < 160; i++) { tx->completeShortPreambleOFDM[i] = completeShortPreambleOFDM[i]; } for (i = 0; i < 53; i++) { tx->shortPreamble[i] = dcv3[i]; } for (i = 0; i < 53; i++) { tx->longPreamble[i] = iv62[i]; } for (i = 0; i < 64; i++) { tx->longPreambleOFDM[i] = longPreambleOFDM[i]; } for (i = 0; i < 160; i++) { tx->completeLongPreambleOFDM[i] = completeLongPreambleOFDM[i]; } for (i = 0; i < 48; i++) { tx->pilots[i] = b_pilots[i]; } for (i = 0; i < 320; i++) { tx->preambles[i] = preambles[i]; } for (i = 0; i < 4; i++) { tx->pilotLocationsWithoutGuardbands[i] = 6.0 + 14.0 * (real_T)i; } tx->dataSubcarrierIndexies.size[0] = 1; tx->dataSubcarrierIndexies.size[1] = 48; for (i = 0; i < 48; i++) { tx->dataSubcarrierIndexies.data[i] = iv63[i]; } tx->samplingFreq = 5.0E+6; tx->FFTLength = 64.0; tx->enableMA = TRUE; tx->numCarriers = 48.0; tx->padBits = 13.0; tx->numSamples = 576.0; tx->messageCharacters = 80.0; tx->numFrames = 20.0; tx->frameLength = 1280.0; tx->freqBin = 78125.0; tx->DecimationFactor = 0.0; tx->receiveBufferLength = 0.0; /* padBits: 13 */ /* numSamples: 576 */ /* messageCharacters: 80 */ /* numFrames: 1000 */ /* frameLength: 1280 */ /* freqBin: 312500 */ /* hDataDemod: [1x1 struct] */ /* hPreambleDemod: [1x1 struct] */ st.site = NULL; b_Destructor(&hPN); emxFreeStruct_OFDMModulator(&hPreambleMod); emxFreeStruct_OFDMModulator_1(&hDataMod); emlrtHeapReferenceStackLeaveFcnR2012b(sp); }
static void sf_c2_controller1(SFc2_controller1InstanceStruct *chartInstance) { int32_T c2_previousEvent; real_T c2_hoistedGlobal; real_T c2_u; uint32_T c2_debug_family_var_map[4]; real_T c2_nargin = 1.0; real_T c2_nargout = 1.0; real_T c2_y; real_T c2_x; real_T c2_b_x; real_T c2_b_y; real_T c2_c_x; real_T c2_xk; real_T c2_d_x; real_T c2_e_x; real_T c2_f_x; real_T *c2_b_u; real_T *c2_c_y; c2_c_y = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1); c2_b_u = (real_T *)ssGetInputPortSignal(chartInstance->S, 0); _sfTime_ = (real_T)ssGetT(chartInstance->S); _SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 1); _SFD_DATA_RANGE_CHECK(*c2_b_u, 0U); _SFD_DATA_RANGE_CHECK(*c2_c_y, 1U); c2_previousEvent = _sfEvent_; _sfEvent_ = CALL_EVENT; _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 1); c2_hoistedGlobal = *c2_b_u; c2_u = c2_hoistedGlobal; sf_debug_symbol_scope_push_eml(0U, 4U, 4U, c2_debug_family_names, c2_debug_family_var_map); sf_debug_symbol_scope_add_eml(&c2_nargin, c2_sf_marshall, 0U); sf_debug_symbol_scope_add_eml(&c2_nargout, c2_sf_marshall, 1U); sf_debug_symbol_scope_add_eml(&c2_u, c2_sf_marshall, 2U); sf_debug_symbol_scope_add_eml(&c2_y, c2_sf_marshall, 3U); CV_EML_FCN(0, 0); _SFD_EML_CALL(0, 2); c2_x = c2_u; c2_b_x = c2_x; c2_b_y = muDoubleScalarAbs(c2_b_x); if (CV_EML_IF(0, 0, c2_b_y > 90.0)) { _SFD_EML_CALL(0, 3); c2_c_x = c2_u; c2_eml_scalar_eg(chartInstance); c2_xk = c2_c_x; c2_d_x = c2_xk; c2_eml_scalar_eg(chartInstance); c2_e_x = c2_d_x / 90.0; c2_f_x = c2_e_x; c2_f_x = muDoubleScalarFloor(c2_f_x); c2_u = c2_d_x - c2_f_x * 90.0; } _SFD_EML_CALL(0, 5); c2_y = c2_u; _SFD_EML_CALL(0, -5); sf_debug_symbol_scope_pop(); *c2_c_y = c2_y; _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 1); _sfEvent_ = c2_previousEvent; sf_debug_check_for_state_inconsistency(_controller1MachineNumber_, chartInstance->chartNumber, chartInstance->instanceNumber); }
/* 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 */ }
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 */ real_T compressedindex(const emlrtStack *sp, const emxArray_real_T *x, const emxArray_real_T *ctable, real_T range, real_T dims) { real_T y; real_T py; int32_T i; int32_T i2; int32_T i3; real_T d4; int32_T k; int32_T vlen; boolean_T p; boolean_T b_p; int32_T exitg1; int32_T b_k; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; emlrtStack e_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; d_st.prev = &c_st; d_st.tls = c_st.tls; e_st.prev = &d_st; e_st.tls = d_st.tls; /* for a given vector, find its index within the transition space matrix */ /* workspace; */ py = 1.0; range++; emlrtForLoopVectorCheckR2012b(1.0, 1.0, dims - 2.0, mxDOUBLE_CLASS, (int32_T) (dims - 2.0), (emlrtRTEInfo *)&o_emlrtRTEI, sp); i = 0; while (i <= (int32_T)(dims - 2.0) - 1) { i2 = x->size[1]; if (!((i + 1 >= 1) && (i + 1 <= i2))) { emlrtDynamicBoundsCheckR2012b(i + 1, 1, i2, (emlrtBCInfo *)&bb_emlrtBCI, sp); } if (x->data[i] == 0.0) { } else { i2 = x->size[1]; if (!((i + 1 >= 1) && (i + 1 <= i2))) { emlrtDynamicBoundsCheckR2012b(i + 1, 1, i2, (emlrtBCInfo *)&cb_emlrtBCI, sp); } d4 = range - (x->data[i] - 1.0); if (d4 > range) { i3 = 1; i2 = 1; } else { if (d4 != (int32_T)muDoubleScalarFloor(d4)) { emlrtIntegerCheckR2012b(d4, (emlrtDCInfo *)&k_emlrtDCI, sp); } i2 = ctable->size[0]; i3 = (int32_T)d4; if (!((i3 >= 1) && (i3 <= i2))) { emlrtDynamicBoundsCheckR2012b(i3, 1, i2, (emlrtBCInfo *)&x_emlrtBCI, sp); } if (range != (int32_T)muDoubleScalarFloor(range)) { emlrtIntegerCheckR2012b(range, (emlrtDCInfo *)&k_emlrtDCI, sp); } i2 = ctable->size[0]; k = (int32_T)range; if (!((k >= 1) && (k <= i2))) { emlrtDynamicBoundsCheckR2012b(k, 1, i2, (emlrtBCInfo *)&x_emlrtBCI, sp); } i2 = k + 1; } st.site = &l_emlrtRSI; d4 = dims - (1.0 + (real_T)i); if (d4 != (int32_T)muDoubleScalarFloor(d4)) { emlrtIntegerCheckR2012b(d4, (emlrtDCInfo *)&l_emlrtDCI, &st); } k = ctable->size[1]; vlen = (int32_T)d4; if (!((vlen >= 1) && (vlen <= k))) { emlrtDynamicBoundsCheckR2012b(vlen, 1, k, (emlrtBCInfo *)&y_emlrtBCI, &st); } b_st.site = &m_emlrtRSI; if ((i2 - i3 == 1) || (i2 - i3 != 1)) { p = true; } else { p = false; } if (p) { } else { emlrtErrorWithMessageIdR2012b(&b_st, &p_emlrtRTEI, "Coder:toolbox:autoDimIncompatibility", 0); } p = false; b_p = false; k = 0; do { exitg1 = 0; if (k < 2) { if (k + 1 <= 1) { b_k = i2 - i3; } else { b_k = 1; } if (b_k != 0) { exitg1 = 1; } else { k++; } } else { b_p = true; exitg1 = 1; } } while (exitg1 == 0); if (!b_p) { } else { p = true; } if (!p) { } else { emlrtErrorWithMessageIdR2012b(&b_st, &q_emlrtRTEI, "Coder:toolbox:UnsupportedSpecialEmpty", 0); } c_st.site = &n_emlrtRSI; if (i2 - i3 == 0) { y = 0.0; } else { vlen = i2 - i3; y = ctable->data[(i3 + ctable->size[0] * ((int32_T)(dims - (1.0 + (real_T)i)) - 1)) - 1]; d_st.site = &o_emlrtRSI; if ((!(2 > i2 - i3)) && (i2 - i3 > 2147483646)) { e_st.site = &j_emlrtRSI; check_forloop_overflow_error(&e_st); } for (k = 0; k + 2 <= vlen; k++) { y += ctable->data[(i3 + k) + ctable->size[0] * ((int32_T)(dims - (1.0 + (real_T)i)) - 1)]; } } py += y; i2 = x->size[1]; if (!((i + 1 >= 1) && (i + 1 <= i2))) { emlrtDynamicBoundsCheckR2012b(i + 1, 1, i2, (emlrtBCInfo *)&db_emlrtBCI, sp); } range -= x->data[i]; } i++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } i2 = x->size[1]; i3 = x->size[1] - 1; if (!((i3 >= 1) && (i3 <= i2))) { emlrtDynamicBoundsCheckR2012b(i3, 1, i2, (emlrtBCInfo *)&ab_emlrtBCI, sp); } return py + x->data[i3 - 1]; }
/* Function Definitions */ void 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 {
/* 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); }
/* Function Definitions */ real_T b_mod(real_T x) { return x - muDoubleScalarFloor(x / 2.0) * 2.0; }
/* 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; }
/* Function Definitions */ void b_floor(real_T *x) { *x = muDoubleScalarFloor(*x); }
static void sf_gateway_c45_Expriment_Gaze(SFc45_Expriment_GazeInstanceStruct *chartInstance) { real_T c45_hoistedGlobal; real_T c45_b_hoistedGlobal; real_T c45_c_hoistedGlobal; real_T c45_d_hoistedGlobal; real_T c45_e_hoistedGlobal; real_T c45_f_hoistedGlobal; real_T c45_r1; real_T c45_r2; real_T c45_r3; real_T c45_r4; real_T c45_r5; real_T c45_r6; uint32_T c45_debug_family_var_map[9]; real_T c45_nargin = 6.0; real_T c45_nargout = 1.0; real_T c45_y[6]; int32_T c45_i2; real_T c45_x; real_T c45_b_x; real_T c45_c_x; real_T c45_d_x; real_T c45_e_x; real_T c45_f_x; real_T c45_g_x; real_T c45_h_x; real_T c45_i_x; real_T c45_j_x; real_T c45_k_x; real_T c45_l_x; int32_T c45_i3; int32_T c45_i4; real_T *c45_b_r1; real_T *c45_b_r2; real_T *c45_b_r3; real_T *c45_b_r4; real_T *c45_b_r5; real_T *c45_b_r6; real_T (*c45_b_y)[6]; c45_b_r6 = (real_T *)ssGetInputPortSignal(chartInstance->S, 5); c45_b_r5 = (real_T *)ssGetInputPortSignal(chartInstance->S, 4); c45_b_r4 = (real_T *)ssGetInputPortSignal(chartInstance->S, 3); c45_b_r3 = (real_T *)ssGetInputPortSignal(chartInstance->S, 2); c45_b_r2 = (real_T *)ssGetInputPortSignal(chartInstance->S, 1); c45_b_y = (real_T (*)[6])ssGetOutputPortSignal(chartInstance->S, 1); c45_b_r1 = (real_T *)ssGetInputPortSignal(chartInstance->S, 0); _SFD_SYMBOL_SCOPE_PUSH(0U, 0U); _sfTime_ = sf_get_time(chartInstance->S); _SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 25U, chartInstance->c45_sfEvent); _SFD_DATA_RANGE_CHECK(*c45_b_r1, 0U); chartInstance->c45_sfEvent = CALL_EVENT; _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 25U, chartInstance->c45_sfEvent); c45_hoistedGlobal = *c45_b_r1; c45_b_hoistedGlobal = *c45_b_r2; c45_c_hoistedGlobal = *c45_b_r3; c45_d_hoistedGlobal = *c45_b_r4; c45_e_hoistedGlobal = *c45_b_r5; c45_f_hoistedGlobal = *c45_b_r6; c45_r1 = c45_hoistedGlobal; c45_r2 = c45_b_hoistedGlobal; c45_r3 = c45_c_hoistedGlobal; c45_r4 = c45_d_hoistedGlobal; c45_r5 = c45_e_hoistedGlobal; c45_r6 = c45_f_hoistedGlobal; _SFD_SYMBOL_SCOPE_PUSH_EML(0U, 9U, 9U, c45_debug_family_names, c45_debug_family_var_map); _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c45_nargin, 0U, c45_b_sf_marshallOut, c45_b_sf_marshallIn); _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c45_nargout, 1U, c45_b_sf_marshallOut, c45_b_sf_marshallIn); _SFD_SYMBOL_SCOPE_ADD_EML(&c45_r1, 2U, c45_b_sf_marshallOut); _SFD_SYMBOL_SCOPE_ADD_EML(&c45_r2, 3U, c45_b_sf_marshallOut); _SFD_SYMBOL_SCOPE_ADD_EML(&c45_r3, 4U, c45_b_sf_marshallOut); _SFD_SYMBOL_SCOPE_ADD_EML(&c45_r4, 5U, c45_b_sf_marshallOut); _SFD_SYMBOL_SCOPE_ADD_EML(&c45_r5, 6U, c45_b_sf_marshallOut); _SFD_SYMBOL_SCOPE_ADD_EML(&c45_r6, 7U, c45_b_sf_marshallOut); _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(c45_y, 8U, c45_sf_marshallOut, c45_sf_marshallIn); CV_EML_FCN(0, 0); _SFD_EML_CALL(0U, chartInstance->c45_sfEvent, 3); for (c45_i2 = 0; c45_i2 < 6; c45_i2++) { c45_y[c45_i2] = 0.0; } _SFD_EML_CALL(0U, chartInstance->c45_sfEvent, 4); c45_x = c45_r1; c45_b_x = c45_x; c45_b_x = muDoubleScalarFloor(c45_b_x); c45_y[0] = c45_b_x; _SFD_EML_CALL(0U, chartInstance->c45_sfEvent, 5); c45_c_x = c45_r2; c45_d_x = c45_c_x; c45_d_x = muDoubleScalarFloor(c45_d_x); c45_y[1] = c45_d_x; _SFD_EML_CALL(0U, chartInstance->c45_sfEvent, 6); c45_e_x = c45_r3; c45_f_x = c45_e_x; c45_f_x = muDoubleScalarFloor(c45_f_x); c45_y[2] = c45_f_x; _SFD_EML_CALL(0U, chartInstance->c45_sfEvent, 7); c45_g_x = c45_r4; c45_h_x = c45_g_x; c45_h_x = muDoubleScalarFloor(c45_h_x); c45_y[3] = c45_h_x; _SFD_EML_CALL(0U, chartInstance->c45_sfEvent, 8); c45_i_x = c45_r5; c45_j_x = c45_i_x; c45_j_x = muDoubleScalarFloor(c45_j_x); c45_y[4] = c45_j_x; _SFD_EML_CALL(0U, chartInstance->c45_sfEvent, 9); c45_k_x = c45_r6; c45_l_x = c45_k_x; c45_l_x = muDoubleScalarFloor(c45_l_x); c45_y[5] = c45_l_x; _SFD_EML_CALL(0U, chartInstance->c45_sfEvent, -9); _SFD_SYMBOL_SCOPE_POP(); for (c45_i3 = 0; c45_i3 < 6; c45_i3++) { (*c45_b_y)[c45_i3] = c45_y[c45_i3]; } _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 25U, chartInstance->c45_sfEvent); _SFD_SYMBOL_SCOPE_POP(); _SFD_CHECK_FOR_STATE_INCONSISTENCY(_Expriment_GazeMachineNumber_, chartInstance->chartNumber, chartInstance->instanceNumber); for (c45_i4 = 0; c45_i4 < 6; c45_i4++) { _SFD_DATA_RANGE_CHECK((*c45_b_y)[c45_i4], 1U); } _SFD_DATA_RANGE_CHECK(*c45_b_r2, 2U); _SFD_DATA_RANGE_CHECK(*c45_b_r3, 3U); _SFD_DATA_RANGE_CHECK(*c45_b_r4, 4U); _SFD_DATA_RANGE_CHECK(*c45_b_r5, 5U); _SFD_DATA_RANGE_CHECK(*c45_b_r6, 6U); }
/* Function Definitions */ void compmat(const emlrtStack *sp, const emxArray_uint8_T *x, real_T dims, emxArray_real_T *y) { int32_T i1; real_T d3; int32_T ii; int32_T i; emxArray_boolean_T *b_x; emxArray_int32_T *b_ii; int32_T nx; int32_T idx; boolean_T overflow; boolean_T exitg1; boolean_T guard1 = false; emlrtStack st; emlrtStack b_st; emlrtStack c_st; emlrtStack d_st; st.prev = sp; st.tls = sp->tls; b_st.prev = &st; b_st.tls = st.tls; c_st.prev = &b_st; c_st.tls = b_st.tls; d_st.prev = &c_st; d_st.tls = c_st.tls; emlrtHeapReferenceStackEnterFcnR2012b(sp); /* UNTITLED Summary of this function goes here */ /* Detailed explanation goes here */ i1 = y->size[0] * y->size[1]; y->size[0] = 1; if (!(dims >= 0.0)) { emlrtNonNegativeCheckR2012b(dims, (emlrtDCInfo *)&j_emlrtDCI, sp); } d3 = dims; if (d3 != (int32_T)muDoubleScalarFloor(d3)) { emlrtIntegerCheckR2012b(d3, (emlrtDCInfo *)&i_emlrtDCI, sp); } y->size[1] = (int32_T)d3; emxEnsureCapacity(sp, (emxArray__common *)y, i1, (int32_T)sizeof(real_T), &f_emlrtRTEI); if (!(dims >= 0.0)) { emlrtNonNegativeCheckR2012b(dims, (emlrtDCInfo *)&j_emlrtDCI, sp); } if (d3 != (int32_T)muDoubleScalarFloor(d3)) { emlrtIntegerCheckR2012b(d3, (emlrtDCInfo *)&i_emlrtDCI, sp); } ii = (int32_T)d3; for (i1 = 0; i1 < ii; i1++) { y->data[i1] = 0.0; } emlrtForLoopVectorCheckR2012b(1.0, 1.0, dims, mxDOUBLE_CLASS, (int32_T)dims, (emlrtRTEInfo *)&n_emlrtRTEI, sp); i = 0; emxInit_boolean_T(sp, &b_x, 2, &f_emlrtRTEI, true); emxInit_int32_T(sp, &b_ii, 2, &g_emlrtRTEI, true); while (i <= (int32_T)dims - 1) { st.site = &k_emlrtRSI; i1 = b_x->size[0] * b_x->size[1]; b_x->size[0] = 1; b_x->size[1] = x->size[1]; emxEnsureCapacity(&st, (emxArray__common *)b_x, i1, (int32_T)sizeof (boolean_T), &f_emlrtRTEI); ii = x->size[0] * x->size[1]; for (i1 = 0; i1 < ii; i1++) { b_x->data[i1] = (x->data[i1] == 1.0 + (real_T)i); } b_st.site = &h_emlrtRSI; nx = b_x->size[1]; idx = 0; i1 = b_ii->size[0] * b_ii->size[1]; b_ii->size[0] = 1; b_ii->size[1] = b_x->size[1]; emxEnsureCapacity(&b_st, (emxArray__common *)b_ii, i1, (int32_T)sizeof (int32_T), &f_emlrtRTEI); c_st.site = &i_emlrtRSI; overflow = ((!(1 > b_x->size[1])) && (b_x->size[1] > 2147483646)); if (overflow) { d_st.site = &j_emlrtRSI; check_forloop_overflow_error(&d_st); } ii = 1; exitg1 = false; while ((!exitg1) && (ii <= nx)) { guard1 = false; if (b_x->data[ii - 1]) { idx++; b_ii->data[idx - 1] = ii; if (idx >= nx) { exitg1 = true; } else { guard1 = true; } } else { guard1 = true; } if (guard1) { ii++; } } if (idx <= b_x->size[1]) { } else { emlrtErrorWithMessageIdR2012b(&b_st, &k_emlrtRTEI, "Coder:builtins:AssertionFailed", 0); } if (b_x->size[1] == 1) { if (idx == 0) { i1 = b_ii->size[0] * b_ii->size[1]; b_ii->size[0] = 1; b_ii->size[1] = 0; emxEnsureCapacity(&b_st, (emxArray__common *)b_ii, i1, (int32_T)sizeof (int32_T), &f_emlrtRTEI); } } else { i1 = b_ii->size[0] * b_ii->size[1]; if (1 > idx) { b_ii->size[1] = 0; } else { b_ii->size[1] = idx; } emxEnsureCapacity(&b_st, (emxArray__common *)b_ii, i1, (int32_T)sizeof (int32_T), &b_emlrtRTEI); } i1 = y->size[1]; if (!((i + 1 >= 1) && (i + 1 <= i1))) { emlrtDynamicBoundsCheckR2012b(i + 1, 1, i1, (emlrtBCInfo *)&w_emlrtBCI, sp); } y->data[i] = b_ii->size[1]; i++; if (*emlrtBreakCheckR2012bFlagVar != 0) { emlrtBreakCheckR2012b(sp); } } emxFree_int32_T(&b_ii); emxFree_boolean_T(&b_x); emlrtHeapReferenceStackLeaveFcnR2012b(sp); }
static void sf_c5_YCbCrTesting(SFc5_YCbCrTestingInstanceStruct *chartInstance) { int32_T c5_cbits; uint32_T c5_in[20]; real32_T c5_out[64]; int32_T c5_b_cbits; real_T c5_inpos; uint32_T c5_Temp; uint32_T c5_run; uint32_T c5_val; uint32_T c5_b_Temp; real_T c5_i; boolean_T c5_exitg1; uint32_T c5_b_run; real_T c5_b_inpos; real_T c5_flag; uint32_T c5_b_val; int32_T c5_j; real32_T (*c5_b_out)[64]; uint32_T (*c5_b_in)[20]; c5_b_out = (real32_T (*)[64])ssGetOutputPortSignal(chartInstance->S, 1); c5_b_in = (uint32_T (*)[20])ssGetInputPortSignal(chartInstance->S, 0); _sfTime_ = (real_T)ssGetT(chartInstance->S); for (c5_cbits = 0; c5_cbits < 20; c5_cbits++) { c5_in[c5_cbits] = (*c5_b_in)[c5_cbits]; } chartInstance->c5_prev_out_not_empty = TRUE; for (c5_cbits = 0; c5_cbits < 64; c5_cbits++) { c5_out[c5_cbits] = chartInstance->c5_prev_out[c5_cbits]; } c5_b_cbits = 0; c5_inpos = 2.0; c5_Temp = 0U; c5_run = 0U; c5_val = 0U; if (((*c5_b_in)[0] & 2147483648U) != 0U) { c5_b_Temp = MAX_uint32_T - (*c5_b_in)[0]; if (c5_b_Temp > 2147483647U) { c5_b_Temp = 2147483647U; } c5_out[0] = (real32_T)(-(int32_T)c5_b_Temp - 1); } else { c5_b_Temp = (*c5_b_in)[0]; if (c5_b_Temp > 2147483647U) { c5_b_Temp = 2147483647U; } c5_out[0] = (real32_T)c5_b_Temp; } c5_i = 2.0; c5_exitg1 = 0U; while ((c5_exitg1 == 0U) && (c5_i <= 64.0)) { c5_getbits(chartInstance, c5_b_cbits, c5_inpos, c5_Temp, c5_in, c5_run, 4.0, &c5_flag, &c5_cbits, &c5_b_inpos, &c5_b_Temp, &c5_b_run); c5_run = c5_b_run; if ((!(c5_flag != 0.0)) || (c5_b_run == 15U)) { c5_exitg1 = 1U; } else { c5_getbits(chartInstance, c5_cbits, c5_b_inpos, c5_b_Temp, c5_in, c5_val, 8.0, &c5_flag, &c5_b_cbits, &c5_inpos, &c5_Temp, &c5_b_val); c5_val = c5_b_val; if (!(c5_flag != 0.0)) { c5_exitg1 = 1U; } else { c5_flag = (real_T)c5_b_run + c5_i; c5_flag = muDoubleScalarFloor(c5_flag + 0.5); if (c5_flag < 4.294967296E+9) { c5_b_Temp = (uint32_T)c5_flag; } else { c5_b_Temp = MAX_uint32_T; } if (c5_b_Temp > 64U) { c5_cbits = 64; } else { c5_cbits = (int32_T)c5_b_Temp; } c5_j = (int32_T)c5_i; while ((uint32_T)c5_j <= (uint32_T)c5_cbits) { c5_out[c5_j - 1] = (real32_T)c5_b_val - 128.0F; c5_j = (int32_T)((uint32_T)c5_j + 1U); sf_mex_listen_for_ctrl_c(chartInstance->S); } c5_i = (c5_i + (real_T)c5_b_run) + 1.0; sf_mex_listen_for_ctrl_c(chartInstance->S); } } } while (c5_i <= 64.0) { c5_out[(int32_T)c5_i - 1] = 0.0F; c5_i++; sf_mex_listen_for_ctrl_c(chartInstance->S); } for (c5_cbits = 0; c5_cbits < 64; c5_cbits++) { chartInstance->c5_prev_out[c5_cbits] = c5_out[c5_cbits]; (*c5_b_out)[c5_cbits] = c5_out[c5_cbits]; } }
/* 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 */ void OFDMbits2letters(const emlrtStack *sp, const boolean_T bits_data[560], const int32_T bits_size[2], real_T Letters_data[80], int32_T Letters_size[1]) { real_T a; int32_T i32; int32_T i33; boolean_T p; const mxArray *y; static const int32_T iv237[2] = { 1, 28 }; const mxArray *m43; char_T cv284[28]; int32_T i; static const char_T cv285[28] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T', 'L', 'A', 'B', ':', 'N', 'o', 'n', 'I', 'n', 't', 'e', 'g', 'e', 'r', 'I', 'n', 'p', 'u', 't' }; const mxArray *b_y; const mxArray *c_y; int32_T maxdimlen; boolean_T y_data[560]; const mxArray *d_y; static const int32_T iv238[2] = { 1, 40 }; char_T cv286[40]; static const char_T cv287[40] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T', 'L', 'A', 'B', ':', 'g', 'e', 't', 'R', 'e', 's', 'h', 'a', 'p', 'e', 'D', 'i', 'm', 's', '_', 'n', 'o', 't', 'S', 'a', 'm', 'e', 'N', 'u', 'm', 'e', 'l' }; boolean_T b_bits_data[560]; char_T s[7]; int32_T exitg1; const mxArray *e_y; static const int32_T iv239[2] = { 1, 34 }; char_T cv288[34]; static const char_T cv289[34] = { 'M', 'A', 'T', 'L', 'A', 'B', ':', 'b', 'i', 'n', '2', 'd', 'e', 'c', ':', 'I', 'l', 'l', 'e', 'g', 'a', 'l', 'B', 'i', 'n', 'a', 'r', 'y', 'S', 't', 'r', 'i', 'n', 'g' }; real_T varargin_1; real_T p2; 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 = &b_st; d_st.tls = b_st.tls; e_st.prev = &st; e_st.tls = st.tls; /* OFDMbits2letters: Convert input bits from a double array to ascii */ /* integers, which can be converted to letters by the char() function */ /* Make input into column */ /* Trim extra bits */ st.site = &qab_emlrtRSI; st.site = &qab_emlrtRSI; b_st.site = &m_emlrtRSI; c_st.site = &n_emlrtRSI; a = (real_T)(bits_size[0] * bits_size[1]) / 7.0; st.site = &qab_emlrtRSI; b_floor(&a); st.site = &qab_emlrtRSI; a *= 7.0; if (1.0 > a) { i32 = 0; } else { i32 = bits_size[0] * bits_size[1]; emlrtDynamicBoundsCheckFastR2012b(1, 1, i32, &rb_emlrtBCI, sp); i32 = bits_size[0] * bits_size[1]; i33 = (int32_T)a; i32 = emlrtDynamicBoundsCheckFastR2012b(i33, 1, i32, &rb_emlrtBCI, sp); } emlrtVectorVectorIndexCheckR2012b(bits_size[0] * bits_size[1], 1, 1, i32, &x_emlrtECI, sp); /* Shape into letters */ st.site = &rab_emlrtRSI; st.site = &rab_emlrtRSI; b_st.site = &m_emlrtRSI; c_st.site = &n_emlrtRSI; a = (real_T)i32 / 7.0; st.site = &rab_emlrtRSI; b_st.site = &tab_emlrtRSI; c_st.site = &uab_emlrtRSI; if (a != muDoubleScalarFloor(a)) { p = FALSE; } else { p = TRUE; } if (p) { c_st.site = &uab_emlrtRSI; p = TRUE; } else { p = FALSE; } if (p) { } else { y = NULL; m43 = mxCreateCharArray(2, iv237); for (i = 0; i < 28; i++) { cv284[i] = cv285[i]; } emlrtInitCharArrayR2013a(&b_st, 28, m43, cv284); emlrtAssign(&y, m43); b_y = NULL; m43 = mxCreateNumericMatrix(1, 1, mxINT32_CLASS, mxREAL); *(int32_T *)mxGetData(m43) = MIN_int32_T; emlrtAssign(&b_y, m43); c_y = NULL; m43 = mxCreateNumericMatrix(1, 1, mxINT32_CLASS, mxREAL); *(int32_T *)mxGetData(m43) = MAX_int32_T; emlrtAssign(&c_y, m43); c_st.site = &uab_emlrtRSI; d_st.site = &bcb_emlrtRSI; c_error(&c_st, c_message(&d_st, y, b_y, c_y, &ac_emlrtMCI), &bc_emlrtMCI); } c_st.site = &ny_emlrtRSI; c_st.site = &ny_emlrtRSI; b_st.site = &ky_emlrtRSI; c_st.site = &af_emlrtRSI; maxdimlen = i32; if (1 > i32) { maxdimlen = 1; } b_st.site = &ky_emlrtRSI; c_st.site = &af_emlrtRSI; if (i32 < maxdimlen) { } else { maxdimlen = i32; } if (7 > maxdimlen) { b_st.site = &jy_emlrtRSI; c_eml_error(&b_st); } if ((int8_T)(int32_T)a > maxdimlen) { b_st.site = &jy_emlrtRSI; c_eml_error(&b_st); } b_st.site = &iy_emlrtRSI; c_st.site = &v_emlrtRSI; if (i32 == 7 * (int32_T)a) { } else { d_y = NULL; m43 = mxCreateCharArray(2, iv238); for (i = 0; i < 40; i++) { cv286[i] = cv287[i]; } emlrtInitCharArrayR2013a(&st, 40, m43, cv286); emlrtAssign(&d_y, m43); b_st.site = &iy_emlrtRSI; e_st.site = &rbb_emlrtRSI; c_error(&b_st, b_message(&e_st, d_y, &tb_emlrtMCI), &ub_emlrtMCI); } b_st.site = &hy_emlrtRSI; c_st.site = &dg_emlrtRSI; for (maxdimlen = 0; maxdimlen + 1 <= i32; maxdimlen++) { y_data[maxdimlen] = bits_data[maxdimlen]; } for (i32 = 0; i32 < 7; i32++) { maxdimlen = (int32_T)a; for (i33 = 0; i33 < maxdimlen; i33++) { b_bits_data[i33 + (int32_T)a * i32] = y_data[i32 + 7 * i33]; } } /* Convert bits to letters */ Letters_size[0] = (int32_T)a; maxdimlen = (int32_T)a; for (i32 = 0; i32 < maxdimlen; i32++) { Letters_data[i32] = 0.0; } i = 0; while (i <= (int32_T)a - 1) { st.site = &sab_emlrtRSI; i32 = (int32_T)a; i33 = 1 + i; emlrtDynamicBoundsCheckFastR2012b(i33, 1, i32, &qb_emlrtBCI, &st); b_st.site = &of_emlrtRSI; b_st.site = &vab_emlrtRSI; for (maxdimlen = 0; maxdimlen < 7; maxdimlen++) { s[maxdimlen] = '0'; if (b_bits_data[i + (int32_T)a * maxdimlen]) { s[maxdimlen] = '1'; } } st.site = &sab_emlrtRSI; b_st.site = &wab_emlrtRSI; maxdimlen = 0; do { exitg1 = 0; if (maxdimlen < 7) { if ((s[maxdimlen] != '0') && (s[maxdimlen] != '1')) { p = FALSE; exitg1 = 1; } else { maxdimlen++; } } else { p = TRUE; exitg1 = 1; } } while (exitg1 == 0); if (p) { } else { e_y = NULL; m43 = mxCreateCharArray(2, iv239); for (maxdimlen = 0; maxdimlen < 34; maxdimlen++) { cv288[maxdimlen] = cv289[maxdimlen]; } emlrtInitCharArrayR2013a(&st, 34, m43, cv288); emlrtAssign(&e_y, m43); b_st.site = &wab_emlrtRSI; e_st.site = &qbb_emlrtRSI; c_error(&b_st, b_message(&e_st, e_y, &cc_emlrtMCI), &dc_emlrtMCI); } b_st.site = &xab_emlrtRSI; varargin_1 = 0.0; p2 = 1.0; for (maxdimlen = 0; maxdimlen < 7; maxdimlen++) { if (s[6 - maxdimlen] == '1') { varargin_1 += p2; } p2 += p2; } st.site = &sab_emlrtRSI; i32 = (int32_T)varargin_1; emlrtDynamicBoundsCheckFastR2012b(i32, 0, 255, &emlrtBCI, &st); i32 = (int32_T)a; i33 = 1 + i; Letters_data[emlrtDynamicBoundsCheckFastR2012b(i33, 1, i32, &sb_emlrtBCI, sp) - 1] = (int8_T)varargin_1; i++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, sp); } }
static void sf_gateway_c2_Demo_AU_VA1(SFc2_Demo_AU_VA1InstanceStruct *chartInstance) { real_T c2_hoistedGlobal; real_T c2_randv; uint32_T c2_debug_family_var_map[6]; real_T c2_randTrigger; real_T c2_nargin = 1.0; real_T c2_nargout = 2.0; real_T c2_v_trigW; real_T c2_v_trig; real_T c2_x; real_T c2_b_x; real_T c2_c_x; real_T c2_d_x; real_T *c2_b_randv; real_T *c2_b_v_trigW; real_T *c2_b_v_trig; boolean_T guard1 = false; boolean_T guard2 = false; c2_b_v_trig = (real_T *)ssGetOutputPortSignal(chartInstance->S, 2); c2_b_v_trigW = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1); c2_b_randv = (real_T *)ssGetInputPortSignal(chartInstance->S, 0); _SFD_SYMBOL_SCOPE_PUSH(0U, 0U); _sfTime_ = sf_get_time(chartInstance->S); _SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 1U, chartInstance->c2_sfEvent); _SFD_DATA_RANGE_CHECK(*c2_b_randv, 0U); chartInstance->c2_sfEvent = CALL_EVENT; _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 1U, chartInstance->c2_sfEvent); c2_hoistedGlobal = *c2_b_randv; c2_randv = c2_hoistedGlobal; _SFD_SYMBOL_SCOPE_PUSH_EML(0U, 6U, 6U, c2_debug_family_names, c2_debug_family_var_map); _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c2_randTrigger, 0U, c2_sf_marshallOut, c2_sf_marshallIn); _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c2_nargin, 1U, c2_sf_marshallOut, c2_sf_marshallIn); _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c2_nargout, 2U, c2_sf_marshallOut, c2_sf_marshallIn); _SFD_SYMBOL_SCOPE_ADD_EML(&c2_randv, 3U, c2_sf_marshallOut); _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c2_v_trigW, 4U, c2_sf_marshallOut, c2_sf_marshallIn); _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c2_v_trig, 5U, c2_sf_marshallOut, c2_sf_marshallIn); CV_EML_FCN(0, 0); _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 3); c2_v_trigW = 0.0; _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 5); c2_x = c2_randv; c2_randTrigger = c2_x; c2_b_x = c2_randTrigger; c2_randTrigger = c2_b_x; c2_randTrigger = muDoubleScalarFloor(c2_randTrigger); _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 7); guard2 = false; if (CV_EML_COND(0, 1, 0, 0.0 < c2_randTrigger)) { if (CV_EML_COND(0, 1, 1, c2_randTrigger < 30.0)) { CV_EML_MCDC(0, 1, 0, true); CV_EML_IF(0, 1, 0, true); _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 8); c2_v_trigW += 0.1; } else { guard2 = true; } } else { guard2 = true; } if (guard2 == true) { CV_EML_MCDC(0, 1, 0, false); CV_EML_IF(0, 1, 0, false); } _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 10); guard1 = false; if (CV_EML_COND(0, 1, 2, 30.0 < c2_randTrigger)) { if (CV_EML_COND(0, 1, 3, c2_randTrigger < 60.0)) { CV_EML_MCDC(0, 1, 1, true); CV_EML_IF(0, 1, 1, true); _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 11); c2_v_trigW -= 0.1; } else { guard1 = true; } } else { guard1 = true; } if (guard1 == true) { CV_EML_MCDC(0, 1, 1, false); CV_EML_IF(0, 1, 1, false); } _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 14); if (CV_EML_IF(0, 1, 2, c2_v_trigW > 0.0)) { _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 15); c2_v_trig = 1.0; } else { _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 16); if (CV_EML_IF(0, 1, 3, c2_v_trigW < 0.0)) { _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 17); c2_v_trig = -1.0; _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 18); c2_c_x = c2_v_trigW; c2_d_x = c2_c_x; c2_v_trigW = muDoubleScalarAbs(c2_d_x); } else { _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 20); c2_v_trig = 0.0; _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, 20); c2_v_trigW = 0.0; } } _SFD_EML_CALL(0U, chartInstance->c2_sfEvent, -20); _SFD_SYMBOL_SCOPE_POP(); *c2_b_v_trigW = c2_v_trigW; *c2_b_v_trig = c2_v_trig; _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 1U, chartInstance->c2_sfEvent); _SFD_SYMBOL_SCOPE_POP(); _SFD_CHECK_FOR_STATE_INCONSISTENCY(_Demo_AU_VA1MachineNumber_, chartInstance->chartNumber, chartInstance->instanceNumber); _SFD_DATA_RANGE_CHECK(*c2_b_v_trigW, 1U); _SFD_DATA_RANGE_CHECK(*c2_b_v_trig, 2U); }
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; }