/* * corrcoef.c * * Code generation for function 'corrcoef' * * C source code generated on: Wed Aug 26 14:59:34 2015 * */ /* Include files */ #include "rt_nonfinite.h" #include "Select_Ground_Motions.h" #include "corrcoef.h" #include "SP_1996.h" #include "Select_Ground_Motions_emxutil.h" #include "Select_Ground_Motions_mexutil.h" #include "Select_Ground_Motions_data.h" /* Variable Definitions */ static emlrtRSInfo rs_emlrtRSI = { 50, "corrcoef", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/datafun/corrcoef.m" }; static emlrtRSInfo ss_emlrtRSI = { 124, "corrcoef", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/datafun/corrcoef.m" }; static emlrtRSInfo ts_emlrtRSI = { 244, "corrcoef", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/datafun/corrcoef.m" }; static emlrtRSInfo us_emlrtRSI = { 248, "corrcoef", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/datafun/corrcoef.m" }; static emlrtRSInfo vs_emlrtRSI = { 255, "corrcoef", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/datafun/corrcoef.m" }; static emlrtRSInfo ws_emlrtRSI = { 261, "corrcoef", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/datafun/corrcoef.m" }; static emlrtRSInfo xs_emlrtRSI = { 268, "corrcoef", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/datafun/corrcoef.m" }; static emlrtRSInfo ys_emlrtRSI = { 208, "corrcoef", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/datafun/corrcoef.m" }; static emlrtMCInfo cd_emlrtMCI = { 51, 5, "corrcoef", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/datafun/corrcoef.m" }; static emlrtMCInfo dd_emlrtMCI = { 50, 15, "corrcoef", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/datafun/corrcoef.m" }; static emlrtRTEInfo ud_emlrtRTEI = { 1, 26, "corrcoef", "/usr/local/MATLAB/R2013a/toolbox/eml/lib/matlab/datafun/corrcoef.m" }; /* Function Definitions */ void corrcoef(const emxArray_real_T *x, real_T r[4]) { boolean_T overflow; const mxArray *y; static const int32_T iv127[2] = { 1, 43 }; const mxArray *m41; char_T cv148[43]; int32_T i; static const char_T cv149[43] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o', 'l', 'b', 'o', 'x', ':', 'c', 'o', 'r', 'r', 'c', 'o', 'e', 'f', '_', 'u', 'n', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd', 'R', 'o', 'w', 'V', 'e', 'c', 't', 'o', 'r' }; emxArray_real_T *b_x; int32_T loop_ub; real_T d; real_T b_d[2]; emlrtHeapReferenceStackEnterFcnR2012b(emlrtRootTLSGlobal); overflow = (x->size[0] != 1); if (overflow) { } else { emlrtPushRtStackR2012b(&rs_emlrtRSI, emlrtRootTLSGlobal); y = NULL; m41 = mxCreateCharArray(2, iv127); for (i = 0; i < 43; i++) { cv148[i] = cv149[i]; } emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 43, m41, cv148); emlrtAssign(&y, m41); error(message(y, &cd_emlrtMCI), &dd_emlrtMCI); emlrtPopRtStackR2012b(&rs_emlrtRSI, emlrtRootTLSGlobal); } b_emxInit_real_T(&b_x, 2, &ud_emlrtRTEI, TRUE); emlrtPushRtStackR2012b(&ss_emlrtRSI, emlrtRootTLSGlobal); i = b_x->size[0] * b_x->size[1]; b_x->size[0] = x->size[0]; b_x->size[1] = 2; emxEnsureCapacity((emxArray__common *)b_x, i, (int32_T)sizeof(real_T), &ud_emlrtRTEI); loop_ub = x->size[0] * x->size[1]; for (i = 0; i < loop_ub; i++) { b_x->data[i] = x->data[i]; } for (i = 0; i < 4; i++) { r[i] = 0.0; } if (x->size[0] < 2) { for (i = 0; i < 4; i++) { r[i] = rtNaN; } } else { for (loop_ub = 0; loop_ub < 2; loop_ub++) { d = 0.0; emlrtPushRtStackR2012b(&ts_emlrtRSI, emlrtRootTLSGlobal); if (1 > 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(&ts_emlrtRSI, emlrtRootTLSGlobal); for (i = 1; i <= x->size[0]; i++) { d += b_x->data[(i + b_x->size[0] * loop_ub) - 1]; } d /= (real_T)x->size[0]; emlrtPushRtStackR2012b(&us_emlrtRSI, emlrtRootTLSGlobal); if (1 > 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(&us_emlrtRSI, emlrtRootTLSGlobal); for (i = 0; i + 1 <= x->size[0]; i++) { b_x->data[i + b_x->size[0] * loop_ub] -= d; } } for (loop_ub = 0; loop_ub < 2; loop_ub++) { d = 0.0; emlrtPushRtStackR2012b(&vs_emlrtRSI, emlrtRootTLSGlobal); if (1 > 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(&vs_emlrtRSI, emlrtRootTLSGlobal); for (i = 0; i + 1 <= x->size[0]; i++) { d += b_x->data[i + b_x->size[0] * loop_ub] * b_x->data[i + b_x->size[0] * loop_ub]; } r[loop_ub + (loop_ub << 1)] = d / ((real_T)x->size[0] - 1.0); i = loop_ub + 2; while (i < 3) { d = 0.0; emlrtPushRtStackR2012b(&ws_emlrtRSI, emlrtRootTLSGlobal); if (1 > 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(&ws_emlrtRSI, emlrtRootTLSGlobal); for (i = 0; i + 1 <= x->size[0]; i++) { d += b_x->data[i + b_x->size[0]] * b_x->data[i + b_x->size[0] * loop_ub]; } r[1 + (loop_ub << 1)] = d / ((real_T)x->size[0] - 1.0); i = 3; } } } emxFree_real_T(&b_x); emlrtPushRtStackR2012b(&xs_emlrtRSI, emlrtRootTLSGlobal); for (i = 0; i < 2; i++) { emlrtPushRtStackR2012b(&ys_emlrtRSI, emlrtRootTLSGlobal); if (r[i + (i << 1)] < 0.0) { emlrtPushRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); e_eml_error(); emlrtPopRtStackR2012b(&md_emlrtRSI, emlrtRootTLSGlobal); } b_d[i] = muDoubleScalarSqrt(r[i + (i << 1)]); emlrtPopRtStackR2012b(&ys_emlrtRSI, emlrtRootTLSGlobal); } for (loop_ub = 0; loop_ub < 2; loop_ub++) { i = loop_ub + 2; while (i < 3) { r[1 + (loop_ub << 1)] = r[1 + (loop_ub << 1)] / b_d[1] / b_d[loop_ub]; i = 3; } i = loop_ub + 2; while (i < 3) { d = muDoubleScalarAbs(r[1 + (loop_ub << 1)]); if (d > 1.0) { r[1 + (loop_ub << 1)] /= d; } r[2 + loop_ub] = r[1 + (loop_ub << 1)]; i = 3; } if (r[loop_ub + (loop_ub << 1)] > 0.0) { r[loop_ub + (loop_ub << 1)] = muDoubleScalarSign(r[loop_ub + (loop_ub << 1)]); } else { r[loop_ub + (loop_ub << 1)] = rtNaN; } } emlrtPopRtStackR2012b(&xs_emlrtRSI, emlrtRootTLSGlobal); emlrtPopRtStackR2012b(&ss_emlrtRSI, emlrtRootTLSGlobal); emlrtHeapReferenceStackLeaveFcnR2012b(emlrtRootTLSGlobal); } /* End of code generation (corrcoef.c) */