/* * conditionalCovariance.c * * Code generation for function 'conditionalCovariance' * * C source code generated on: Wed Aug 26 14:59:34 2015 * */ /* Include files */ #include "rt_nonfinite.h" #include "Select_Ground_Motions.h" #include "conditionalCovariance.h" #include "CB_2008_nga.h" #include "SP_1996.h" #include "Select_Ground_Motions_emxutil.h" #include "inv.h" #include "sqrt.h" #include "baker_jayaram_correlation.h" #include "mpower.h" #include "corrcoef.h" #include "interp1.h" #include "log.h" #include "repmat.h" #include "any.h" #include "Select_Ground_Motions_mexutil.h" #include "Select_Ground_Motions_data.h" /* Variable Definitions */ static emlrtRSInfo fp_emlrtRSI = { 21, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtRSInfo gp_emlrtRSI = { 28, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtRSInfo hp_emlrtRSI = { 41, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtRSInfo ip_emlrtRSI = { 44, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtRSInfo jp_emlrtRSI = { 47, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtRSInfo kp_emlrtRSI = { 49, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtRSInfo lp_emlrtRSI = { 51, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtRSInfo mp_emlrtRSI = { 53, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtRSInfo np_emlrtRSI = { 68, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtRSInfo op_emlrtRSI = { 69, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtRSInfo pp_emlrtRSI = { 75, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtRSInfo ns_emlrtRSI = { 149, "interp1", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/polyfun/interp1.m" }; static emlrtRSInfo os_emlrtRSI = { 105, "interp1", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/polyfun/interp1.m" }; static emlrtRSInfo ps_emlrtRSI = { 96, "interp1", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/polyfun/interp1.m" }; static emlrtRSInfo qs_emlrtRSI = { 19, "flipdim", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/elmat/flipdim.m" }; static emlrtMCInfo xc_emlrtMCI = { 97, 9, "interp1", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/polyfun/interp1.m" }; static emlrtMCInfo yc_emlrtMCI = { 96, 19, "interp1", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/polyfun/interp1.m" }; static emlrtMCInfo ad_emlrtMCI = { 106, 13, "interp1", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/polyfun/interp1.m" }; static emlrtMCInfo bd_emlrtMCI = { 105, 23, "interp1", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/polyfun/interp1.m" }; static emlrtRTEInfo hd_emlrtRTEI = { 1, 15, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtRTEInfo id_emlrtRTEI = { 33, 1, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtRTEInfo jd_emlrtRTEI = { 34, 1, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtRTEInfo kd_emlrtRTEI = { 49, 9, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtRTEInfo ld_emlrtRTEI = { 67, 1, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtECInfo nb_emlrtECI = { 1, 75, 31, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtBCInfo qd_emlrtBCI = { -1, -1, 75, 59, "sampleUse", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; static emlrtBCInfo rd_emlrtBCI = { -1, -1, 75, 44, "sampleUse", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; static emlrtECInfo ob_emlrtECI = { 1, 69, 13, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtECInfo pb_emlrtECI = { 2, 68, 17, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtECInfo qb_emlrtECI = { 2, 49, 19, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m" }; static emlrtBCInfo sd_emlrtBCI = { -1, -1, 43, 16, "sigmaKnown", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; static emlrtBCInfo td_emlrtBCI = { -1, -1, 42, 16, "sigmaKnown", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; static emlrtBCInfo ud_emlrtBCI = { -1, -1, 39, 14, "perKnown1", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; static emlrtBCInfo vd_emlrtBCI = { -1, -1, 38, 14, "perKnown1", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; static emlrtBCInfo wd_emlrtBCI = { -1, -1, 68, 25, "SaKnown", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; static emlrtDCInfo i_emlrtDCI = { 68, 25, "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 1 }; static emlrtBCInfo xd_emlrtBCI = { -1, -1, 69, 26, "sampleUse", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; static emlrtBCInfo yd_emlrtBCI = { -1, -1, 69, 84, "sampleUse", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; static emlrtBCInfo ae_emlrtBCI = { -1, -1, 76, 21, "corrReqSamp", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; static emlrtBCInfo be_emlrtBCI = { -1, -1, 76, 23, "corrReqSamp", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; static emlrtBCInfo ce_emlrtBCI = { -1, -1, 44, 16, "sigmaKnown", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; static emlrtBCInfo de_emlrtBCI = { -1, -1, 53, 17, "corrReq", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; static emlrtBCInfo ee_emlrtBCI = { -1, -1, 53, 19, "corrReq", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; static emlrtBCInfo fe_emlrtBCI = { -1, -1, 28, 40, "perKnown1", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; static emlrtBCInfo ge_emlrtBCI = { -1, -1, 29, 18, "sigmaKnown", "conditionalCovariance", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/conditionalCovariance.m", 0 }; /* Function Declarations */ static void c_eml_li_find(const boolean_T x[501], int32_T y_data[501], int32_T y_size[2]); /* Function Definitions */ static void c_eml_li_find(const boolean_T x[501], int32_T y_data[501], int32_T y_size[2]) { int32_T k; int32_T i; const mxArray *y; const mxArray *m32; k = 0; for (i = 0; i < 501; i++) { if (x[i]) { k++; } } if (k <= 501) { } else { emlrtPushRtStackR2012b(&sc_emlrtRSI, emlrtRootTLSGlobal); y = NULL; m32 = mxCreateString("Assertion failed."); emlrtAssign(&y, m32); error(y, &m_emlrtMCI); emlrtPopRtStackR2012b(&sc_emlrtRSI, emlrtRootTLSGlobal); } y_size[0] = 1; y_size[1] = k; k = 0; for (i = 0; i < 501; i++) { if (x[i]) { y_data[k] = i + 1; k++; } } } void conditionalCovariance(const real_T perKnown[501], real_T T1, real_T M_bar, real_T Rrup, real_T Rjb, real_T Ztor, real_T delta, real_T lambda, real_T Vs30, real_T Zvs, real_T arb, const emxArray_real_T *finalRecords, const emxArray_real_T *finalScaleFactors, const emxArray_real_T *SaKnown) { boolean_T b_perKnown[501]; int32_T i16; int32_T tmp_size[2]; int32_T tmp_data[501]; int32_T b_tmp_size[2]; int32_T b_tmp_data[501]; int32_T perKnown1_size_idx_1; int32_T high_i; real_T perKnown1_data[1003]; real_T sigmaKnown_data[1003]; int32_T i; real_T tmp2_data[21]; real_T tmp1_data[21]; emxArray_real_T *corrReq; emxArray_real_T *corrReqSamp; emxArray_real_T *sigma12; emxArray_boolean_T *x; emxArray_real_T *b; emxArray_real_T *b_b; emxArray_real_T *y; emxArray_real_T *c_b; emxArray_int32_T *ii; emxArray_int32_T *r37; emxArray_int32_T *b_ii; int32_T j; int32_T low_ip1; int32_T i2; boolean_T exitg2; boolean_T guard1 = FALSE; const mxArray *b_y; const mxArray *m31; int32_T low_i; real_T var1; real_T var2; real_T b_sigmaKnown_data[1003]; int32_T sigmaKnown_size[2]; emxArray_real_T c_sigmaKnown_data; int32_T varT_size[2]; real_T varT_data[1003]; real_T a; real_T d_b; real_T b_a; real_T e_b; real_T r; emxArray_real_T b_varT_data; const mxArray *c_y; static const int32_T iv80[2] = { 1, 45 }; char_T cv115[45]; static const char_T cv116[45] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 'm', 't', 'i', 'm', 'e', 's', '_', 'n', 'o', 'D', 'y', 'n', 'a', 'm', 'i', 'c', 'S', 'c', 'a', 'l', 'a', 'r', 'E', 'x', 'p', 'a', 'n', 's', 'i', 'o', 'n' }; const mxArray *d_y; static const int32_T iv81[2] = { 1, 21 }; char_T cv117[21]; static const char_T cv118[21] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T', 'L', 'A', 'B', ':', 'i', 'n', 'n', 'e', 'r', 'd', 'i', 'm' }; const mxArray *e_y; static const int32_T iv82[2] = { 1, 21 }; real_T corrMatrix[4]; real_T beta1; char_T TRANSB; char_T TRANSA; ptrdiff_t m_t; ptrdiff_t n_t; ptrdiff_t k_t; ptrdiff_t lda_t; ptrdiff_t ldb_t; ptrdiff_t ldc_t; double * alpha1_t; double * Aia0_t; double * Bib0_t; double * beta1_t; double * Cic0_t; real_T b_var1[4]; real_T sigmaCond[4]; emxArray_real_T *varargin_2; emxArray_real_T *b_SaKnown; emxArray_real_T *sampleUse; emxArray_real_T *f_y; real_T b_x[501]; boolean_T overflow; const mxArray *g_y; static const int32_T iv83[2] = { 1, 45 }; static const char_T cv119[45] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 'i', 'n', 't', 'e', 'r', 'p', '1', '_', 'v', 's', 'i', 'z', 'e', 'M', 'a', 't', 'r', 'i', 'x', 'B', 'e', 'c', 'a', 'm', 'e', 'R', 'o', 'w', 'V', 'e', 'c' }; const mxArray *h_y; static const int32_T iv84[2] = { 1, 36 }; char_T cv120[36]; static const char_T cv121[36] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T', 'L', 'A', 'B', ':', 'i', 'n', 't', 'e', 'r', 'p', '1', '_', 'Y', 'I', 'n', 'v', 'a', 'l', 'i', 'd', 'N', 'u', 'm', 'R', 'o', 'w', 's' }; uint32_T outsize_idx_1; int32_T exitg1; emxArray_real_T *r38; emxArray_real_T *r39; emxArray_real_T *r40; emxArray_real_T *b_sampleUse; emxArray_real_T *c_sampleUse; emxArray_real_T *d_sampleUse; emlrtHeapReferenceStackEnterFcnR2012b(emlrtRootTLSGlobal); /* This code is used to compare the covariance structure of the selected */ /* ground motions with the covariance structure provided by Baker and */ /* Jayaram (2008). */ /* */ /* Nirmal Jayaram, Ting Lin, Jack W. Baker */ /* Department of Civil and Environmental Engineering */ /* Stanford University */ /* Last Updated: 11 March 2010 */ /* */ /* Reference manuscripts: */ /* */ /* J. W. Baker and Jayaram, N. (2008). Correlation of spectral acceleration */ /* values from NGA ground motion models, Earthquake Spectra, 24 (1), 299-317 */ /* % Estimate conditional covariances from the Baker and Jayaram (2008) */ /* model */ /* Modify perTgt to include T1 */ for (i16 = 0; i16 < 501; i16++) { b_perKnown[i16] = (perKnown[i16] == T1); } if (!d_any(b_perKnown)) { emlrtPushRtStackR2012b(&fp_emlrtRSI, emlrtRootTLSGlobal); for (i16 = 0; i16 < 501; i16++) { b_perKnown[i16] = (perKnown[i16] < T1); } c_eml_li_find(b_perKnown, tmp_data, tmp_size); for (i16 = 0; i16 < 501; i16++) { b_perKnown[i16] = (perKnown[i16] > T1); } c_eml_li_find(b_perKnown, b_tmp_data, b_tmp_size); perKnown1_size_idx_1 = (tmp_size[1] + b_tmp_size[1]) + 1; high_i = tmp_size[1]; for (i16 = 0; i16 < high_i; i16++) { perKnown1_data[i16] = perKnown[tmp_data[tmp_size[0] * i16] - 1]; } perKnown1_data[tmp_size[1]] = T1; high_i = b_tmp_size[1]; for (i16 = 0; i16 < high_i; i16++) { perKnown1_data[(i16 + tmp_size[1]) + 1] = perKnown[b_tmp_data[b_tmp_size[0] * i16] - 1]; } emlrtPopRtStackR2012b(&fp_emlrtRSI, emlrtRootTLSGlobal); } else { perKnown1_size_idx_1 = 501; memcpy(&perKnown1_data[0], &perKnown[0], 501U * sizeof(real_T)); } for (i16 = 0; i16 < perKnown1_size_idx_1; i16++) { sigmaKnown_data[i16] = 0.0; } i = 1; while (i - 1 <= perKnown1_size_idx_1 - 1) { emlrtPushRtStackR2012b(&gp_emlrtRSI, emlrtRootTLSGlobal); CB_2008_nga(M_bar, perKnown1_data[emlrtDynamicBoundsCheckFastR2012b(i, 1, perKnown1_size_idx_1, &fe_emlrtBCI, emlrtRootTLSGlobal) - 1], Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb, tmp1_data, tmp_size, tmp2_data, b_tmp_size); emlrtPopRtStackR2012b(&gp_emlrtRSI, emlrtRootTLSGlobal); sigmaKnown_data[emlrtDynamicBoundsCheckFastR2012b(i, 1, perKnown1_size_idx_1, &ge_emlrtBCI, emlrtRootTLSGlobal) - 1] = tmp2_data[0]; i++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, emlrtRootTLSGlobal); } b_emxInit_real_T(&corrReq, 2, &id_emlrtRTEI, TRUE); i16 = corrReq->size[0] * corrReq->size[1]; corrReq->size[0] = perKnown1_size_idx_1; emxEnsureCapacity((emxArray__common *)corrReq, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); i16 = corrReq->size[0] * corrReq->size[1]; corrReq->size[1] = perKnown1_size_idx_1; emxEnsureCapacity((emxArray__common *)corrReq, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); high_i = perKnown1_size_idx_1 * perKnown1_size_idx_1; for (i16 = 0; i16 < high_i; i16++) { corrReq->data[i16] = 0.0; } b_emxInit_real_T(&corrReqSamp, 2, &jd_emlrtRTEI, TRUE); i16 = corrReqSamp->size[0] * corrReqSamp->size[1]; corrReqSamp->size[0] = perKnown1_size_idx_1; emxEnsureCapacity((emxArray__common *)corrReqSamp, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); i16 = corrReqSamp->size[0] * corrReqSamp->size[1]; corrReqSamp->size[1] = perKnown1_size_idx_1; emxEnsureCapacity((emxArray__common *)corrReqSamp, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); high_i = perKnown1_size_idx_1 * perKnown1_size_idx_1; for (i16 = 0; i16 < high_i; i16++) { corrReqSamp->data[i16] = 0.0; } i = 0; b_emxInit_real_T(&sigma12, 2, &kd_emlrtRTEI, TRUE); emxInit_boolean_T(&x, 2, &hd_emlrtRTEI, TRUE); b_emxInit_real_T(&b, 2, &hd_emlrtRTEI, TRUE); b_emxInit_real_T(&b_b, 2, &hd_emlrtRTEI, TRUE); b_emxInit_real_T(&y, 2, &hd_emlrtRTEI, TRUE); b_emxInit_real_T(&c_b, 2, &hd_emlrtRTEI, TRUE); b_emxInit_int32_T(&ii, 2, &w_emlrtRTEI, TRUE); emxInit_int32_T(&r37, 1, &hd_emlrtRTEI, TRUE); b_emxInit_int32_T(&b_ii, 2, &hd_emlrtRTEI, TRUE); while (i <= perKnown1_size_idx_1 - 1) { j = 0; while (j <= perKnown1_size_idx_1 - 1) { i16 = (int32_T)(1.0 + (real_T)i); emlrtDynamicBoundsCheckFastR2012b(i16, 1, perKnown1_size_idx_1, &vd_emlrtBCI, emlrtRootTLSGlobal); i16 = (int32_T)(1.0 + (real_T)j); emlrtDynamicBoundsCheckFastR2012b(i16, 1, perKnown1_size_idx_1, &ud_emlrtBCI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hp_emlrtRSI, emlrtRootTLSGlobal); i16 = x->size[0] * x->size[1]; x->size[0] = 1; x->size[1] = perKnown1_size_idx_1; emxEnsureCapacity((emxArray__common *)x, i16, (int32_T)sizeof(boolean_T), &hd_emlrtRTEI); high_i = perKnown1_size_idx_1; for (i16 = 0; i16 < high_i; i16++) { x->data[i16] = (perKnown1_data[i16] == T1); } emlrtPushRtStackR2012b(&vc_emlrtRSI, emlrtRootTLSGlobal); low_ip1 = 0; i16 = ii->size[0] * ii->size[1]; ii->size[0] = 1; ii->size[1] = x->size[1]; emxEnsureCapacity((emxArray__common *)ii, i16, (int32_T)sizeof(int32_T), &c_emlrtRTEI); emlrtPushRtStackR2012b(&xc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&xc_emlrtRSI, emlrtRootTLSGlobal); i2 = 1; exitg2 = FALSE; while ((exitg2 == FALSE) && (i2 <= x->size[1])) { guard1 = FALSE; if (x->data[i2 - 1]) { low_ip1++; ii->data[low_ip1 - 1] = i2; if (low_ip1 >= x->size[1]) { exitg2 = TRUE; } else { guard1 = TRUE; } } else { guard1 = TRUE; } if (guard1 == TRUE) { i2++; } } if (low_ip1 <= x->size[1]) { } else { emlrtPushRtStackR2012b(&yc_emlrtRSI, emlrtRootTLSGlobal); b_y = NULL; m31 = mxCreateString("Assertion failed."); emlrtAssign(&b_y, m31); error(b_y, &o_emlrtMCI); emlrtPopRtStackR2012b(&yc_emlrtRSI, emlrtRootTLSGlobal); } if (x->size[1] == 1) { if (low_ip1 == 0) { i16 = ii->size[0] * ii->size[1]; ii->size[0] = 1; ii->size[1] = 0; emxEnsureCapacity((emxArray__common *)ii, i16, (int32_T)sizeof(int32_T), &hd_emlrtRTEI); } } else { if (1 > low_ip1) { high_i = 0; } else { high_i = low_ip1; } i16 = r37->size[0]; r37->size[0] = high_i; emxEnsureCapacity((emxArray__common *)r37, i16, (int32_T)sizeof(int32_T), &hd_emlrtRTEI); for (i16 = 0; i16 < high_i; i16++) { r37->data[i16] = 1 + i16; } i2 = r37->size[0]; i16 = b_ii->size[0] * b_ii->size[1]; b_ii->size[0] = 1; b_ii->size[1] = i2; emxEnsureCapacity((emxArray__common *)b_ii, i16, (int32_T)sizeof(int32_T), &hd_emlrtRTEI); for (i16 = 0; i16 < i2; i16++) { low_i = 0; while (low_i <= 0) { b_ii->data[b_ii->size[0] * i16] = ii->data[r37->data[i16] - 1]; low_i = 1; } } i16 = ii->size[0] * ii->size[1]; ii->size[0] = 1; ii->size[1] = b_ii->size[1]; emxEnsureCapacity((emxArray__common *)ii, i16, (int32_T)sizeof(int32_T), &hd_emlrtRTEI); high_i = b_ii->size[1]; for (i16 = 0; i16 < high_i; i16++) { ii->data[ii->size[0] * i16] = b_ii->data[b_ii->size[0] * i16]; } } emlrtPopRtStackR2012b(&vc_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&hp_emlrtRSI, emlrtRootTLSGlobal); i16 = (int32_T)(1.0 + (real_T)i); emlrtDynamicBoundsCheckFastR2012b(i16, 1, perKnown1_size_idx_1, &td_emlrtBCI, emlrtRootTLSGlobal); var1 = sigmaKnown_data[i] * sigmaKnown_data[i]; i16 = (int32_T)(1.0 + (real_T)j); emlrtDynamicBoundsCheckFastR2012b(i16, 1, perKnown1_size_idx_1, &sd_emlrtBCI, emlrtRootTLSGlobal); var2 = sigmaKnown_data[j] * sigmaKnown_data[j]; emlrtPushRtStackR2012b(&ip_emlrtRSI, emlrtRootTLSGlobal); sigmaKnown_size[0] = 1; sigmaKnown_size[1] = ii->size[1]; high_i = ii->size[0] * ii->size[1]; for (i16 = 0; i16 < high_i; i16++) { low_i = ii->data[i16]; b_sigmaKnown_data[i16] = sigmaKnown_data[emlrtDynamicBoundsCheckFastR2012b(low_i, 1, perKnown1_size_idx_1, &ce_emlrtBCI, emlrtRootTLSGlobal) - 1]; } c_sigmaKnown_data.data = (real_T *)&b_sigmaKnown_data; c_sigmaKnown_data.size = (int32_T *)&sigmaKnown_size; c_sigmaKnown_data.allocatedSize = 1003; c_sigmaKnown_data.numDimensions = 2; c_sigmaKnown_data.canFreeData = FALSE; mpower(&c_sigmaKnown_data, b); varT_size[0] = 1; varT_size[1] = b->size[1]; high_i = b->size[0] * b->size[1]; for (i16 = 0; i16 < high_i; i16++) { varT_data[i16] = b->data[i16]; } emlrtPopRtStackR2012b(&ip_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&jp_emlrtRSI, emlrtRootTLSGlobal); a = baker_jayaram_correlation(perKnown1_data[i], perKnown1_data[j]); d_b = var1 * var2; b_sqrt(&d_b); b_a = baker_jayaram_correlation(perKnown1_data[i], perKnown1_data[j]); e_b = var1 * var2; b_sqrt(&e_b); emlrtPopRtStackR2012b(&jp_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&kp_emlrtRSI, emlrtRootTLSGlobal); r = baker_jayaram_correlation(perKnown1_data[i], T1); i16 = b->size[0] * b->size[1]; b->size[0] = 1; b->size[1] = varT_size[1]; emxEnsureCapacity((emxArray__common *)b, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); high_i = varT_size[0] * varT_size[1]; for (i16 = 0; i16 < high_i; i16++) { b->data[i16] = var1 * varT_data[i16]; } c_sqrt(b); i16 = b->size[0] * b->size[1]; b->size[0] = 1; emxEnsureCapacity((emxArray__common *)b, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); i2 = b->size[0]; low_ip1 = b->size[1]; high_i = i2 * low_ip1; for (i16 = 0; i16 < high_i; i16++) { b->data[i16] *= r; } emlrtPopRtStackR2012b(&kp_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&kp_emlrtRSI, emlrtRootTLSGlobal); r = baker_jayaram_correlation(T1, perKnown1_data[j]); i16 = b_b->size[0] * b_b->size[1]; b_b->size[0] = 1; b_b->size[1] = varT_size[1]; emxEnsureCapacity((emxArray__common *)b_b, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); high_i = varT_size[0] * varT_size[1]; for (i16 = 0; i16 < high_i; i16++) { b_b->data[i16] = var2 * varT_data[i16]; } c_sqrt(b_b); i16 = b_b->size[0] * b_b->size[1]; b_b->size[0] = 1; emxEnsureCapacity((emxArray__common *)b_b, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); i2 = b_b->size[0]; low_ip1 = b_b->size[1]; high_i = i2 * low_ip1; for (i16 = 0; i16 < high_i; i16++) { b_b->data[i16] *= r; } emlrtPopRtStackR2012b(&kp_emlrtRSI, emlrtRootTLSGlobal); i16 = b->size[1]; low_i = b_b->size[1]; emlrtDimSizeEqCheckFastR2012b(i16, low_i, &qb_emlrtECI, emlrtRootTLSGlobal); i16 = sigma12->size[0] * sigma12->size[1]; sigma12->size[0] = 2; sigma12->size[1] = b->size[1]; emxEnsureCapacity((emxArray__common *)sigma12, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); high_i = b->size[1]; for (i16 = 0; i16 < high_i; i16++) { sigma12->data[sigma12->size[0] * i16] = b->data[b->size[0] * i16]; } high_i = b_b->size[1]; for (i16 = 0; i16 < high_i; i16++) { sigma12->data[1 + sigma12->size[0] * i16] = b_b->data[b_b->size[0] * i16]; } emlrtPushRtStackR2012b(&lp_emlrtRSI, emlrtRootTLSGlobal); b_varT_data.data = (real_T *)&varT_data; b_varT_data.size = (int32_T *)&varT_size; b_varT_data.allocatedSize = 1003; b_varT_data.numDimensions = 2; b_varT_data.canFreeData = FALSE; inv(&b_varT_data, b); emlrtPushRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); if (!(sigma12->size[1] == 1)) { if (b->size[1] == 1) { emlrtPushRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); c_y = NULL; m31 = mxCreateCharArray(2, iv80); for (i2 = 0; i2 < 45; i2++) { cv115[i2] = cv116[i2]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m31, cv115); emlrtAssign(&c_y, m31); error(message(c_y, &r_emlrtMCI), &s_emlrtMCI); emlrtPopRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); d_y = NULL; m31 = mxCreateCharArray(2, iv81); for (i2 = 0; i2 < 21; i2++) { cv117[i2] = cv118[i2]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m31, cv117); emlrtAssign(&d_y, m31); error(message(d_y, &t_emlrtMCI), &u_emlrtMCI); emlrtPopRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); } } emlrtPopRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); i16 = y->size[0] * y->size[1]; y->size[0] = 2; y->size[1] = b->size[1]; emxEnsureCapacity((emxArray__common *)y, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); for (i16 = 0; i16 < 2; i16++) { high_i = b->size[1]; for (low_i = 0; low_i < high_i; low_i++) { y->data[i16 + y->size[0] * low_i] = sigma12->data[i16] * b->data [b->size[0] * low_i]; } } i16 = c_b->size[0] * c_b->size[1]; c_b->size[0] = sigma12->size[1]; c_b->size[1] = 2; emxEnsureCapacity((emxArray__common *)c_b, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); for (i16 = 0; i16 < 2; i16++) { high_i = sigma12->size[1]; for (low_i = 0; low_i < high_i; low_i++) { c_b->data[low_i + c_b->size[0] * i16] = sigma12->data[i16 + sigma12->size[0] * low_i]; } } emlrtPushRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); if (!(y->size[1] == c_b->size[0])) { emlrtPushRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); e_y = NULL; m31 = mxCreateCharArray(2, iv82); for (i2 = 0; i2 < 21; i2++) { cv117[i2] = cv118[i2]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m31, cv117); emlrtAssign(&e_y, m31); error(message(e_y, &t_emlrtMCI), &u_emlrtMCI); emlrtPopRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); if ((y->size[1] == 1) || (c_b->size[0] == 1)) { for (i16 = 0; i16 < 2; i16++) { for (low_i = 0; low_i < 2; low_i++) { corrMatrix[i16 + (low_i << 1)] = 0.0; high_i = y->size[1]; for (low_ip1 = 0; low_ip1 < high_i; low_ip1++) { corrMatrix[i16 + (low_i << 1)] += y->data[i16 + y->size[0] * low_ip1] * c_b->data[low_ip1 + c_b->size[0] * low_i]; } } } } else { emlrtPushRtStackR2012b(&ge_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&he_emlrtRSI, emlrtRootTLSGlobal); for (i16 = 0; i16 < 4; i16++) { corrMatrix[i16] = 0.0; } if (y->size[1] < 1) { } else { emlrtPushRtStackR2012b(&je_emlrtRSI, emlrtRootTLSGlobal); r = 1.0; beta1 = 0.0; TRANSB = 'N'; TRANSA = 'N'; emlrtPushRtStackR2012b(&ne_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&af_emlrtRSI, emlrtRootTLSGlobal); m_t = (ptrdiff_t)(2); emlrtPopRtStackR2012b(&af_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&ne_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&oe_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&af_emlrtRSI, emlrtRootTLSGlobal); n_t = (ptrdiff_t)(2); emlrtPopRtStackR2012b(&af_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&oe_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&pe_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&af_emlrtRSI, emlrtRootTLSGlobal); k_t = (ptrdiff_t)(y->size[1]); emlrtPopRtStackR2012b(&af_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&pe_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&qe_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&af_emlrtRSI, emlrtRootTLSGlobal); lda_t = (ptrdiff_t)(2); emlrtPopRtStackR2012b(&af_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&qe_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&re_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&af_emlrtRSI, emlrtRootTLSGlobal); ldb_t = (ptrdiff_t)(y->size[1]); emlrtPopRtStackR2012b(&af_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&re_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&se_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&af_emlrtRSI, emlrtRootTLSGlobal); ldc_t = (ptrdiff_t)(2); emlrtPopRtStackR2012b(&af_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&se_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&te_emlrtRSI, emlrtRootTLSGlobal); alpha1_t = (double *)(&r); emlrtPopRtStackR2012b(&te_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ue_emlrtRSI, emlrtRootTLSGlobal); Aia0_t = (double *)(&y->data[0]); emlrtPopRtStackR2012b(&ue_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ve_emlrtRSI, emlrtRootTLSGlobal); Bib0_t = (double *)(&c_b->data[0]); emlrtPopRtStackR2012b(&ve_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&we_emlrtRSI, emlrtRootTLSGlobal); beta1_t = (double *)(&beta1); emlrtPopRtStackR2012b(&we_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&xe_emlrtRSI, emlrtRootTLSGlobal); Cic0_t = (double *)(&corrMatrix[0]); emlrtPopRtStackR2012b(&xe_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&ye_emlrtRSI, emlrtRootTLSGlobal); dgemm(&TRANSA, &TRANSB, &m_t, &n_t, &k_t, alpha1_t, Aia0_t, &lda_t, Bib0_t, &ldb_t, beta1_t, Cic0_t, &ldc_t); emlrtPopRtStackR2012b(&ye_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&je_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&he_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&ge_emlrtRSI, emlrtRootTLSGlobal); } b_var1[0] = var1; b_var1[2] = a * d_b; b_var1[1] = b_a * e_b; b_var1[3] = var2; for (i16 = 0; i16 < 2; i16++) { for (low_i = 0; low_i < 2; low_i++) { sigmaCond[low_i + (i16 << 1)] = b_var1[low_i + (i16 << 1)] - corrMatrix[low_i + (i16 << 1)]; } } emlrtPopRtStackR2012b(&lp_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&mp_emlrtRSI, emlrtRootTLSGlobal); r = sigmaCond[0] * sigmaCond[3]; if (r < 0.0) { emlrtPushRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); e_eml_error(); emlrtPopRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); } i16 = corrReq->size[0]; low_i = 1 + i; low_ip1 = corrReq->size[1]; i2 = 1 + j; corrReq->data[(emlrtDynamicBoundsCheckFastR2012b(low_i, 1, i16, &de_emlrtBCI, emlrtRootTLSGlobal) + corrReq->size[0] * (emlrtDynamicBoundsCheckFastR2012b(i2, 1, low_ip1, &ee_emlrtBCI, emlrtRootTLSGlobal) - 1)) - 1] = sigmaCond[2] / muDoubleScalarSqrt(r); emlrtPopRtStackR2012b(&mp_emlrtRSI, emlrtRootTLSGlobal); j++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, emlrtRootTLSGlobal); } i++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, emlrtRootTLSGlobal); } emxFree_int32_T(&b_ii); emxFree_int32_T(&r37); emxFree_int32_T(&ii); emxFree_real_T(&c_b); emxFree_real_T(&y); emxFree_real_T(&b_b); emxFree_boolean_T(&x); emxFree_real_T(&sigma12); emxFree_real_T(&corrReq); /* f = figure(); */ /* set(f,'Visible','off'); */ /* %imagesc(perKnown1,perKnown1,corrReq) */ /* title('Baker and Jayaram (2008) conditional correlations'); */ /* xlabel('T_1 (s)'); */ /* ylabel('T_2 (s)'); */ /* %print(f,'-dpng','BJcc.png'); */ /* % Observed correlations */ high_i = finalRecords->size[0]; for (i16 = 0; i16 < high_i; i16++) { low_i = SaKnown->size[0]; r = finalRecords->data[i16]; low_ip1 = (int32_T)emlrtIntegerCheckFastR2012b(r, &i_emlrtDCI, emlrtRootTLSGlobal); emlrtDynamicBoundsCheckFastR2012b(low_ip1, 1, low_i, &wd_emlrtBCI, emlrtRootTLSGlobal); } b_emxInit_real_T(&varargin_2, 2, &hd_emlrtRTEI, TRUE); b_emxInit_real_T(&b_SaKnown, 2, &hd_emlrtRTEI, TRUE); emlrtPushRtStackR2012b(&np_emlrtRSI, emlrtRootTLSGlobal); b_repmat(finalScaleFactors, SaKnown->size[1], varargin_2); emlrtPopRtStackR2012b(&np_emlrtRSI, emlrtRootTLSGlobal); high_i = SaKnown->size[1]; i16 = b_SaKnown->size[0] * b_SaKnown->size[1]; b_SaKnown->size[0] = finalRecords->size[0]; b_SaKnown->size[1] = high_i; emxEnsureCapacity((emxArray__common *)b_SaKnown, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); for (i16 = 0; i16 < high_i; i16++) { low_ip1 = finalRecords->size[0]; for (low_i = 0; low_i < low_ip1; low_i++) { b_SaKnown->data[low_i + b_SaKnown->size[0] * i16] = SaKnown->data [((int32_T)finalRecords->data[low_i] + SaKnown->size[0] * i16) - 1]; } } for (i16 = 0; i16 < 2; i16++) { tmp_size[i16] = b_SaKnown->size[i16]; } emxFree_real_T(&b_SaKnown); for (i16 = 0; i16 < 2; i16++) { b_tmp_size[i16] = varargin_2->size[i16]; } b_emxInit_real_T(&sampleUse, 2, &ld_emlrtRTEI, TRUE); emlrtSizeEqCheck2DFastR2012b(tmp_size, b_tmp_size, &pb_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&np_emlrtRSI, emlrtRootTLSGlobal); high_i = SaKnown->size[1]; i16 = sampleUse->size[0] * sampleUse->size[1]; sampleUse->size[0] = finalRecords->size[0]; sampleUse->size[1] = high_i; emxEnsureCapacity((emxArray__common *)sampleUse, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); for (i16 = 0; i16 < high_i; i16++) { low_ip1 = finalRecords->size[0]; for (low_i = 0; low_i < low_ip1; low_i++) { sampleUse->data[low_i + sampleUse->size[0] * i16] = SaKnown->data [((int32_T)finalRecords->data[low_i] + SaKnown->size[0] * i16) - 1] * varargin_2->data[low_i + varargin_2->size[0] * i16]; } } d_log(sampleUse); emlrtPopRtStackR2012b(&np_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&op_emlrtRSI, emlrtRootTLSGlobal); i16 = varargin_2->size[0] * varargin_2->size[1]; varargin_2->size[0] = sampleUse->size[1]; varargin_2->size[1] = sampleUse->size[0]; emxEnsureCapacity((emxArray__common *)varargin_2, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); high_i = sampleUse->size[0]; for (i16 = 0; i16 < high_i; i16++) { low_ip1 = sampleUse->size[1]; for (low_i = 0; low_i < low_ip1; low_i++) { varargin_2->data[low_i + varargin_2->size[0] * i16] = sampleUse->data[i16 + sampleUse->size[0] * low_i]; } } b_emxInit_real_T(&f_y, 2, &hd_emlrtRTEI, TRUE); emlrtPushRtStackR2012b(&kd_emlrtRSI, emlrtRootTLSGlobal); i16 = f_y->size[0] * f_y->size[1]; f_y->size[0] = varargin_2->size[0]; f_y->size[1] = varargin_2->size[1]; emxEnsureCapacity((emxArray__common *)f_y, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); high_i = varargin_2->size[0] * varargin_2->size[1]; for (i16 = 0; i16 < high_i; i16++) { f_y->data[i16] = varargin_2->data[i16]; } memcpy(&b_x[0], &perKnown[0], 501U * sizeof(real_T)); if (((varargin_2->size[0] == 1) && (varargin_2->size[1] == 1)) || (!((varargin_2->size[0] == 1) || (varargin_2->size[1] == 1))) || (varargin_2->size[0] != 1)) { overflow = TRUE; } else { overflow = FALSE; } if (overflow) { } else { emlrtPushRtStackR2012b(&ps_emlrtRSI, emlrtRootTLSGlobal); g_y = NULL; m31 = mxCreateCharArray(2, iv83); for (i = 0; i < 45; i++) { cv115[i] = cv119[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m31, cv115); emlrtAssign(&g_y, m31); error(message(g_y, &xc_emlrtMCI), &yc_emlrtMCI); emlrtPopRtStackR2012b(&ps_emlrtRSI, emlrtRootTLSGlobal); } if (501 == varargin_2->size[0]) { } else { emlrtPushRtStackR2012b(&os_emlrtRSI, emlrtRootTLSGlobal); h_y = NULL; m31 = mxCreateCharArray(2, iv84); for (i = 0; i < 36; i++) { cv120[i] = cv121[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 36, m31, cv120); emlrtAssign(&h_y, m31); error(message(h_y, &ad_emlrtMCI), &bd_emlrtMCI); emlrtPopRtStackR2012b(&os_emlrtRSI, emlrtRootTLSGlobal); } outsize_idx_1 = (uint32_T)varargin_2->size[1]; i16 = b->size[0] * b->size[1]; b->size[0] = 1; emxEnsureCapacity((emxArray__common *)b, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); i16 = b->size[0] * b->size[1]; b->size[1] = (int32_T)outsize_idx_1; emxEnsureCapacity((emxArray__common *)b, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); high_i = (int32_T)outsize_idx_1; for (i16 = 0; i16 < high_i; i16++) { b->data[i16] = rtNaN; } i2 = 1; do { exitg1 = 0; if (i2 < 502) { if (muDoubleScalarIsNaN(perKnown[i2 - 1])) { emlrtPushRtStackR2012b(&hs_emlrtRSI, emlrtRootTLSGlobal); c_eml_error(); emlrtPopRtStackR2012b(&hs_emlrtRSI, emlrtRootTLSGlobal); exitg1 = 1; } else { i2++; } } else { if (perKnown[1] < perKnown[0]) { for (i2 = 0; i2 < 250; i2++) { r = b_x[i2]; b_x[i2] = b_x[500 - i2]; b_x[500 - i2] = r; } emlrtPushRtStackR2012b(&ns_emlrtRSI, emlrtRootTLSGlobal); if ((!((varargin_2->size[0] == 0) || (varargin_2->size[1] == 0))) && (varargin_2->size[0] > 1)) { i2 = 0; emlrtPushRtStackR2012b(&qs_emlrtRSI, emlrtRootTLSGlobal); overflow = (varargin_2->size[1] > 2147483646); if (overflow) { emlrtPushRtStackR2012b(&lc_emlrtRSI, emlrtRootTLSGlobal); check_forloop_overflow_error(); emlrtPopRtStackR2012b(&lc_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&qs_emlrtRSI, emlrtRootTLSGlobal); for (i = 1; i <= varargin_2->size[1]; i++) { low_ip1 = i2 + 1; i2 += varargin_2->size[0]; for (high_i = i2; low_ip1 < high_i; high_i--) { r = f_y->data[low_ip1 - 1]; f_y->data[low_ip1 - 1] = f_y->data[high_i - 1]; f_y->data[high_i - 1] = r; low_ip1++; } } } emlrtPopRtStackR2012b(&ns_emlrtRSI, emlrtRootTLSGlobal); } for (i2 = 0; i2 < 500; i2++) { if (b_x[i2 + 1] <= b_x[i2]) { emlrtPushRtStackR2012b(&ld_emlrtRSI, emlrtRootTLSGlobal); d_eml_error(); emlrtPopRtStackR2012b(&ld_emlrtRSI, emlrtRootTLSGlobal); } } if ((T1 > b_x[500]) || (T1 < b_x[0])) { } else { low_i = 1; low_ip1 = 2; high_i = 501; while (high_i > low_ip1) { i16 = low_i + high_i; if (i16 >= 0) { i2 = (int32_T)((uint32_T)i16 >> 1); } else { i2 = ~(int32_T)((uint32_T)~i16 >> 1); } if (T1 >= b_x[i2 - 1]) { low_i = i2; low_ip1 = i2 + 1; } else { high_i = i2; } } r = (T1 - b_x[low_i - 1]) / (b_x[low_i] - b_x[low_i - 1]); for (j = 0; j < varargin_2->size[1]; j++) { i2 = j * 501; if (f_y->data[(low_i + i2) - 1] == f_y->data[low_i + j * 501]) { b->data[j] = f_y->data[(low_i + i2) - 1]; } else { b->data[j] = (1.0 - r) * f_y->data[(low_i + j * 501) - 1] + r * f_y->data[low_i + j * 501]; } } } exitg1 = 1; } } while (exitg1 == 0); emxFree_real_T(&f_y); emxFree_real_T(&varargin_2); emlrtPopRtStackR2012b(&kd_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&op_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&op_emlrtRSI, emlrtRootTLSGlobal); for (i16 = 0; i16 < 501; i16++) { b_perKnown[i16] = (perKnown[i16] < T1); } c_eml_li_find(b_perKnown, tmp_data, tmp_size); high_i = tmp_size[0] * tmp_size[1]; for (i16 = 0; i16 < high_i; i16++) { low_i = sampleUse->size[1]; b_tmp_data[i16] = emlrtDynamicBoundsCheckFastR2012b(tmp_data[i16], 1, low_i, &xd_emlrtBCI, emlrtRootTLSGlobal); } b_emxInit_real_T(&r38, 2, &hd_emlrtRTEI, TRUE); high_i = sampleUse->size[0]; i16 = r38->size[0] * r38->size[1]; r38->size[0] = high_i; r38->size[1] = tmp_size[1]; emxEnsureCapacity((emxArray__common *)r38, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); low_ip1 = tmp_size[1]; for (i16 = 0; i16 < low_ip1; i16++) { for (low_i = 0; low_i < high_i; low_i++) { r38->data[low_i + r38->size[0] * i16] = sampleUse->data[low_i + sampleUse->size[0] * (b_tmp_data[i16] - 1)]; } } b_emxInit_real_T(&r39, 2, &hd_emlrtRTEI, TRUE); emlrtPopRtStackR2012b(&op_emlrtRSI, emlrtRootTLSGlobal); i2 = b->size[1]; i16 = r39->size[0] * r39->size[1]; r39->size[0] = i2; r39->size[1] = 1; emxEnsureCapacity((emxArray__common *)r39, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); high_i = b->size[1]; for (i16 = 0; i16 < high_i; i16++) { r39->data[i16] = b->data[i16]; } emxFree_real_T(&b); i16 = r38->size[0]; low_i = r39->size[0]; emlrtDimSizeEqCheckFastR2012b(i16, low_i, &ob_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&op_emlrtRSI, emlrtRootTLSGlobal); for (i16 = 0; i16 < 501; i16++) { b_perKnown[i16] = (perKnown[i16] > T1); } c_eml_li_find(b_perKnown, tmp_data, tmp_size); high_i = tmp_size[0] * tmp_size[1]; for (i16 = 0; i16 < high_i; i16++) { low_i = sampleUse->size[1]; b_tmp_data[i16] = emlrtDynamicBoundsCheckFastR2012b(tmp_data[i16], 1, low_i, &yd_emlrtBCI, emlrtRootTLSGlobal); } b_emxInit_real_T(&r40, 2, &hd_emlrtRTEI, TRUE); high_i = sampleUse->size[0]; i16 = r40->size[0] * r40->size[1]; r40->size[0] = high_i; r40->size[1] = tmp_size[1]; emxEnsureCapacity((emxArray__common *)r40, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); low_ip1 = tmp_size[1]; for (i16 = 0; i16 < low_ip1; i16++) { for (low_i = 0; low_i < high_i; low_i++) { r40->data[low_i + r40->size[0] * i16] = sampleUse->data[low_i + sampleUse->size[0] * (b_tmp_data[i16] - 1)]; } } emlrtPopRtStackR2012b(&op_emlrtRSI, emlrtRootTLSGlobal); i16 = r38->size[0]; low_i = r40->size[0]; emlrtDimSizeEqCheckFastR2012b(i16, low_i, &ob_emlrtECI, emlrtRootTLSGlobal); i16 = sampleUse->size[0] * sampleUse->size[1]; sampleUse->size[0] = r38->size[0]; sampleUse->size[1] = (r38->size[1] + r40->size[1]) + 1; emxEnsureCapacity((emxArray__common *)sampleUse, i16, (int32_T)sizeof(real_T), &hd_emlrtRTEI); high_i = r38->size[1]; for (i16 = 0; i16 < high_i; i16++) { low_ip1 = r38->size[0]; for (low_i = 0; low_i < low_ip1; low_i++) { sampleUse->data[low_i + sampleUse->size[0] * i16] = r38->data[low_i + r38->size[0] * i16]; } } high_i = r39->size[0]; for (i16 = 0; i16 < high_i; i16++) { sampleUse->data[i16 + sampleUse->size[0] * r38->size[1]] = r39->data[i16]; } emxFree_real_T(&r39); high_i = r40->size[1]; for (i16 = 0; i16 < high_i; i16++) { low_ip1 = r40->size[0]; for (low_i = 0; low_i < low_ip1; low_i++) { sampleUse->data[low_i + sampleUse->size[0] * ((i16 + r38->size[1]) + 1)] = r40->data[low_i + r40->size[0] * i16]; } } emxFree_real_T(&r40); emxFree_real_T(&r38); /* za kompatibilnost funkcije corrcoef v programu 'Octave', so bili v vrstici */ /* 73 dodani oglati oklepaji []. */ i = 0; b_emxInit_real_T(&b_sampleUse, 2, &hd_emlrtRTEI, TRUE); emxInit_real_T(&c_sampleUse, 1, &hd_emlrtRTEI, TRUE); emxInit_real_T(&d_sampleUse, 1, &hd_emlrtRTEI, TRUE); while (i <= perKnown1_size_idx_1 - 1) { j = 0; while (j <= perKnown1_size_idx_1 - 1) { i16 = sampleUse->size[1]; low_i = (int32_T)(1.0 + (real_T)i); emlrtDynamicBoundsCheckFastR2012b(low_i, 1, i16, &rd_emlrtBCI, emlrtRootTLSGlobal); i16 = sampleUse->size[1]; low_i = (int32_T)(1.0 + (real_T)j); emlrtDynamicBoundsCheckFastR2012b(low_i, 1, i16, &qd_emlrtBCI, emlrtRootTLSGlobal); i16 = sampleUse->size[0]; low_i = sampleUse->size[0]; emlrtDimSizeEqCheckFastR2012b(i16, low_i, &nb_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&pp_emlrtRSI, emlrtRootTLSGlobal); high_i = sampleUse->size[0]; low_ip1 = sampleUse->size[0]; i2 = sampleUse->size[0]; i16 = c_sampleUse->size[0]; c_sampleUse->size[0] = i2; emxEnsureCapacity((emxArray__common *)c_sampleUse, i16, (int32_T)sizeof (real_T), &hd_emlrtRTEI); for (i16 = 0; i16 < i2; i16++) { c_sampleUse->data[i16] = sampleUse->data[i16 + sampleUse->size[0] * i]; } i2 = sampleUse->size[0]; i16 = d_sampleUse->size[0]; d_sampleUse->size[0] = i2; emxEnsureCapacity((emxArray__common *)d_sampleUse, i16, (int32_T)sizeof (real_T), &hd_emlrtRTEI); for (i16 = 0; i16 < i2; i16++) { d_sampleUse->data[i16] = sampleUse->data[i16 + sampleUse->size[0] * j]; } i16 = b_sampleUse->size[0] * b_sampleUse->size[1]; b_sampleUse->size[0] = high_i; b_sampleUse->size[1] = 2; emxEnsureCapacity((emxArray__common *)b_sampleUse, i16, (int32_T)sizeof (real_T), &hd_emlrtRTEI); i16 = 0; while (i16 <= 0) { for (i16 = 0; i16 < high_i; i16++) { b_sampleUse->data[i16] = c_sampleUse->data[i16]; } i16 = 1; } i16 = 0; while (i16 <= 0) { for (i16 = 0; i16 < low_ip1; i16++) { b_sampleUse->data[i16 + b_sampleUse->size[0]] = d_sampleUse->data[i16]; } i16 = 1; } corrcoef(b_sampleUse, corrMatrix); emlrtPopRtStackR2012b(&pp_emlrtRSI, emlrtRootTLSGlobal); i16 = corrReqSamp->size[0]; low_i = 1 + i; low_ip1 = corrReqSamp->size[1]; i2 = 1 + j; corrReqSamp->data[(emlrtDynamicBoundsCheckFastR2012b(low_i, 1, i16, &ae_emlrtBCI, emlrtRootTLSGlobal) + corrReqSamp->size[0] * (emlrtDynamicBoundsCheckFastR2012b(i2, 1, low_ip1, &be_emlrtBCI, emlrtRootTLSGlobal) - 1)) - 1] = corrMatrix[2]; j++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, emlrtRootTLSGlobal); } i++; emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, emlrtRootTLSGlobal); } emxFree_real_T(&d_sampleUse); emxFree_real_T(&c_sampleUse); emxFree_real_T(&b_sampleUse); emxFree_real_T(&sampleUse); emxFree_real_T(&corrReqSamp); /* f = figure(); */ /* set(f,'Visible','off'); */ /* %imagesc(perKnown1,perKnown1,corrReqSamp) */ /* title('Sample correlations'); */ /* xlabel('T_1 (s)'); */ /* ylabel('T_2 (s)'); */ /* %colorbar('YLim',[0 1]); */ /* */ /* %% Error */ /* */ /* f = figure(); */ /* set(f,'Visible','off'); */ /* %imagesc(perKnown1,perKnown1,corrReqSamp-corrReq) */ /* title('Difference in the correlation (sample-model)'); */ /* xlabel('T_1 (s)'); */ /* ylabel('T_2 (s)'); */ /* %colorbar('YLim',[0 1]); */ /* */ /* %% contour plot */ /* */ /* f = figure(); */ /* set(f,'Visible','off'); */ /* %contour(perKnown1, perKnown1, corrReqSamp); */ /* set(gca,'yscale','log','xscale','log'); */ /* axis square; */ /* xlabel('T_1'); */ /* ylabel('T_2'); */ /* title('Sample correlation contour'); */ /* xlabel('T_1') */ /* ylabel('T_2') */ /* %colorbar('YLim',[0 1]); */ /* */ /* */ /* f = figure(); */ /* set(f,'Visible','off'); */ /* %contour(perKnown1, perKnown1, corrReq); */ /* set(gca,'yscale','log','xscale','log'); */ /* axis square; */ /* xlabel('T_1'); */ /* ylabel('T_2'); */ /* title('Baker and Jayaram (2008) conditional correlation contour'); */ /* xlabel('T_1') */ /* ylabel('T_2') */ /* %colorbar('YLim',[0 1]); */ emlrtHeapReferenceStackLeaveFcnR2012b(emlrtRootTLSGlobal); } /* End of code generation (conditionalCovariance.c) */