/* * CB_2008_nga_T0.c * * Code generation for function 'CB_2008_nga_T0' * * 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_T0.h" #include "Select_Ground_Motions_emxutil.h" #include "sqrt.h" #include "mpower.h" #include "exp.h" #include "log.h" #include "mrdivide.h" #include "SP_1996.h" #include "Select_Ground_Motions_mexutil.h" #include "Select_Ground_Motions_data.h" /* Variable Definitions */ static emlrtRSInfo nq_emlrtRSI = { 142, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtRSInfo oq_emlrtRSI = { 164, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtRSInfo pq_emlrtRSI = { 190, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtRSInfo qq_emlrtRSI = { 191, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtRSInfo rq_emlrtRSI = { 194, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtRSInfo sq_emlrtRSI = { 196, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtRSInfo tq_emlrtRSI = { 45, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtRSInfo uq_emlrtRSI = { 99, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtRSInfo vq_emlrtRSI = { 174, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtRTEInfo od_emlrtRTEI = { 104, 23, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtBCInfo le_emlrtBCI = { -1, -1, 99, 14, "Sa(it)", "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m", 0 }; static emlrtECInfo vb_emlrtECI = { -1, 99, 14, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtBCInfo me_emlrtBCI = { -1, -1, 99, 21, "sigma(it)", "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m", 0 }; static emlrtECInfo wb_emlrtECI = { -1, 99, 21, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtECInfo xb_emlrtECI = { 2, 196, 18, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtECInfo yb_emlrtECI = { 2, 194, 12, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtECInfo ac_emlrtECI = { 2, 191, 15, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtECInfo bc_emlrtECI = { 2, 178, 10, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtECInfo cc_emlrtECI = { 2, 164, 14, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtECInfo dc_emlrtECI = { 2, 146, 8, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtECInfo ec_emlrtECI = { 2, 142, 9, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtECInfo fc_emlrtECI = { 2, 137, 16, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtECInfo gc_emlrtECI = { 2, 135, 16, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; static emlrtECInfo hc_emlrtECI = { 2, 133, 12, "CB_2008_nga_T0", "/home/sebenik/Projects/Ground_Motion_Selection/GMS_con_cms_1gmc_dynamicInput_501_jure/CB_2008_nga_T0.m" }; /* Function Declarations */ static void b_CB_2008_nga_sub(real_T M, const real_T ip_data[24], const int32_T ip_size[2], real_T Rrup, real_T Ztor, real_T delta, 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 b_CB_2008_nga_sub(real_T M, const real_T ip_data[24], const int32_T ip_size[2], real_T Rrup, real_T Ztor, real_T delta, 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 b; static const real_T dv20[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 dv21[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 d_y[2]; real_T fhngz; static const real_T dv22[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 dv23[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 tmp_size[2]; static const real_T dv24[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 tmp_data[24]; real_T b_tmp_data[24]; int32_T b_tmp_size[2]; static const real_T dv25[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_b; emxArray_real_T c_tmp_data; const mxArray *e_y; static const int32_T iv90[2] = { 1, 45 }; const mxArray *m34; char_T cv126[45]; static const char_T cv127[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 *f_y; static const int32_T iv91[2] = { 1, 21 }; char_T cv128[21]; static const char_T cv129[21] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T', 'L', 'A', 'B', ':', 'i', 'n', 'n', 'e', 'r', 'd', 'i', 'm' }; static const real_T dv26[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 dv27[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 c_b; real_T fhngdelta; static const real_T dv28[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 }; static const real_T dv29[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 }; real_T d_tmp_data[24]; int32_T c_tmp_size[2]; static const int16_T iv92[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 }; static const real_T dv30[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 fsed_size[2]; static const real_T dv31[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 }; real_T fsed_data[24]; emxArray_real_T *a; static const real_T dv32[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 dv33[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 *g_y; static const int32_T iv93[2] = { 1, 45 }; const mxArray *h_y; static const int32_T iv94[2] = { 1, 21 }; real_T e_tmp_data[24]; int32_T d_tmp_size[2]; static const real_T dv34[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 f_tmp_data; real_T g_tmp_data[24]; int32_T e_tmp_size[2]; emxArray_real_T h_tmp_data; const mxArray *i_y; static const int32_T iv95[2] = { 1, 45 }; const mxArray *j_y; static const int32_T iv96[2] = { 1, 21 }; emxArray_real_T b_fsed_data; real_T i_tmp_data[24]; int32_T f_tmp_size[2]; static const real_T dv35[24] = { 0.219, 0.219, 0.235, 0.0, 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 j_tmp_data; emxArray_real_T b_sigma_data; real_T k_tmp_data[24]; int32_T g_tmp_size[2]; static const real_T dv36[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 l_tmp_data; emlrtHeapReferenceStackEnterFcnR2012b(emlrtRootTLSGlobal); /* Magnitude dependence */ b_emxInit_real_T(&y, 2, &od_emlrtRTEI, TRUE); b_emxInit_real_T(&b_y, 2, &od_emlrtRTEI, TRUE); b_emxInit_real_T(&c_y, 2, &od_emlrtRTEI, TRUE); if (M <= 5.5) { fmag_size[0] = 1; fmag_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { fmag_data[b] = dv20[(int32_T)ip_data[b] - 1]; } b = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { y->data[b] = dv21[(int32_T)ip_data[b] - 1] * M; } for (b = 0; b < 2; b++) { fmag[b] = fmag_size[b]; } for (b = 0; b < 2; b++) { d_y[b] = y->size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, d_y, &hc_emlrtECI, emlrtRootTLSGlobal); fmag_size[0] = 1; i = ip_size[1]; for (b = 0; b < i; b++) { fhngz = fmag_data[b] + y->data[b]; fmag_data[b] = fhngz; } } else if (M <= 6.5) { fmag_size[0] = 1; fmag_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { fmag_data[b] = dv20[(int32_T)ip_data[b] - 1]; } b = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { y->data[b] = dv21[(int32_T)ip_data[b] - 1] * M; } for (b = 0; b < 2; b++) { fmag[b] = fmag_size[b]; } for (b = 0; b < 2; b++) { d_y[b] = y->size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, d_y, &gc_emlrtECI, emlrtRootTLSGlobal); b = 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, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { b_y->data[b] = dv22[(int32_T)ip_data[b] - 1] * (M - 5.5); } for (b = 0; b < 2; b++) { fmag[b] = fmag_size[b]; } for (b = 0; b < 2; b++) { d_y[b] = b_y->size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, d_y, &gc_emlrtECI, emlrtRootTLSGlobal); fmag_size[0] = 1; i = ip_size[1]; for (b = 0; b < i; b++) { fhngz = (fmag_data[b] + y->data[b]) + b_y->data[b]; fmag_data[b] = fhngz; } } else { fmag_size[0] = 1; fmag_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { fmag_data[b] = dv20[(int32_T)ip_data[b] - 1]; } b = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { y->data[b] = dv21[(int32_T)ip_data[b] - 1] * M; } for (b = 0; b < 2; b++) { fmag[b] = fmag_size[b]; } for (b = 0; b < 2; b++) { d_y[b] = y->size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, d_y, &fc_emlrtECI, emlrtRootTLSGlobal); b = 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, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { b_y->data[b] = dv22[(int32_T)ip_data[b] - 1] * (M - 5.5); } for (b = 0; b < 2; b++) { fmag[b] = fmag_size[b]; } for (b = 0; b < 2; b++) { d_y[b] = b_y->size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, d_y, &fc_emlrtECI, emlrtRootTLSGlobal); b = 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, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { c_y->data[b] = dv23[(int32_T)ip_data[b] - 1] * (M - 6.5); } for (b = 0; b < 2; b++) { fmag[b] = fmag_size[b]; } for (b = 0; b < 2; b++) { d_y[b] = c_y->size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, d_y, &fc_emlrtECI, emlrtRootTLSGlobal); fmag_size[0] = 1; i = ip_size[1]; for (b = 0; b < i; b++) { fhngz = ((fmag_data[b] + y->data[b]) + b_y->data[b]) + c_y->data[b]; fmag_data[b] = fhngz; } } /* Distance dependence */ tmp_size[0] = 1; tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { tmp_data[b] = dv24[(int32_T)ip_data[b] - 1]; } b = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { y->data[b] = 0.17 * M; } for (b = 0; b < 2; b++) { fmag[b] = tmp_size[b]; } for (b = 0; b < 2; b++) { d_y[b] = y->size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, d_y, &ec_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&nq_emlrtRSI, emlrtRootTLSGlobal); fhngz = Rrup * Rrup; b = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = ip_size[1]; for (b = 0; b < i; b++) { y->data[b] += tmp_data[b]; } b_tmp_size[0] = 1; b_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { b_tmp_data[b] = dv25[(int32_T)ip_data[b] - 1]; } b_emxInit_real_T(&b_b, 2, &od_emlrtRTEI, TRUE); c_tmp_data.data = (real_T *)&b_tmp_data; c_tmp_data.size = (int32_T *)&b_tmp_size; c_tmp_data.allocatedSize = 24; c_tmp_data.numDimensions = 2; c_tmp_data.canFreeData = FALSE; mpower(&c_tmp_data, b_b); b = b_b->size[0] * b_b->size[1]; b_b->size[0] = 1; emxEnsureCapacity((emxArray__common *)b_b, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = b_b->size[0]; b = b_b->size[1]; i *= b; for (b = 0; b < i; b++) { b_b->data[b] += fhngz; } c_sqrt(b_b); c_log(b_b); emlrtPushRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); if (!(y->size[1] == 1)) { if ((y->size[1] == 1) || (b_b->size[1] == 1)) { emlrtPushRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); e_y = NULL; m34 = mxCreateCharArray(2, iv90); for (i = 0; i < 45; i++) { cv126[i] = cv127[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m34, cv126); emlrtAssign(&e_y, m34); error(message(e_y, &r_emlrtMCI), &s_emlrtMCI); emlrtPopRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); f_y = NULL; m34 = mxCreateCharArray(2, iv91); for (i = 0; i < 21; i++) { cv128[i] = cv129[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m34, cv128); emlrtAssign(&f_y, m34); error(message(f_y, &t_emlrtMCI), &u_emlrtMCI); emlrtPopRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); } } emlrtPopRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); fhngz = y->data[0]; b = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = b_b->size[1]; emxEnsureCapacity((emxArray__common *)y, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = b_b->size[1]; for (b = 0; b < i; b++) { y->data[y->size[0] * b] = fhngz * b_b->data[b_b->size[0] * b]; } emlrtPopRtStackR2012b(&nq_emlrtRSI, emlrtRootTLSGlobal); /* Style of faulting */ b = 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, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { b_y->data[b] = dv26[(int32_T)ip_data[b] - 1] * (real_T)Frv * ffltz; } fflt_size[0] = 1; fflt_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { fflt_data[b] = dv27[(int32_T)ip_data[b] - 1] * (real_T)Fnm; } for (b = 0; b < 2; b++) { d_y[b] = b_y->size[b]; } for (b = 0; b < 2; b++) { fflt[b] = fflt_size[b]; } emlrtSizeEqCheck2DFastR2012b(d_y, fflt, &dc_emlrtECI, emlrtRootTLSGlobal); fflt_size[0] = 1; fflt_size[1] = b_y->size[1]; i = b_y->size[0] * b_y->size[1]; for (b = 0; b < i; b++) { fhngz = b_y->data[b] + fflt_data[b]; fflt_data[b] = fhngz; } /* Hanging-wall effects */ if ((Ztor >= 0.0) && (Ztor < 20.0)) { c_b = TRUE; } else { c_b = FALSE; } fhngz = (20.0 - Ztor) / 20.0 * (real_T)c_b; fhngdelta = (real_T)(delta <= 70.0) + (90.0 - delta) / 20.0 * (real_T)(delta > 70.0); b = 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, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { b_y->data[b] = dv28[(int32_T)ip_data[b] - 1] * fhngr * fhngm * fhngz * fhngdelta; } /* Site conditions */ /* Vs30=1100 */ /* if Vs30 < k1(ip); */ /* A1100 = CB_2008_nga (M, 0, Rrup, Rjb,Ztor, delta, lambda, 1100, Zvs, arb); */ /* fsite = c10(ip) * log(Vs30/k1(ip)) + k2(ip) * (log(A1100 + c * (Vs30/k1(ip))^n) - log(A1100 + c)); */ /* elseif Vs30 < 1100; */ /* fsite = (c10(ip) + k2(ip) * n) * log(Vs30/k1(ip)); */ /* else */ tmp_size[0] = 1; tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { tmp_data[b] = dv29[(int32_T)ip_data[b] - 1]; } for (b = 0; b < 2; b++) { fmag[b] = tmp_size[b]; fflt[b] = ip_size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, fflt, &cc_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&oq_emlrtRSI, emlrtRootTLSGlobal); c_tmp_size[0] = 1; c_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { d_tmp_data[b] = iv92[(int32_T)ip_data[b] - 1]; } fhngz = b_mrdivide(d_tmp_data, c_tmp_size); b_log(&fhngz); b = 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, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = ip_size[1]; for (b = 0; b < i; b++) { c_y->data[b] = (tmp_data[b] + dv30[(int32_T)ip_data[b] - 1] * 1.18) * fhngz; } emlrtPopRtStackR2012b(&oq_emlrtRSI, emlrtRootTLSGlobal); /* end; */ /* Sediment effects */ if (Zvs < 1.0) { fsed_size[0] = 1; fsed_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { fsed_data[b] = dv31[(int32_T)ip_data[b] - 1] * (Zvs - 1.0); } } else if (Zvs <= 3.0) { fsed_size[0] = 1; fsed_size[1] = 1; fsed_data[0] = 0.0; } else { b_emxInit_real_T(&a, 2, &od_emlrtRTEI, TRUE); emlrtPushRtStackR2012b(&vq_emlrtRSI, emlrtRootTLSGlobal); b = a->size[0] * a->size[1]; a->size[0] = 1; a->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)a, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { a->data[b] = dv32[(int32_T)ip_data[b] - 1]; } b = b_b->size[0] * b_b->size[1]; b_b->size[0] = 1; b_b->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)b_b, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { b_b->data[b] = dv33[(int32_T)ip_data[b] - 1]; } emlrtPushRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); if (!(a->size[1] == 1)) { if ((a->size[1] == 1) || (b_b->size[1] == 1)) { emlrtPushRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); g_y = NULL; m34 = mxCreateCharArray(2, iv93); for (i = 0; i < 45; i++) { cv126[i] = cv127[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m34, cv126); emlrtAssign(&g_y, m34); error(message(g_y, &r_emlrtMCI), &s_emlrtMCI); emlrtPopRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); h_y = NULL; m34 = mxCreateCharArray(2, iv94); for (i = 0; i < 21; i++) { cv128[i] = cv129[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m34, cv128); emlrtAssign(&h_y, m34); error(message(h_y, &t_emlrtMCI), &u_emlrtMCI); emlrtPopRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); } } emlrtPopRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); fhngz = 1.0 - muDoubleScalarExp(-0.25 * (Zvs - 3.0)); fsed_size[0] = 1; fsed_size[1] = b_b->size[1]; fhngdelta = a->data[0]; i = b_b->size[0] * b_b->size[1]; emxFree_real_T(&a); for (b = 0; b < i; b++) { fsed_data[b] = fhngdelta * b_b->data[b] * 0.47236655274101469 * fhngz; } emlrtPopRtStackR2012b(&vq_emlrtRSI, emlrtRootTLSGlobal); } emxFree_real_T(&b_b); /* Median value */ for (b = 0; b < 2; b++) { fmag[b] = fmag_size[b]; } for (b = 0; b < 2; b++) { d_y[b] = y->size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, d_y, &bc_emlrtECI, emlrtRootTLSGlobal); for (b = 0; b < 2; b++) { fmag[b] = fmag_size[b]; fflt[b] = fflt_size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, fflt, &bc_emlrtECI, emlrtRootTLSGlobal); for (b = 0; b < 2; b++) { fmag[b] = fmag_size[b]; } for (b = 0; b < 2; b++) { d_y[b] = b_y->size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, d_y, &bc_emlrtECI, emlrtRootTLSGlobal); for (b = 0; b < 2; b++) { fmag[b] = fmag_size[b]; } for (b = 0; b < 2; b++) { d_y[b] = c_y->size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, d_y, &bc_emlrtECI, emlrtRootTLSGlobal); for (b = 0; b < 2; b++) { fmag[b] = fmag_size[b]; } for (b = 0; b < 2; b++) { fflt[b] = fsed_size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, fflt, &bc_emlrtECI, emlrtRootTLSGlobal); b = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = fmag_size[1]; emxEnsureCapacity((emxArray__common *)y, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = fmag_size[1]; for (b = 0; b < i; b++) { y->data[b] = ((((fmag_data[b] + y->data[b]) + fflt_data[b]) + b_y->data[b]) + c_y->data[b]) + fsed_data[b]; } emxFree_real_T(&c_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 (b = 0; b < i; b++) { Sa_data[b] = y->data[b]; } /* Standard deviation computations */ /* if all(Vs30 < k1(ip)); */ /* alpha = k2(ip) * A1100 * ((A1100 + c*(Vs30/k1(ip))^n)^(-1) - (A1100+c)^(-1)); */ /* else */ /* end; */ emlrtPushRtStackR2012b(&pq_emlrtRSI, emlrtRootTLSGlobal); d_tmp_size[0] = 1; d_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { e_tmp_data[b] = dv34[(int32_T)ip_data[b] - 1]; } f_tmp_data.data = (real_T *)&e_tmp_data; f_tmp_data.size = (int32_T *)&d_tmp_size; f_tmp_data.allocatedSize = 24; f_tmp_data.numDimensions = 2; f_tmp_data.canFreeData = FALSE; mpower(&f_tmp_data, y); b = y->size[0] * y->size[1]; y->size[0] = 1; emxEnsureCapacity((emxArray__common *)y, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = y->size[0]; b = y->size[1]; i *= b; for (b = 0; b < i; b++) { y->data[b] -= 0.09; } c_sqrt(y); fsed_size[0] = 1; fsed_size[1] = y->size[1]; i = y->size[0] * y->size[1]; for (b = 0; b < i; b++) { fsed_data[b] = y->data[b]; } emlrtPopRtStackR2012b(&pq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&qq_emlrtRSI, emlrtRootTLSGlobal); e_tmp_size[0] = 1; e_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { g_tmp_data[b] = dv34[(int32_T)ip_data[b] - 1]; } h_tmp_data.data = (real_T *)&g_tmp_data; h_tmp_data.size = (int32_T *)&e_tmp_size; h_tmp_data.allocatedSize = 24; h_tmp_data.numDimensions = 2; h_tmp_data.canFreeData = FALSE; mpower(&h_tmp_data, y); tmp_size[0] = 1; tmp_size[1] = y->size[1]; i = y->size[0] * y->size[1]; for (b = 0; b < i; b++) { tmp_data[b] = y->data[b]; } emlrtPopRtStackR2012b(&qq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&qq_emlrtRSI, emlrtRootTLSGlobal); b = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = ip_size[1]; emxEnsureCapacity((emxArray__common *)y, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { y->data[b] = 0.0; } emlrtPushRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); if (!(y->size[1] == 1)) { if ((y->size[1] == 1) || (fsed_size[1] == 1)) { emlrtPushRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); i_y = NULL; m34 = mxCreateCharArray(2, iv95); for (i = 0; i < 45; i++) { cv126[i] = cv127[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m34, cv126); emlrtAssign(&i_y, m34); error(message(i_y, &r_emlrtMCI), &s_emlrtMCI); emlrtPopRtStackR2012b(&wd_emlrtRSI, emlrtRootTLSGlobal); } else { emlrtPushRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); j_y = NULL; m34 = mxCreateCharArray(2, iv96); for (i = 0; i < 21; i++) { cv128[i] = cv129[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m34, cv128); emlrtAssign(&j_y, m34); error(message(j_y, &t_emlrtMCI), &u_emlrtMCI); emlrtPopRtStackR2012b(&vd_emlrtRSI, emlrtRootTLSGlobal); } } emlrtPopRtStackR2012b(&ud_emlrtRSI, emlrtRootTLSGlobal); b = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = fsed_size[1]; emxEnsureCapacity((emxArray__common *)y, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = fsed_size[0] * fsed_size[1]; for (b = 0; b < i; b++) { y->data[b] = 0.0 * fsed_data[b] * 0.37213438432910229; } emlrtPopRtStackR2012b(&qq_emlrtRSI, emlrtRootTLSGlobal); for (b = 0; b < 2; b++) { fmag[b] = tmp_size[b]; } for (b = 0; b < 2; b++) { d_y[b] = y->size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, d_y, &ac_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&qq_emlrtRSI, emlrtRootTLSGlobal); b = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = tmp_size[1]; emxEnsureCapacity((emxArray__common *)y, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = tmp_size[1]; for (b = 0; b < i; b++) { y->data[b] += tmp_data[b]; } c_sqrt(y); fsed_size[0] = 1; fsed_size[1] = y->size[1]; i = y->size[0] * y->size[1]; for (b = 0; b < i; b++) { fsed_data[b] = y->data[b]; } emlrtPopRtStackR2012b(&qq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&rq_emlrtRSI, emlrtRootTLSGlobal); b_fsed_data.data = (real_T *)&fsed_data; b_fsed_data.size = (int32_T *)&fsed_size; b_fsed_data.allocatedSize = 24; b_fsed_data.numDimensions = 2; b_fsed_data.canFreeData = FALSE; mpower(&b_fsed_data, y); tmp_size[0] = 1; tmp_size[1] = y->size[1]; i = y->size[0] * y->size[1]; for (b = 0; b < i; b++) { tmp_data[b] = y->data[b]; } emlrtPopRtStackR2012b(&rq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&rq_emlrtRSI, emlrtRootTLSGlobal); f_tmp_size[0] = 1; f_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { i_tmp_data[b] = dv35[(int32_T)ip_data[b] - 1]; } j_tmp_data.data = (real_T *)&i_tmp_data; j_tmp_data.size = (int32_T *)&f_tmp_size; j_tmp_data.allocatedSize = 24; j_tmp_data.numDimensions = 2; j_tmp_data.canFreeData = FALSE; mpower(&j_tmp_data, y); fsed_size[0] = 1; fsed_size[1] = y->size[1]; i = y->size[0] * y->size[1]; for (b = 0; b < i; b++) { fsed_data[b] = y->data[b]; } emlrtPopRtStackR2012b(&rq_emlrtRSI, emlrtRootTLSGlobal); for (b = 0; b < 2; b++) { fmag[b] = tmp_size[b]; } for (b = 0; b < 2; b++) { fflt[b] = fsed_size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, fflt, &yb_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&rq_emlrtRSI, emlrtRootTLSGlobal); b = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = tmp_size[1]; emxEnsureCapacity((emxArray__common *)y, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = tmp_size[1]; for (b = 0; b < i; b++) { y->data[b] = tmp_data[b] + fsed_data[b]; } c_sqrt(y); sigma_size[0] = 1; sigma_size[1] = y->size[1]; i = y->size[0] * y->size[1]; for (b = 0; b < i; b++) { sigma_data[b] = y->data[b]; } emlrtPopRtStackR2012b(&rq_emlrtRSI, emlrtRootTLSGlobal); if (arb == 1.0) { emlrtPushRtStackR2012b(&sq_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, y); tmp_size[0] = 1; tmp_size[1] = y->size[1]; i = y->size[0] * y->size[1]; for (b = 0; b < i; b++) { tmp_data[b] = y->data[b]; } emlrtPopRtStackR2012b(&sq_emlrtRSI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&sq_emlrtRSI, emlrtRootTLSGlobal); g_tmp_size[0] = 1; g_tmp_size[1] = ip_size[1]; i = ip_size[0] * ip_size[1]; for (b = 0; b < i; b++) { k_tmp_data[b] = dv36[(int32_T)ip_data[b] - 1]; } l_tmp_data.data = (real_T *)&k_tmp_data; l_tmp_data.size = (int32_T *)&g_tmp_size; l_tmp_data.allocatedSize = 24; l_tmp_data.numDimensions = 2; l_tmp_data.canFreeData = FALSE; mpower(&l_tmp_data, y); fsed_size[0] = 1; fsed_size[1] = y->size[1]; i = y->size[0] * y->size[1]; for (b = 0; b < i; b++) { fsed_data[b] = y->data[b]; } emlrtPopRtStackR2012b(&sq_emlrtRSI, emlrtRootTLSGlobal); for (b = 0; b < 2; b++) { fmag[b] = tmp_size[b]; } for (b = 0; b < 2; b++) { fflt[b] = fsed_size[b]; } emlrtSizeEqCheck2DFastR2012b(fmag, fflt, &xb_emlrtECI, emlrtRootTLSGlobal); emlrtPushRtStackR2012b(&sq_emlrtRSI, emlrtRootTLSGlobal); b = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = tmp_size[1]; emxEnsureCapacity((emxArray__common *)y, b, (int32_T)sizeof(real_T), &od_emlrtRTEI); i = tmp_size[1]; for (b = 0; b < i; b++) { y->data[b] = tmp_data[b] + fsed_data[b]; } c_sqrt(y); sigma_size[0] = 1; sigma_size[1] = y->size[1]; i = y->size[0] * y->size[1]; for (b = 0; b < i; b++) { sigma_data[b] = y->data[b]; } emlrtPopRtStackR2012b(&sq_emlrtRSI, emlrtRootTLSGlobal); } emxFree_real_T(&y); emlrtHeapReferenceStackLeaveFcnR2012b(emlrtRootTLSGlobal); } real_T CB_2008_nga_T0(real_T M, real_T Rrup, real_T Rjb, real_T Ztor, real_T delta, real_T lambda, real_T Zvs, real_T arb) { real_T Sa; real_T fhngr; real_T c; int32_T idx; int32_T ii; boolean_T exitg2; boolean_T guard2 = FALSE; static const boolean_T bv0[24] = { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE }; int32_T i19; 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 i20; 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 */ /* */ /* 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(&tq_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(&tq_emlrtRSI, emlrtRootTLSGlobal); } else { fhngr = (Rrup - Rjb) / Rrup; } Sa = 0.0; /* interpolate between periods if neccesary */ idx = 0; ii = 1; exitg2 = FALSE; while ((exitg2 == FALSE) && (ii < 25)) { guard2 = FALSE; if (bv0[ii - 1]) { idx++; if (idx >= 24) { exitg2 = TRUE; } else { guard2 = TRUE; } } else { guard2 = TRUE; } if (guard2 == TRUE) { ii++; } } if (1 > idx) { i19 = 0; } else { i19 = idx; } if (i19 == 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 (bv0[ii - 1]) { 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++) { i20 = 0; while (i20 <= 0) { b_ii_data[ii] = ii_data[tmp_data[ii] - 1]; i20 = 1; } } for (ii = 0; ii < idx; ii++) { ii_data[ii] = b_ii_data[ii]; } emlrtPushRtStackR2012b(&uq_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; } b_CB_2008_nga_sub(M, c_ii_data, ii_size, Rrup, Ztor, delta, 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(&uq_emlrtRSI, emlrtRootTLSGlobal); emlrtSizeEqCheck1DFastR2012b(1, b_tmp_size[1], &vb_emlrtECI, emlrtRootTLSGlobal); emlrtDynamicBoundsCheckFastR2012b(1, 1, b_tmp_size[1], &le_emlrtBCI, emlrtRootTLSGlobal); Sa = c_tmp_data[0]; emlrtSizeEqCheck1DFastR2012b(1, tmp_size[1], &wb_emlrtECI, emlrtRootTLSGlobal); emlrtDynamicBoundsCheckFastR2012b(1, 1, tmp_size[1], &me_emlrtBCI, emlrtRootTLSGlobal); } return Sa; } /* End of code generation (CB_2008_nga_T0.c) */