Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error in reversing weight vector #148

Merged
merged 1 commit into from
Jan 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions six/modules/c++/six.sicd/source/Functor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,12 @@ RaisedCos::RaisedCos(double coef) :

std::vector<double> RaisedCos::operator()(size_t n) const
{
std::vector<double> ret;
ret.resize(static_cast<size_t>(std::ceil(n / 2.0)));
for (size_t ii = 0; ii < ret.size(); ++ii)
std::vector<double> ret(n);
const size_t halfSize = static_cast<size_t>(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;
}
Expand Down
4 changes: 1 addition & 3 deletions six/modules/c++/six.sicd/unittests/test_filling_grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down