Skip to content
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
11 changes: 11 additions & 0 deletions sm/hexfft.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,17 @@ export namespace sm::hexfft
return this->image_asa_to_hexgrid();
}

//! Return the real component of the inverse FFT.
sm::vvec<F> inverse_real()
{
sm::vvec<std::complex<F>> inv_cplx = this->inverse();
sm::vvec<F> inv_real (inv_cplx.size(), F{0});
for (std::uint32_t i = 0; i < inv_cplx.size(); ++i) {
inv_real[i] = std::real (inv_cplx[i]);
}
return inv_real;
}

private:

//! Find parameters for the enclosing hexgrid (used to populate d0/d1 and create hg_asa)
Expand Down
4 changes: 4 additions & 0 deletions tests/hexfft1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ static bool roundtrips (sm::hexgrid<F>& hg, const char* label)
sm::hexfft::fft<F> hfft (&hg, data);
sm::vvec<std::complex<F>> back = hfft.inverse();

sm::vvec<F> back_real = hfft.inverse_real();

F maxerr = F{0};
for (std::uint32_t i = 0; i < hg.num(); ++i) {
F err = std::abs (back[i] - std::complex<F> (data[i], F{0}));
F err_real = std::abs (back_real[i] - data[i]);
maxerr = std::max (maxerr, err);
maxerr = std::max (maxerr, err_real);
}
std::cout << label << ": hg.num()=" << hg.num() << " spectrum rows=" << hfft.asa_rows << " cols=" << hfft.asa_cols
<< " (size " << hfft.size() << ") max roundtrip error: " << maxerr << std::endl;
Expand Down
Loading