/* * CB_2008_nga_low.c * * Code generation for function 'CB_2008_nga_low' * * C source code generated on: Wed Aug 26 14:59:34 2015 * */ /* Include files */ #include "rt_nonfinite.h" #include "Select_Ground_Motions.h" #include "CB_2008_nga_low.h" #include "Select_Ground_Motions_emxutil.h" #include "sqrt.h" #include "mpower.h" #include "mrdivide.h" #include "CB_2008_nga_T0.h" #include "all.h" #include "exp.h" #include "log.h" #include "SP_1996.h" #include "Select_Ground_Motions_mexutil.h" #include "Select_Ground_Motions_data.h" /* Variable Definitions */ static emlrtRSInfo yq_emlrtRSI = { 100, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRSInfo ar_emlrtRSI = { 47, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRSInfo br_emlrtRSI = { 143, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRSInfo cr_emlrtRSI = { 160, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRSInfo dr_emlrtRSI = { 161, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRSInfo er_emlrtRSI = { 163, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRSInfo fr_emlrtRSI = { 165, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRSInfo gr_emlrtRSI = { 183, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRSInfo hr_emlrtRSI = { 184, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRSInfo ir_emlrtRSI = { 192, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRSInfo jr_emlrtRSI = { 193, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRSInfo kr_emlrtRSI = { 196, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRSInfo lr_emlrtRSI = { 198, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRSInfo mr_emlrtRSI = { 159, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRSInfo nr_emlrtRSI = { 175, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRSInfo or_emlrtRSI = { 182, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtRTEInfo qd_emlrtRTEI = { 105, 23, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtECInfo ic_emlrtECI = { -1, 100, 14, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtBCInfo ne_emlrtBCI = { -1, -1, 100, 14, "Sa(it)", "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m", 0 }; static emlrtECInfo jc_emlrtECI = { -1, 100, 21, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtBCInfo oe_emlrtBCI = { -1, -1, 100, 21, "sigma(it)", "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m", 0 }; static emlrtECInfo kc_emlrtECI = { 2, 198, 18, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtECInfo lc_emlrtECI = { 2, 196, 12, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtECInfo mc_emlrtECI = { 2, 193, 15, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtECInfo nc_emlrtECI = { 2, 179, 10, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtECInfo oc_emlrtECI = { 2, 165, 14, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtECInfo pc_emlrtECI = { 2, 163, 14, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtECInfo qc_emlrtECI = { 2, 161, 13, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtECInfo rc_emlrtECI = { 2, 147, 8, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtECInfo sc_emlrtECI = { 2, 143, 9, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtECInfo tc_emlrtECI = { 2, 138, 16, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtECInfo uc_emlrtECI = { 2, 136, 16, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; static emlrtECInfo vc_emlrtECI = { 2, 134, 12, "CB_2008_nga_low", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_low.m" }; /* Function Declarations */ static void c_CB_2008_nga_sub(real_T M, const real_T ip_data[24], const int32_T ip_size[2], real_T Rrup, real_T Rjb, real_T Ztor, real_T delta, real_T lambda, real_T Vs30, real_T Zvs, real_T arb, real_T ffltz, real_T fhngr, boolean_T Frv, boolean_T Fnm, real_T fhngm, real_T Sa_data[24], int32_T Sa_size[2], real_T sigma_data[24], int32_T sigma_size[2]); /* Function Definitions */ static void c_CB_2008_nga_sub(real_T M, const real_T ip_data[24], const int32_T ip_size[2], real_T Rrup, real_T Rjb, real_T Ztor, real_T delta, real_T lambda, real_T Vs30, real_T Zvs, real_T arb, real_T ffltz, real_T fhngr, boolean_T Frv, boolean_T Fnm, real_T fhngm, real_T Sa_data[24], int32_T Sa_size[2], real_T sigma_data[24], int32_T sigma_size[2]) { emxArray_real_T *y; emxArray_real_T *b_y; emxArray_real_T *c_y; int32_T fmag_size[2]; int32_T i; int32_T d_y; static const real_T dv37[24] = { -1.715, -1.68, -1.552, -1.209, -0.657, -0.314, -0.133, -0.486, -0.89, -1.171, -1.466, -2.569, -4.844, -6.406, -8.692, -9.701, -10.556, -11.212, -11.684, -12.505, -13.087, -1.715, 0.954, -5.27 }; real_T fmag_data[24]; static const real_T dv38[24] = { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.656, 0.972, 1.196, 1.513, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 0.5, 0.696, 1.6 }; int32_T fmag[2]; int32_T e_y[2]; real_T fhngz; static const real_T dv39[24] = { -0.53, -0.53, -0.53, -0.53, -0.53, -0.53, -0.53, -0.446, -0.362, -0.294, -0.186, -0.304, -0.578, -0.772, -1.046, -0.978, -0.638, -0.316, -0.07, -0.07, -0.07, -0.53, -0.309, -0.07 }; static const real_T dv40[24] = { -0.262, -0.262, -0.262, -0.267, -0.302, -0.324, -0.339, -0.398, -0.458, -0.511, -0.592, -0.536, -0.406, -0.314, -0.185, -0.236, -0.491, -0.77, -0.986, -0.656, -0.422, -0.262, -0.019, 0.0 }; int32_T fsed_size[2]; static const real_T dv41[24] = { -2.118, -2.123, -2.145, -2.199, -2.277, -2.318, -2.309, -2.22, -2.146, -2.095, -2.066, -2.041, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.118, -2.016, -2.0 }; real_T fsed_data[24]; int32_T fsed[2]; real_T tmp_data[24]; int32_T tmp_size[2]; static const real_T dv42[24] = { 5.6, 5.6, 5.6, 5.74, 7.09, 8.05, 8.79, 7.6, 6.58, 6.04, 5.3, 4.73, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 5.6, 4.0, 4.0 }; emxArray_real_T b_tmp_data; const mxArray *f_y; static const int32_T iv98[2] = { 1, 45 }; const mxArray *m36; char_T cv132[45]; static const char_T cv133[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 *g_y; static const int32_T iv99[2] = { 1, 21 }; char_T cv134[21]; static const char_T cv135[21] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T', 'L', 'A', 'B', ':', 'i', 'n', 'n', 'e', 'r', 'd', 'i', 'm' }; static const real_T dv43[24] = { 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.28, 0.255, 0.161, 0.094, 0.0, 0.0, 0.0, 0.0, 0.0, 0.28, 0.245, 0.0 }; int32_T fflt_size[2]; static const real_T dv44[24] = { -0.12, -0.12, -0.12, -0.12, -0.12, -0.099, -0.048, -0.012, 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.12, 0.0, 0.0 }; real_T fflt_data[24]; int32_T fflt[2]; boolean_T b; real_T fhngdelta; static const real_T dv45[24] = { 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.49, 0.371, 0.154, 0.0, 0.0, 0.0, 0.0, 0.49, 0.358, 0.0 }; boolean_T Vs30_data[24]; int32_T Vs30_size[2]; static const int16_T iv100[24] = { 865, 865, 908, 1054, 1086, 1032, 878, 748, 654, 587, 503, 457, 410, 400, 400, 400, 400, 400, 400, 400, 400, 865, 400, 400 }; emxArray_boolean_T b_Vs30_data; emxArray_real_T *h_y; real_T c_tmp_data[24]; int32_T b_tmp_size[2]; real_T b_b; static const real_T dv46[24] = { 1.058, 1.102, 1.174, 1.272, 1.438, 1.604, 1.928, 2.194, 2.351, 2.46, 2.587, 2.544, 2.133, 1.571, 0.406, -0.456, -0.82, -0.82, -0.82, -0.82, -0.82, 1.058, 1.694, -0.82 }; int32_T c_tmp_size[2]; static const real_T dv47[24] = { -1.186, -1.219, -1.273, -1.346, -1.471, -1.624, -1.931, -2.188, -2.381, -2.518, -2.657, -2.669, -2.401, -1.955, -1.025, -0.299, 0.0, 0.0, 0.0, 0.0, 0.0, -1.186, -1.955, 0.0 }; int32_T fsite_size[2]; real_T fsite_data[24]; static const real_T dv48[24] = { 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.077, 0.15, 0.253, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.04, 0.092, 0.3 }; static const real_T dv49[24] = { 0.61, 0.61, 0.61, 0.61, 0.61, 0.61, 0.61, 0.61, 0.7, 0.75, 0.85, 0.883, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.61, 1.0, 1.0 }; static const real_T dv50[24] = { 1.839, 1.84, 1.841, 1.843, 1.845, 1.847, 1.852, 1.856, 1.861, 1.865, 1.874, 1.883, 1.906, 1.929, 1.974, 2.019, 2.11, 2.2, 2.291, 2.517, 2.744, 1.839, 1.929, 2.744 }; const mxArray *i_y; static const int32_T iv101[2] = { 1, 45 }; const mxArray *j_y; static const int32_T iv102[2] = { 1, 21 }; boolean_T c_Vs30_data[24]; int32_T b_Vs30_size[2]; emxArray_boolean_T d_Vs30_data; int32_T d_tmp_size[2]; real_T d_tmp_data[24]; int32_T e_tmp_size[2]; static const real_T dv51[24] = { 0.478, 0.48, 0.498, 0.51, 0.52, 0.531, 0.532, 0.534, 0.534, 0.544, 0.541, 0.55, 0.568, 0.568, 0.564, 0.571, 0.558, 0.576, 0.601, 0.628, 0.667, 0.478, 0.484, 0.667 }; emxArray_real_T e_tmp_data; real_T f_tmp_data[24]; int32_T f_tmp_size[2]; emxArray_real_T g_tmp_data; emxArray_real_T b_fflt_data; static const real_T dv52[24] = { 1.0, 0.999, 0.989, 0.963, 0.922, 0.898, 0.89, 0.871, 0.852, 0.831, 0.785, 0.735, 0.628, 0.534, 0.411, 0.331, 0.289, 0.261, 0.2, 0.174, 0.174, 1.0, 0.691, 0.174 }; const mxArray *k_y; static const int32_T iv103[2] = { 1, 45 }; const mxArray *l_y; static const int32_T iv104[2] = { 1, 21 }; const mxArray *m_y; static const int32_T iv105[2] = { 1, 45 }; const mxArray *n_y; static const int32_T iv106[2] = { 1, 21 }; emxArray_real_T c_fflt_data; real_T h_tmp_data[24]; int32_T g_tmp_size[2]; static const real_T dv53[24] = { 0.219, 0.219, 0.235, 0.258, 0.292, 0.286, 0.28, 0.249, 0.24, 0.215, 0.217, 0.214, 0.227, 0.255, 0.296, 0.296, 0.326, 0.297, 0.359, 0.428, 0.485, 0.219, 0.203, 0.485 }; emxArray_real_T i_tmp_data; emxArray_real_T b_sigma_data; real_T j_tmp_data[24]; int32_T h_tmp_size[2]; static const real_T dv54[24] = { 0.166, 0.166, 0.165, 0.162, 0.158, 0.17, 0.18, 0.186, 0.191, 0.198, 0.206, 0.208, 0.221, 0.225, 0.222, 0.226, 0.229, 0.237, 0.237, 0.271, 0.29, 0.166, 0.19, 0.29 }; emxArray_real_T k_tmp_data; emlrtHeapReferenceStackEnterFcnR2012b(emlrtRootTLSGlobal); /* Magnitude dependence */ b_emxInit_real_T(&y, 2, &qd_emlrtRTEI, TRUE); b_emxInit_real_T(&b_y, 2, &qd_emlrtRTEI, TRUE); b_emxInit_real_T(&c_y, 2, &qd_emlrtRTEI, TRUE); if (M <= 5.5) { fmag_size[0] = 1; fmag_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fmag_data[d_y] = dv37[(int32_T)ip_data[d_y] - 1]; } d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[d_y] = dv38[(int32_T)ip_data[d_y] - 1] * M; } for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &vc_emlrtECI, emlrtRootTLSGlobal); fmag_size[0] = 1; i = ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fhngz = fmag_data[d_y] + y->data[d_y]; fmag_data[d_y] = fhngz; } } else if (M <= 6.5) { fmag_size[0] = 1; fmag_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fmag_data[d_y] = dv37[(int32_T)ip_data[d_y] - 1]; } d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[d_y] = dv38[(int32_T)ip_data[d_y] - 1] * M; } for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &uc_emlrtECI, emlrtRootTLSGlobal); d_y = b_y->size[0] * b_y->size[1]; b_y->size[0] = 1; b_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)b_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { b_y->data[d_y] = dv39[(int32_T)ip_data[d_y] - 1] * (M - 5.5); } for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = b_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &uc_emlrtECI, emlrtRootTLSGlobal); fmag_size[0] = 1; i = ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fhngz = (fmag_data[d_y] + y->data[d_y]) + b_y->data[d_y]; fmag_data[d_y] = fhngz; } } else { fmag_size[0] = 1; fmag_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fmag_data[d_y] = dv37[(int32_T)ip_data[d_y] - 1]; } d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[d_y] = dv38[(int32_T)ip_data[d_y] - 1] * M; } for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &tc_emlrtECI, emlrtRootTLSGlobal); d_y = b_y->size[0] * b_y->size[1]; b_y->size[0] = 1; b_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)b_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { b_y->data[d_y] = dv39[(int32_T)ip_data[d_y] - 1] * (M - 5.5); } for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = b_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &tc_emlrtECI, emlrtRootTLSGlobal); d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = dv40[(int32_T)ip_data[d_y] - 1] * (M - 6.5); } for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = c_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &tc_emlrtECI, emlrtRootTLSGlobal); fmag_size[0] = 1; i = ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fhngz = ((fmag_data[d_y] + y->data[d_y]) + b_y->data[d_y]) + c_y->data[d_y]; fmag_data[d_y] = fhngz; } } /* Distance dependence */ fsed_size[0] = 1; fsed_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fsed_data[d_y] = dv41[(int32_T)ip_data[d_y] - 1]; } d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[d_y] = 0.17 * M; } for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = fsed_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fsed, e_y, &sc_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&br_emlrtRSI, emlrtRootTLSGlobal); fhngz = Rrup * Rrup; d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[d_y] += fsed_data[d_y]; } tmp_size[0] = 1; tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { tmp_data[d_y] = dv42[(int32_T)ip_data[d_y] - 1]; } b_tmp_data.data = (real_T *)&tmp_data; b_tmp_data.size = (int32_T *)&tmp_size; b_tmp_data.allocatedSize = 24; b_tmp_data.numDimensions = 2; b_tmp_data.canFreeData = FALSE; mpower(&b_tmp_data, c_y); d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = c_y->size[0]; d_y = c_y->size[1]; i *= d_y; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] += fhngz; } c_sqrt(c_y); c_log(c_y); emlrtPushRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); if (!(y->size[1] == 1)) { if ((y->size[1] == 1) || (c_y->size[1] == 1)) { emlrtPushRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); f_y = NULL; m36 = mxCreateCharArray(2, iv98); for (i = 0; i < 45; i++) { cv132[i] = cv133[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m36, cv132); emlrtAssign(&f_y, m36); error(message(f_y, &r_emlrtMCI), &s_emlrtMCI); emlrtPopRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); g_y = NULL; m36 = mxCreateCharArray(2, iv99); for (i = 0; i < 21; i++) { cv134[i] = cv135[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m36, cv134); emlrtAssign(&g_y, m36); error(message(g_y, &t_emlrtMCI), &u_emlrtMCI); emlrtPopRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); } } emlrtPopRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); fhngz = y->data[0]; d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = c_y->size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[y->size[0] * d_y] = fhngz * c_y->data[c_y->size[0] * d_y]; } emlrtPopRtStackR2012b(&br_emlrtRSI, emlrtRootTLSGlobal); /* Style of faulting */ d_y = b_y->size[0] * b_y->size[1]; b_y->size[0] = 1; b_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)b_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { b_y->data[d_y] = dv43[(int32_T)ip_data[d_y] - 1] * (real_T)Frv * ffltz; } fflt_size[0] = 1; fflt_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fflt_data[d_y] = dv44[(int32_T)ip_data[d_y] - 1] * (real_T)Fnm; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = b_y->size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { fflt[d_y] = fflt_size[d_y]; } emlrtSizeEqCheck2DFastR2012b(e_y, fflt, &rc_emlrtECI, emlrtRootTLSGlobal); fflt_size[0] = 1; fflt_size[1] = b_y->size[1]; i = b_y->size[0] * b_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fflt_data[d_y] += b_y->data[d_y]; } /* Hanging-wall effects */ if ((Ztor >= 0.0) && (Ztor < 20.0)) { b = TRUE; } else { b = FALSE; } fhngz = (20.0 - Ztor) / 20.0 * (real_T)b; fhngdelta = (real_T)(delta <= 70.0) + (90.0 - delta) / 20.0 * (real_T)(delta > 70.0); d_y = b_y->size[0] * b_y->size[1]; b_y->size[0] = 1; b_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)b_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { b_y->data[d_y] = dv45[(int32_T)ip_data[d_y] - 1] * fhngr * fhngm * fhngz * fhngdelta; } /* Site conditions */ emlrtPushRtStackR2012b(&mr_emlrtRSI, emlrtRootTLSGlobal); Vs30_size[0] = 1; Vs30_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { Vs30_data[d_y] = (Vs30 < iv100[(int32_T)ip_data[d_y] - 1]); } b_Vs30_data.data = (boolean_T *)&Vs30_data; b_Vs30_data.size = (int32_T *)&Vs30_size; b_Vs30_data.allocatedSize = 24; b_Vs30_data.numDimensions = 2; b_Vs30_data.canFreeData = FALSE; b = b_all(&b_Vs30_data); emlrtPopRtStackR2012b(&mr_emlrtRSI, emlrtRootTLSGlobal); b_emxInit_real_T(&h_y, 2, &qd_emlrtRTEI, TRUE); if (b) { emlrtPushRtStackR2012b(&cr_emlrtRSI, emlrtRootTLSGlobal); fhngz = CB_2008_nga_T0(M, Rrup, Rjb, Ztor, delta, lambda, Zvs, arb); emlrtPopRtStackR2012b(&cr_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&dr_emlrtRSI, emlrtRootTLSGlobal); b_tmp_size[0] = 1; b_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_tmp_data[d_y] = iv100[(int32_T)ip_data[d_y] - 1]; } b_b = c_mrdivide(Vs30, c_tmp_data, b_tmp_size); b_log(&b_b); d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = dv46[(int32_T)ip_data[d_y] - 1] * b_b; } emlrtPopRtStackR2012b(&dr_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&dr_emlrtRSI, emlrtRootTLSGlobal); c_tmp_size[0] = 1; c_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_tmp_data[d_y] = iv100[(int32_T)ip_data[d_y] - 1]; } b_b = b_mpower(c_mrdivide(Vs30, c_tmp_data, c_tmp_size)); fhngdelta = fhngz + 1.88; b_log(&fhngdelta); fhngz += 1.88 * b_b; b_log(&fhngz); b_b = fhngz - fhngdelta; d_y = h_y->size[0] * h_y->size[1]; h_y->size[0] = 1; h_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)h_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { h_y->data[d_y] = dv47[(int32_T)ip_data[d_y] - 1] * b_b; } emlrtPopRtStackR2012b(&dr_emlrtRSI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = c_y->size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = h_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(e_y, fsed, &qc_emlrtECI, emlrtRootTLSGlobal); fsite_size[0] = 1; fsite_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fsite_data[d_y] = c_y->data[d_y] + h_y->data[d_y]; } } else if (Vs30 < 1100.0) { fsite_size[0] = 1; fsite_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fsite_data[d_y] = dv46[(int32_T)ip_data[d_y] - 1]; } d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = dv47[(int32_T)ip_data[d_y] - 1] * 1.18; } for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = fsite_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = c_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fsed, e_y, &pc_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&er_emlrtRSI, emlrtRootTLSGlobal); b_tmp_size[0] = 1; b_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_tmp_data[d_y] = iv100[(int32_T)ip_data[d_y] - 1]; } b_b = c_mrdivide(Vs30, c_tmp_data, b_tmp_size); b_log(&b_b); fsite_size[0] = 1; i = ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fhngz = (fsite_data[d_y] + c_y->data[d_y]) * b_b; fsite_data[d_y] = fhngz; } emlrtPopRtStackR2012b(&er_emlrtRSI, emlrtRootTLSGlobal); } else { fsite_size[0] = 1; fsite_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fsite_data[d_y] = dv46[(int32_T)ip_data[d_y] - 1]; } d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = dv47[(int32_T)ip_data[d_y] - 1] * 1.18; } for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = fsite_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = c_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fsed, e_y, &oc_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&fr_emlrtRSI, emlrtRootTLSGlobal); b_tmp_size[0] = 1; b_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_tmp_data[d_y] = iv100[(int32_T)ip_data[d_y] - 1]; } b_b = b_mrdivide(c_tmp_data, b_tmp_size); b_log(&b_b); fsite_size[0] = 1; i = ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fhngz = (fsite_data[d_y] + c_y->data[d_y]) * b_b; fsite_data[d_y] = fhngz; } emlrtPopRtStackR2012b(&fr_emlrtRSI, emlrtRootTLSGlobal); } /* Sediment effects */ if (Zvs < 1.0) { fsed_size[0] = 1; fsed_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fsed_data[d_y] = dv48[(int32_T)ip_data[d_y] - 1] * (Zvs - 1.0); } } else if (Zvs <= 3.0) { fsed_size[0] = 1; fsed_size[1] = 1; fsed_data[0] = 0.0; } else { emlrtPushRtStackR2012b(&nr_emlrtRSI, emlrtRootTLSGlobal); d_y = h_y->size[0] * h_y->size[1]; h_y->size[0] = 1; h_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)h_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { h_y->data[d_y] = dv49[(int32_T)ip_data[d_y] - 1]; } d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = dv50[(int32_T)ip_data[d_y] - 1]; } emlrtPushRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); if (!(h_y->size[1] == 1)) { if ((h_y->size[1] == 1) || (c_y->size[1] == 1)) { emlrtPushRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); i_y = NULL; m36 = mxCreateCharArray(2, iv101); for (i = 0; i < 45; i++) { cv132[i] = cv133[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m36, cv132); emlrtAssign(&i_y, m36); error(message(i_y, &r_emlrtMCI), &s_emlrtMCI); emlrtPopRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); j_y = NULL; m36 = mxCreateCharArray(2, iv102); for (i = 0; i < 21; i++) { cv134[i] = cv135[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m36, cv134); emlrtAssign(&j_y, m36); error(message(j_y, &t_emlrtMCI), &u_emlrtMCI); emlrtPopRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); } } emlrtPopRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); b_b = 1.0 - muDoubleScalarExp(-0.25 * (Zvs - 3.0)); fsed_size[0] = 1; fsed_size[1] = c_y->size[1]; fhngz = h_y->data[0]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fsed_data[d_y] = fhngz * c_y->data[d_y] * 0.47236655274101469 * b_b; } emlrtPopRtStackR2012b(&nr_emlrtRSI, emlrtRootTLSGlobal); } /* Median value */ for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &nc_emlrtECI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { fflt[d_y] = fflt_size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, fflt, &nc_emlrtECI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = b_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, e_y, &nc_emlrtECI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; fsed[d_y] = fsite_size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, fsed, &nc_emlrtECI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fmag[d_y] = fmag_size[d_y]; fsed[d_y] = fsed_size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fmag, fsed, &nc_emlrtECI, emlrtRootTLSGlobal); d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = fmag_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = fmag_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[d_y] = ((((fmag_data[d_y] + y->data[d_y]) + fflt_data[d_y]) + b_y->data[d_y]) + fsite_data[d_y]) + fsed_data[d_y]; } emxFree_real_T(&b_y); b_exp(y); Sa_size[0] = 1; Sa_size[1] = y->size[1]; i = y->size[0] * y->size[1]; for (d_y = 0; d_y < i; d_y++) { Sa_data[d_y] = y->data[d_y]; } /* Standard deviation computations */ emlrtPushRtStackR2012b(&or_emlrtRSI, emlrtRootTLSGlobal); b_Vs30_size[0] = 1; b_Vs30_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_Vs30_data[d_y] = (Vs30 < iv100[(int32_T)ip_data[d_y] - 1]); } d_Vs30_data.data = (boolean_T *)&c_Vs30_data; d_Vs30_data.size = (int32_T *)&b_Vs30_size; d_Vs30_data.allocatedSize = 24; d_Vs30_data.numDimensions = 2; d_Vs30_data.canFreeData = FALSE; b = b_all(&d_Vs30_data); emlrtPopRtStackR2012b(&or_emlrtRSI, emlrtRootTLSGlobal); if (b) { emlrtPushRtStackR2012b(&gr_emlrtRSI, emlrtRootTLSGlobal); fhngz = CB_2008_nga_T0(M, Rrup, Rjb, Ztor, delta, lambda, Zvs, arb); emlrtPopRtStackR2012b(&gr_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&hr_emlrtRSI, emlrtRootTLSGlobal); d_tmp_size[0] = 1; d_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_tmp_data[d_y] = iv100[(int32_T)ip_data[d_y] - 1]; } b_b = b_mpower(c_mrdivide(Vs30, c_tmp_data, d_tmp_size)); b_b = c_mpower(fhngz + 1.88 * b_b) - c_mpower(fhngz + 1.88); fflt_size[0] = 1; fflt_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { fflt_data[d_y] = dv47[(int32_T)ip_data[d_y] - 1] * fhngz * b_b; } emlrtPopRtStackR2012b(&hr_emlrtRSI, emlrtRootTLSGlobal); } else { fflt_size[0] = 1; fflt_size[1] = 1; fflt_data[0] = 0.0; } emlrtPushRtStackR2012b(&ir_emlrtRSI, emlrtRootTLSGlobal); e_tmp_size[0] = 1; e_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { d_tmp_data[d_y] = dv51[(int32_T)ip_data[d_y] - 1]; } e_tmp_data.data = (real_T *)&d_tmp_data; e_tmp_data.size = (int32_T *)&e_tmp_size; e_tmp_data.allocatedSize = 24; e_tmp_data.numDimensions = 2; e_tmp_data.canFreeData = FALSE; mpower(&e_tmp_data, c_y); d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = c_y->size[0]; d_y = c_y->size[1]; i *= d_y; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] -= 0.09; } c_sqrt(c_y); fsite_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fsite_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&ir_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&jr_emlrtRSI, emlrtRootTLSGlobal); f_tmp_size[0] = 1; f_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { f_tmp_data[d_y] = dv51[(int32_T)ip_data[d_y] - 1]; } g_tmp_data.data = (real_T *)&f_tmp_data; g_tmp_data.size = (int32_T *)&f_tmp_size; g_tmp_data.allocatedSize = 24; g_tmp_data.numDimensions = 2; g_tmp_data.canFreeData = FALSE; mpower(&g_tmp_data, c_y); fsed_size[0] = 1; fsed_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fsed_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&jr_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&jr_emlrtRSI, emlrtRootTLSGlobal); b_fflt_data.data = (real_T *)&fflt_data; b_fflt_data.size = (int32_T *)&fflt_size; b_fflt_data.allocatedSize = 24; b_fflt_data.numDimensions = 2; b_fflt_data.canFreeData = FALSE; mpower(&b_fflt_data, h_y); d_y = h_y->size[0] * h_y->size[1]; h_y->size[0] = 1; emxEnsureCapacity((emxArray__common *)h_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = h_y->size[0]; d_y = h_y->size[1]; i *= d_y; for (d_y = 0; d_y < i; d_y++) { h_y->data[d_y] *= 0.138484; } emlrtPopRtStackR2012b(&jr_emlrtRSI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = fsed_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = h_y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fsed, e_y, &mc_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&jr_emlrtRSI, emlrtRootTLSGlobal); d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = fflt_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = fflt_size[0] * fflt_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[d_y] = 2.0 * fflt_data[d_y]; } d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = dv52[(int32_T)ip_data[d_y] - 1]; } emlrtPushRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); if (!(y->size[1] == 1)) { if ((y->size[1] == 1) || (c_y->size[1] == 1)) { emlrtPushRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); k_y = NULL; m36 = mxCreateCharArray(2, iv103); for (i = 0; i < 45; i++) { cv132[i] = cv133[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m36, cv132); emlrtAssign(&k_y, m36); error(message(k_y, &r_emlrtMCI), &s_emlrtMCI); emlrtPopRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); l_y = NULL; m36 = mxCreateCharArray(2, iv104); for (i = 0; i < 21; i++) { cv134[i] = cv135[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m36, cv134); emlrtAssign(&l_y, m36); error(message(l_y, &t_emlrtMCI), &u_emlrtMCI); emlrtPopRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); } } emlrtPopRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); fhngz = y->data[0]; d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = c_y->size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[y->size[0] * d_y] = fhngz * c_y->data[c_y->size[0] * d_y]; } emlrtPushRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); if (!(y->size[1] == 1)) { if ((y->size[1] == 1) || (fsite_size[1] == 1)) { emlrtPushRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); m_y = NULL; m36 = mxCreateCharArray(2, iv105); for (i = 0; i < 45; i++) { cv132[i] = cv133[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m36, cv132); emlrtAssign(&m_y, m36); error(message(m_y, &r_emlrtMCI), &s_emlrtMCI); emlrtPopRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); n_y = NULL; m36 = mxCreateCharArray(2, iv106); for (i = 0; i < 21; i++) { cv134[i] = cv135[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m36, cv134); emlrtAssign(&n_y, m36); error(message(n_y, &t_emlrtMCI), &u_emlrtMCI); emlrtPopRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); } } emlrtPopRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); fhngz = y->data[0]; d_y = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = fsite_size[1]; emxEnsureCapacity((emxArray__common *)y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = fsite_size[1]; for (d_y = 0; d_y < i; d_y++) { y->data[y->size[0] * d_y] = fhngz * fsite_data[d_y] * 0.37213438432910229; } emlrtPopRtStackR2012b(&jr_emlrtRSI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = fsed_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { e_y[d_y] = y->size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fsed, e_y, &mc_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&jr_emlrtRSI, emlrtRootTLSGlobal); d_y = h_y->size[0] * h_y->size[1]; h_y->size[0] = 1; h_y->size[1] = fsed_size[1]; emxEnsureCapacity((emxArray__common *)h_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = fsed_size[1]; for (d_y = 0; d_y < i; d_y++) { h_y->data[d_y] = (fsed_data[d_y] + h_y->data[d_y]) + y->data[d_y]; } emxFree_real_T(&y); c_sqrt(h_y); fflt_size[0] = 1; fflt_size[1] = h_y->size[1]; i = h_y->size[0] * h_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fflt_data[d_y] = h_y->data[d_y]; } emxFree_real_T(&h_y); emlrtPopRtStackR2012b(&jr_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&kr_emlrtRSI, emlrtRootTLSGlobal); c_fflt_data.data = (real_T *)&fflt_data; c_fflt_data.size = (int32_T *)&fflt_size; c_fflt_data.allocatedSize = 24; c_fflt_data.numDimensions = 2; c_fflt_data.canFreeData = FALSE; mpower(&c_fflt_data, c_y); fsed_size[0] = 1; fsed_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fsed_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&kr_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&kr_emlrtRSI, emlrtRootTLSGlobal); g_tmp_size[0] = 1; g_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { h_tmp_data[d_y] = dv53[(int32_T)ip_data[d_y] - 1]; } i_tmp_data.data = (real_T *)&h_tmp_data; i_tmp_data.size = (int32_T *)&g_tmp_size; i_tmp_data.allocatedSize = 24; i_tmp_data.numDimensions = 2; i_tmp_data.canFreeData = FALSE; mpower(&i_tmp_data, c_y); fflt_size[0] = 1; fflt_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fflt_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&kr_emlrtRSI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = fsed_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { fflt[d_y] = fflt_size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fsed, fflt, &lc_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&kr_emlrtRSI, emlrtRootTLSGlobal); d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = fsed_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = fsed_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = fsed_data[d_y] + fflt_data[d_y]; } c_sqrt(c_y); sigma_size[0] = 1; sigma_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { sigma_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&kr_emlrtRSI, emlrtRootTLSGlobal); if (arb == 1.0) { emlrtPushRtStackR2012b(&lr_emlrtRSI, emlrtRootTLSGlobal); b_sigma_data.data = (real_T *)sigma_data; b_sigma_data.size = (int32_T *)sigma_size; b_sigma_data.allocatedSize = 24; b_sigma_data.numDimensions = 2; b_sigma_data.canFreeData = FALSE; mpower(&b_sigma_data, c_y); fsed_size[0] = 1; fsed_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fsed_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&lr_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&lr_emlrtRSI, emlrtRootTLSGlobal); h_tmp_size[0] = 1; h_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (d_y = 0; d_y < i; d_y++) { j_tmp_data[d_y] = dv54[(int32_T)ip_data[d_y] - 1]; } k_tmp_data.data = (real_T *)&j_tmp_data; k_tmp_data.size = (int32_T *)&h_tmp_size; k_tmp_data.allocatedSize = 24; k_tmp_data.numDimensions = 2; k_tmp_data.canFreeData = FALSE; mpower(&k_tmp_data, c_y); fflt_size[0] = 1; fflt_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { fflt_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&lr_emlrtRSI, emlrtRootTLSGlobal); for (d_y = 0; d_y < 2; d_y++) { fsed[d_y] = fsed_size[d_y]; } for (d_y = 0; d_y < 2; d_y++) { fflt[d_y] = fflt_size[d_y]; } emlrtSizeEqCheck2DFastR2012b(fsed, fflt, &kc_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&lr_emlrtRSI, emlrtRootTLSGlobal); d_y = c_y->size[0] * c_y->size[1]; c_y->size[0] = 1; c_y->size[1] = fsed_size[1]; emxEnsureCapacity((emxArray__common *)c_y, d_y, (int32_T)sizeof(real_T), &qd_emlrtRTEI); i = fsed_size[1]; for (d_y = 0; d_y < i; d_y++) { c_y->data[d_y] = fsed_data[d_y] + fflt_data[d_y]; } c_sqrt(c_y); sigma_size[0] = 1; sigma_size[1] = c_y->size[1]; i = c_y->size[0] * c_y->size[1]; for (d_y = 0; d_y < i; d_y++) { sigma_data[d_y] = c_y->data[d_y]; } emlrtPopRtStackR2012b(&lr_emlrtRSI, emlrtRootTLSGlobal); } emxFree_real_T(&c_y); emlrtHeapReferenceStackLeaveFcnR2012b(emlrtRootTLSGlobal); } void CB_2008_nga_low(real_T M, real_T T, real_T Rrup, real_T Rjb, real_T Ztor, real_T delta, real_T lambda, real_T Vs30, real_T Zvs, real_T arb, real_T Sa_data[1], int32_T Sa_size[2], real_T sigma_data[1], int32_T sigma_size[2]) { real_T fhngr; real_T c; int32_T idx; int32_T ii; boolean_T exitg2; boolean_T guard2 = FALSE; static const real_T period[24] = { 0.01, 0.02, 0.03, 0.05, 0.075, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 7.5, 10.0, 0.0, -1.0, -10.0 }; int32_T i21; int8_T ii_data[24]; boolean_T exitg1; boolean_T guard1 = FALSE; int32_T tmp_data[24]; int8_T b_ii_data[24]; int32_T i22; real_T c_ii_data[24]; int32_T ii_size[2]; real_T b_Ztor; real_T b_M; int32_T tmp_size[2]; real_T b_tmp_data[24]; int32_T b_tmp_size[2]; real_T c_tmp_data[24]; /* by Yoshifumi Yamamoto, 11/10/08 */ /* Stanford University */ /* yama4423@stanford.edu */ /* fix bug 2009/05/05 */ /* */ /* Campbell-Bozorgnia attenuation equation, 2008 */ /* */ /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ /* Input Variables */ /* M = Magnitude */ /* T = Period (sec); Use -1 for PGV computation and -10 for PGD */ /* computation */ /* Use 1000 for output the array of Sa with period */ /* Rrup = Closest distance coseismic rupture (km) */ /* Rjb = Joyner-Boore distance (km) */ /* Ztor = Depth to the top of coseismic rupture (km) */ /* delta = average dip of the rupture place (degree) */ /* lambda = rake angle (degree) */ /* Vs30 = shear wave velocity averaged over top 30 m (m/s) */ /* Zvs = Depth to the 2.5 km/s shear-wave velocity horizon (km) */ /* arb = 1 for arbitrary component sigma */ /* = 0 for average component sigma */ /* d */ /* Output Variables */ /* Sa = Median spectral acceleration prediction */ /* sigma = logarithmic standard deviation of spectral acceleration */ /* prediction */ /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ /* Coefficients */ /* Style of faulting */ if (Rjb == 0.0) { fhngr = 1.0; } else if (Ztor < 1.0) { emlrtPushRtStackR2012b(&ar_emlrtRSI, emlrtRootTLSGlobal); fhngr = Rjb * Rjb; if (fhngr + 1.0 < 0.0) { emlrtPushRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); e_eml_error(); emlrtPopRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); } c = Rjb * Rjb; if (c + 1.0 < 0.0) { emlrtPushRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); e_eml_error(); emlrtPopRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); } fhngr = (muDoubleScalarMax(Rrup, muDoubleScalarSqrt(fhngr + 1.0)) - Rjb) / muDoubleScalarMax(Rrup, muDoubleScalarSqrt(c + 1.0)); emlrtPopRtStackR2012b(&ar_emlrtRSI, emlrtRootTLSGlobal); } else { fhngr = (Rrup - Rjb) / Rrup; } Sa_size[0] = 1; Sa_size[1] = 1; Sa_data[0] = 0.0; sigma_size[0] = 1; sigma_size[1] = 1; sigma_data[0] = 0.0; /* interpolate between periods if neccesary */ idx = 0; ii = 1; exitg2 = FALSE; while ((exitg2 == FALSE) && (ii < 25)) { guard2 = FALSE; if (period[ii - 1] == T) { idx++; if (idx >= 24) { exitg2 = TRUE; } else { guard2 = TRUE; } } else { guard2 = TRUE; } if (guard2 == TRUE) { ii++; } } if (1 > idx) { i21 = 0; } else { i21 = idx; } if (i21 == 0) { /* T_low = max(period(find(periodTeach))); */ /* [sa_low sigma_low] = CB_2008_nga (M, T_low, Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb, ffltz, fhngr, Frv, Fnm, fhngm); */ /* [sa_hi sigma_hi] = CB_2008_nga (M, T_hi, Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb, ffltz, fhngr, Frv, Fnm, fhngm); */ /* [sa_low sigma_low] = CB_2008_nga (M, T_low, Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb); */ /* [sa_hi sigma_hi] = CB_2008_nga (M, T_hi, Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb); */ /* x = [log(T_low) log(T_hi)]; */ /* Y_sa = [log(sa_low) log(sa_hi)]; */ /* Y_sigma = [sigma_low sigma_hi]; */ /* Sa(it) = exp(interp1(x,Y_sa,log(Teach))); */ /* sigma(it) = interp1(x,Y_sigma,log(Teach)); */ } else { idx = 0; ii = 1; exitg1 = FALSE; while ((exitg1 == FALSE) && (ii < 25)) { guard1 = FALSE; if (period[ii - 1] == T) { idx++; ii_data[idx - 1] = (int8_T)ii; if (idx >= 24) { exitg1 = TRUE; } else { guard1 = TRUE; } } else { guard1 = TRUE; } if (guard1 == TRUE) { ii++; } } if (1 > idx) { idx = 0; } for (ii = 0; ii < idx; ii++) { tmp_data[ii] = 1 + ii; } for (ii = 0; ii < idx; ii++) { i22 = 0; while (i22 <= 0) { b_ii_data[ii] = ii_data[tmp_data[ii] - 1]; i22 = 1; } } for (ii = 0; ii < idx; ii++) { ii_data[ii] = b_ii_data[ii]; } emlrtPushRtStackR2012b(&yq_emlrtRSI, emlrtRootTLSGlobal); ii_size[0] = 1; ii_size[1] = idx; for (ii = 0; ii < idx; ii++) { c_ii_data[ii] = ii_data[ii]; } if (Ztor < 1.0) { b_Ztor = Ztor; } else { b_Ztor = 1.0; } if (M <= 6.0) { b_M = 0.0; } else if (M < 6.5) { b_M = 2.0 * (M - 6.0); } else { b_M = 1.0; } c_CB_2008_nga_sub(M, c_ii_data, ii_size, Rrup, Rjb, Ztor, delta, lambda, Vs30, Zvs, arb, b_Ztor, fhngr, (lambda > 30.0) && (lambda < 150.0), (lambda > -150.0) && (lambda < -30.0), b_M, c_tmp_data, b_tmp_size, b_tmp_data, tmp_size); emlrtPopRtStackR2012b(&yq_emlrtRSI, emlrtRootTLSGlobal); emlrtSizeEqCheck1DFastR2012b(1, b_tmp_size[1], &ic_emlrtECI, emlrtRootTLSGlobal); emlrtDynamicBoundsCheckFastR2012b(1, 1, b_tmp_size[1], &ne_emlrtBCI, emlrtRootTLSGlobal); Sa_data[0] = c_tmp_data[0]; emlrtSizeEqCheck1DFastR2012b(1, tmp_size[1], &jc_emlrtECI, emlrtRootTLSGlobal); emlrtDynamicBoundsCheckFastR2012b(1, 1, tmp_size[1], &oe_emlrtBCI, emlrtRootTLSGlobal); sigma_data[0] = b_tmp_data[0]; } } /* End of code generation (CB_2008_nga_low.c) */