diff --git a/six/modules/c++/six.sicd/source/Functor.cpp b/six/modules/c++/six.sicd/source/Functor.cpp index cee769c51..ddcb67c0e 100644 --- a/six/modules/c++/six.sicd/source/Functor.cpp +++ b/six/modules/c++/six.sicd/source/Functor.cpp @@ -38,19 +38,12 @@ RaisedCos::RaisedCos(double coef) : std::vector RaisedCos::operator()(size_t n) const { - std::vector ret; - ret.resize(static_cast(std::ceil(n / 2.0))); - for (size_t ii = 0; ii < ret.size(); ++ii) + std::vector ret(n); + const size_t halfSize = static_cast(std::ceil(n / 2.0)); + for (size_t ii = 0; ii < halfSize; ++ii) { ret[ii] = mCoef - (1 - mCoef) * std::cos(2 * M_PI * ii / (n - 1)); - } - if (n % 2 == 0) - { - std::reverse_copy(ret.begin(), ret.end(), std::back_inserter(ret)); - } - else - { - std::copy(ret.begin(), ret.end() - 1, std::back_inserter(ret)); + ret[(ret.size() - 1) - ii] = ret[ii]; } return ret; } diff --git a/six/modules/c++/six.sicd/unittests/test_filling_grid.cpp b/six/modules/c++/six.sicd/unittests/test_filling_grid.cpp index cc897cd0a..cc746fa5e 100644 --- a/six/modules/c++/six.sicd/unittests/test_filling_grid.cpp +++ b/six/modules/c++/six.sicd/unittests/test_filling_grid.cpp @@ -86,11 +86,9 @@ TEST_CASE(HammingWindow) row.fillDerivedFields(imageData); TEST_ASSERT_EQ(row.weights.size(), 512); - //Just grabbing some random values to make sure they line up with MATLAB - //TEST_ASSERT_ALMOST_EQ is too picky for what we have, so doing something - //more manual. TEST_ASSERT_ALMOST_EQ(row.weights[163], .733193239); TEST_ASSERT_ALMOST_EQ(row.weights[300], .9328411378); + TEST_ASSERT_ALMOST_EQ(row.weights[0], row.weights[511]); } TEST_CASE(KaiserWindow)