/* * interp1.c * * Code generation for function 'interp1' * * C source code generated on: Wed Aug 26 14:59:33 2015 * */ /* Include files */ #include "rt_nonfinite.h" #include "Select_Ground_Motions.h" #include "interp1.h" #include "Select_Ground_Motions_mexutil.h" #include "Select_Ground_Motions_data.h" /* Variable Definitions */ static emlrtRSInfo gs_emlrtRSI = { 147, "interp1", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/polyfun/interp1.m" }; static emlrtRSInfo is_emlrtRSI = { 91, "interp1", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/polyfun/interp1.m" }; static emlrtRSInfo js_emlrtRSI = { 15, "fliplr", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/elmat/fliplr.m" }; static emlrtMCInfo vc_emlrtMCI = { 92, 13, "interp1", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/polyfun/interp1.m" }; static emlrtMCInfo wc_emlrtMCI = { 91, 23, "interp1", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/polyfun/interp1.m" }; /* Function Definitions */ real_T b_interp1(const real_T varargin_1[2], const real_T varargin_2_data[48], const int32_T varargin_2_size[2], real_T varargin_3) { real_T yi; int32_T i; int32_T b_j1; real_T y_data[48]; real_T x[2]; const mxArray *y; static const int32_T iv117[2] = { 1, 35 }; const mxArray *m39; char_T cv142[35]; static const char_T cv143[35] = { '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', 'L', 'e', 'n', 'g', 't', 'h' }; int32_T exitg1; int32_T c; real_T r; emlrtPushRtStackR2012b(&kd_emlrtRSI, emlrtRootTLSGlobal); i = varargin_2_size[0] * varargin_2_size[1]; for (b_j1 = 0; b_j1 < i; b_j1++) { y_data[b_j1] = varargin_2_data[b_j1]; } for (b_j1 = 0; b_j1 < 2; b_j1++) { x[b_j1] = varargin_1[b_j1]; } if (2 == varargin_2_size[1]) { } else { emlrtPushRtStackR2012b(&is_emlrtRSI, emlrtRootTLSGlobal); y = NULL; m39 = mxCreateCharArray(2, iv117); for (i = 0; i < 35; i++) { cv142[i] = cv143[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 35, m39, cv142); emlrtAssign(&y, m39); error(message(y, &vc_emlrtMCI), &wc_emlrtMCI); emlrtPopRtStackR2012b(&is_emlrtRSI, emlrtRootTLSGlobal); } yi = rtNaN; i = 1; do { exitg1 = 0; if (i < 3) { if (muDoubleScalarIsNaN(varargin_1[i - 1])) { emlrtPushRtStackR2012b(&hs_emlrtRSI, emlrtRootTLSGlobal); c_eml_error(); emlrtPopRtStackR2012b(&hs_emlrtRSI, emlrtRootTLSGlobal); exitg1 = 1; } else { i++; } } else { if (varargin_1[1] < varargin_1[0]) { x[0] = varargin_1[1]; x[1] = varargin_1[0]; emlrtPushRtStackR2012b(&gs_emlrtRSI, emlrtRootTLSGlobal); b_j1 = varargin_2_size[1]; b_j1 += (b_j1 < 0); if (b_j1 >= 0) { i = (int32_T)((uint32_T)b_j1 >> 1); } else { i = ~(int32_T)((uint32_T)~b_j1 >> 1); } emlrtPushRtStackR2012b(&js_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&js_emlrtRSI, emlrtRootTLSGlobal); for (b_j1 = 1; b_j1 <= i; b_j1++) { c = varargin_2_size[1] - b_j1; r = y_data[b_j1 - 1]; y_data[b_j1 - 1] = y_data[c]; y_data[c] = r; } emlrtPopRtStackR2012b(&gs_emlrtRSI, emlrtRootTLSGlobal); } if (x[1] <= x[0]) { emlrtPushRtStackR2012b(&ld_emlrtRSI, emlrtRootTLSGlobal); d_eml_error(); emlrtPopRtStackR2012b(&ld_emlrtRSI, emlrtRootTLSGlobal); } if ((varargin_3 > x[1]) || (varargin_3 < x[0])) { } else { r = (varargin_3 - x[0]) / (x[1] - x[0]); if (y_data[0] == y_data[1]) { yi = y_data[0]; } else { yi = (1.0 - r) * y_data[0] + r * y_data[1]; } } exitg1 = 1; } } while (exitg1 == 0); emlrtPopRtStackR2012b(&kd_emlrtRSI, emlrtRootTLSGlobal); return yi; } void c_eml_error(void) { emlrtPushRtStackR2012b(&jd_emlrtRSI, emlrtRootTLSGlobal); emlrtErrorWithMessageIdR2012b(emlrtRootTLSGlobal, &ee_emlrtRTEI, "MATLAB:interp1:NaNinX", 0); emlrtPopRtStackR2012b(&jd_emlrtRSI, emlrtRootTLSGlobal); } void d_eml_error(void) { emlrtPushRtStackR2012b(&jd_emlrtRSI, emlrtRootTLSGlobal); emlrtErrorWithMessageIdR2012b(emlrtRootTLSGlobal, &ee_emlrtRTEI, "Coder:toolbox:interp1_nonMonotonicX", 0); emlrtPopRtStackR2012b(&jd_emlrtRSI, emlrtRootTLSGlobal); } real_T interp1(const real_T varargin_1[14], const real_T varargin_2[14], real_T varargin_3) { real_T yi; real_T y[14]; real_T x[14]; int32_T mid_i; real_T r; int32_T low_i; int32_T low_ip1; int32_T high_i; emlrtPushRtStackR2012b(&kd_emlrtRSI, emlrtRootTLSGlobal); for (mid_i = 0; mid_i < 14; mid_i++) { y[mid_i] = varargin_2[mid_i]; x[mid_i] = varargin_1[mid_i]; } yi = rtNaN; if (varargin_1[1] < varargin_1[0]) { for (mid_i = 0; mid_i < 7; mid_i++) { r = x[mid_i]; x[mid_i] = x[13 - mid_i]; x[13 - mid_i] = r; } for (mid_i = 0; mid_i < 7; mid_i++) { r = y[mid_i]; y[mid_i] = y[13 - mid_i]; y[13 - mid_i] = r; } } for (mid_i = 0; mid_i < 13; mid_i++) { if (x[mid_i + 1] <= x[mid_i]) { emlrtPushRtStackR2012b(&ld_emlrtRSI, emlrtRootTLSGlobal); d_eml_error(); emlrtPopRtStackR2012b(&ld_emlrtRSI, emlrtRootTLSGlobal); } } if ((varargin_3 > x[13]) || (varargin_3 < x[0])) { } else { low_i = 1; low_ip1 = 2; high_i = 14; while (high_i > low_ip1) { mid_i = low_i + high_i; if (mid_i >= 0) { mid_i = (int32_T)((uint32_T)mid_i >> 1); } else { mid_i = ~(int32_T)((uint32_T)~mid_i >> 1); } if (varargin_3 >= x[mid_i - 1]) { low_i = mid_i; low_ip1 = mid_i + 1; } else { high_i = mid_i; } } r = (varargin_3 - x[low_i - 1]) / (x[low_i] - x[low_i - 1]); if (y[low_i - 1] == y[low_i]) { yi = y[low_i - 1]; } else { yi = (1.0 - r) * y[low_i - 1] + r * y[low_i]; } } emlrtPopRtStackR2012b(&kd_emlrtRSI, emlrtRootTLSGlobal); return yi; } /* End of code generation (interp1.c) */