// // File: std.cpp // // MATLAB Coder version : 5.2 // C/C++ source code generated on : 09-Mar-2023 16:57:20 // // Include Files #include "fun8_std.h" #include "fun8_AMJamming_H_data.h" #include "rt_nonfinite.h" #include "coder_array.h" #include // Function Declarations static double rt_hypotd_snf(double u0, double u1); // Function Definitions // // Arguments : double u0 // double u1 // Return Type : double // static double rt_hypotd_snf(double u0, double u1) { double a; double y; a = std::abs(u0); y = std::abs(u1); if (a < y) { a /= y; y *= std::sqrt(a * a + 1.0); } else if (a > y) { y /= a; y = a * std::sqrt(y * y + 1.0); } else if (!std::isnan(y)) { y = a * 1.4142135623730951; } return y; } // // Arguments : const ::coder::array &x // Return Type : double // namespace coder { double b_std_8(const ::coder::array &x) { array absdiff; double y; int n; n = x.size(1); if (x.size(1) == 0) { y = rtNaN; } else if (x.size(1) == 1) { if ((!std::isinf(x[0].re)) && (!std::isinf(x[0].im)) && ((!std::isnan(x[0].re)) && (!std::isnan(x[0].im)))) { y = 0.0; } else { y = rtNaN; } } else { double bsum_re; double xbar_im; double xbar_re; int firstBlockLength; int k; int lastBlockLength; int nblocks; if (x.size(1) <= 1024) { firstBlockLength = x.size(1); lastBlockLength = 0; nblocks = 1; } else { firstBlockLength = 1024; nblocks = x.size(1) / 1024; lastBlockLength = x.size(1) - (nblocks << 10); if (lastBlockLength > 0) { nblocks++; } else { lastBlockLength = 1024; } } xbar_re = x[0].re; xbar_im = x[0].im; for (k = 2; k <= firstBlockLength; k++) { xbar_re += x[k - 1].re; xbar_im += x[k - 1].im; } for (int ib{2}; ib <= nblocks; ib++) { double bsum_im; int hi; firstBlockLength = (ib - 1) << 10; bsum_re = x[firstBlockLength].re; bsum_im = x[firstBlockLength].im; if (ib == nblocks) { hi = lastBlockLength; } else { hi = 1024; } for (k = 2; k <= hi; k++) { int bsum_re_tmp; bsum_re_tmp = (firstBlockLength + k) - 1; bsum_re += x[bsum_re_tmp].re; bsum_im += x[bsum_re_tmp].im; } xbar_re += bsum_re; xbar_im += bsum_im; } if (xbar_im == 0.0) { bsum_re = xbar_re / static_cast(x.size(1)); xbar_re = 0.0; } else if (xbar_re == 0.0) { bsum_re = 0.0; xbar_re = xbar_im / static_cast(x.size(1)); } else { bsum_re = xbar_re / static_cast(x.size(1)); xbar_re = xbar_im / static_cast(x.size(1)); } absdiff.set_size(x.size(1)); for (k = 0; k < n; k++) { absdiff[k] = rt_hypotd_snf(x[k].re - bsum_re, x[k].im - xbar_re); } y = 0.0; xbar_re = 3.3121686421112381E-170; firstBlockLength = x.size(1); for (k = 0; k < firstBlockLength; k++) { if (absdiff[k] > xbar_re) { bsum_re = xbar_re / absdiff[k]; y = y * bsum_re * bsum_re + 1.0; xbar_re = absdiff[k]; } else { bsum_re = absdiff[k] / xbar_re; y += bsum_re * bsum_re; } } y = xbar_re * std::sqrt(y); y /= std::sqrt(static_cast(x.size(1)) - 1.0); } return y; } } // namespace coder // // File trailer for std.cpp // // [EOF] //