/* * sum.c * * Code generation for function 'sum' * * C source code generated on: Wed Aug 26 14:59:33 2015 * */ /* Include files */ #include "rt_nonfinite.h" #include "Select_Ground_Motions.h" #include "sum.h" #include "Select_Ground_Motions_emxutil.h" #include "Select_Ground_Motions_mexutil.h" #include "Select_Ground_Motions_data.h" /* Variable Definitions */ static emlrtRSInfo wm_emlrtRSI = { 72, "sum", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/datafun/sum.m" }; static emlrtRTEInfo oc_emlrtRTEI = { 1, 14, "sum", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/datafun/sum.m" }; /* Function Definitions */ real_T b_sum(const emxArray_real_T *x) { real_T y; boolean_T overflow; int32_T k; if (x->size[1] == 0) { y = 0.0; } else { y = x->data[0]; emlrtPushRtStackR2012b(&am_emlrtRSI, emlrtRootTLSGlobal); if (2 > x->size[1]) { overflow = FALSE; } else { overflow = (x->size[1] > 2147483646); } if (overflow) { emlrtPushRtStackR2012b(&lc_emlrtRSI, emlrtRootTLSGlobal); check_forloop_overflow_error(); emlrtPopRtStackR2012b(&lc_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&am_emlrtRSI, emlrtRootTLSGlobal); for (k = 2; k <= x->size[1]; k++) { y += x->data[k - 1]; } } return y; } void c_sum(const emxArray_real_T *x, real_T y_data[1], int32_T y_size[1]) { int32_T ix; real_T s; boolean_T overflow; int32_T k; y_size[0] = 1; if (x->size[1] == 0) { y_size[0] = 1; y_data[0] = 0.0; } else { emlrtPushRtStackR2012b(&wm_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&wm_emlrtRSI, emlrtRootTLSGlobal); ix = 0; s = x->data[0]; emlrtPushRtStackR2012b(&hm_emlrtRSI, emlrtRootTLSGlobal); if (2 > x->size[1]) { overflow = FALSE; } else { overflow = (x->size[1] > 2147483646); } if (overflow) { emlrtPushRtStackR2012b(&lc_emlrtRSI, emlrtRootTLSGlobal); check_forloop_overflow_error(); emlrtPopRtStackR2012b(&lc_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&hm_emlrtRSI, emlrtRootTLSGlobal); for (k = 2; k <= x->size[1]; k++) { ix++; s += x->data[ix]; } y_data[0] = s; } } real_T d_sum(const emxArray_real_T *x) { real_T y; boolean_T overflow; boolean_T p; int32_T i; int32_T exitg1; const mxArray *b_y; static const int32_T iv72[2] = { 1, 30 }; const mxArray *m27; char_T cv99[30]; static const char_T cv100[30] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 's', 'u', 'm', '_', 's', 'p', 'e', 'c', 'i', 'a', 'l', 'E', 'm', 'p', 't', 'y' }; const mxArray *c_y; static const int32_T iv73[2] = { 1, 36 }; char_T cv101[36]; static const char_T cv102[36] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 'a', 'u', 't', 'o', 'D', 'i', 'm', 'I', 'n', 'c', 'o', 'm', 'p', 'a', 't', 'i', 'b', 'i', 'l', 'i', 't', 'y' }; overflow = FALSE; p = FALSE; i = 0; do { exitg1 = 0; if (i < 2) { if (x->size[i] != 0) { exitg1 = 1; } else { i++; } } else { p = TRUE; exitg1 = 1; } } while (exitg1 == 0); if (!p) { } else { overflow = TRUE; } if (!overflow) { } else { emlrtPushRtStackR2012b(&xl_emlrtRSI, emlrtRootTLSGlobal); b_y = NULL; m27 = mxCreateCharArray(2, iv72); for (i = 0; i < 30; i++) { cv99[i] = cv100[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 30, m27, cv99); emlrtAssign(&b_y, m27); error(message(b_y, &ac_emlrtMCI), &bc_emlrtMCI); emlrtPopRtStackR2012b(&xl_emlrtRSI, emlrtRootTLSGlobal); } if ((x->size[1] == 1) || (x->size[1] != 1)) { overflow = TRUE; } else { overflow = FALSE; } if (overflow) { } else { emlrtPushRtStackR2012b(&yl_emlrtRSI, emlrtRootTLSGlobal); c_y = NULL; m27 = mxCreateCharArray(2, iv73); for (i = 0; i < 36; i++) { cv101[i] = cv102[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 36, m27, cv101); emlrtAssign(&c_y, m27); error(message(c_y, &cc_emlrtMCI), &dc_emlrtMCI); emlrtPopRtStackR2012b(&yl_emlrtRSI, emlrtRootTLSGlobal); } if (x->size[1] == 0) { y = 0.0; } else { y = x->data[0]; emlrtPushRtStackR2012b(&am_emlrtRSI, emlrtRootTLSGlobal); if (2 > x->size[1]) { overflow = FALSE; } else { overflow = (x->size[1] > 2147483646); } if (overflow) { emlrtPushRtStackR2012b(&lc_emlrtRSI, emlrtRootTLSGlobal); check_forloop_overflow_error(); emlrtPopRtStackR2012b(&lc_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&am_emlrtRSI, emlrtRootTLSGlobal); for (i = 2; i <= x->size[1]; i++) { y += x->data[i - 1]; } } return y; } void sum(const emxArray_real_T *x, emxArray_real_T *y) { uint32_T sz[2]; int32_T ixstart; int32_T k; int32_T ix; int32_T iy; boolean_T overflow; int32_T i; real_T s; for (ixstart = 0; ixstart < 2; ixstart++) { sz[ixstart] = (uint32_T)x->size[ixstart]; } ixstart = y->size[0] * y->size[1]; y->size[0] = 1; y->size[1] = (int32_T)sz[1]; emxEnsureCapacity((emxArray__common *)y, ixstart, (int32_T)sizeof(real_T), &nc_emlrtRTEI); if ((x->size[0] == 0) || (x->size[1] == 0)) { ixstart = y->size[0] * y->size[1]; y->size[0] = 1; emxEnsureCapacity((emxArray__common *)y, ixstart, (int32_T)sizeof(real_T), &oc_emlrtRTEI); ixstart = y->size[0] * y->size[1]; y->size[1] = (int32_T)sz[1]; emxEnsureCapacity((emxArray__common *)y, ixstart, (int32_T)sizeof(real_T), &oc_emlrtRTEI); k = (int32_T)sz[1]; for (ixstart = 0; ixstart < k; ixstart++) { y->data[ixstart] = 0.0; } } else { ix = -1; iy = -1; emlrtPushRtStackR2012b(&gm_emlrtRSI, emlrtRootTLSGlobal); overflow = (x->size[1] > 2147483646); if (overflow) { emlrtPushRtStackR2012b(&lc_emlrtRSI, emlrtRootTLSGlobal); check_forloop_overflow_error(); emlrtPopRtStackR2012b(&lc_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&gm_emlrtRSI, emlrtRootTLSGlobal); for (i = 1; i <= x->size[1]; i++) { ixstart = ix + 1; ix++; s = x->data[ixstart]; emlrtPushRtStackR2012b(&hm_emlrtRSI, emlrtRootTLSGlobal); if (2 > x->size[0]) { overflow = FALSE; } else { overflow = (x->size[0] > 2147483646); } if (overflow) { emlrtPushRtStackR2012b(&lc_emlrtRSI, emlrtRootTLSGlobal); check_forloop_overflow_error(); emlrtPopRtStackR2012b(&lc_emlrtRSI, emlrtRootTLSGlobal); } emlrtPopRtStackR2012b(&hm_emlrtRSI, emlrtRootTLSGlobal); for (k = 2; k <= x->size[0]; k++) { ix++; s += x->data[ix]; } iy++; y->data[iy] = s; } } } /* End of code generation (sum.c) */