-
Notifications
You must be signed in to change notification settings - Fork 5
Update dependencies #51
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
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 2.1.2-preview | ||
| 2.2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| #pragma once | ||
|
|
||
| #include <complex> | ||
| #include <cstring> | ||
| #include <fftw3.h> | ||
| #include <xtensor.hpp> | ||
naegelejd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #include <xtensor/misc/xmanipulation.hpp> | ||
naegelejd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| namespace fftw_wrappers { | ||
|
|
||
| namespace detail { | ||
|
|
||
| // Helper function for 1D FFTW operations | ||
| template <class E> | ||
| inline auto fftw_1d_impl(E&& e, int direction, bool normalize) -> xt::xarray<std::complex<float>> { | ||
| auto size = e.size(); | ||
|
|
||
| std::vector<size_t> shape = {size}; | ||
| xt::xarray<std::complex<float>> result = xt::zeros<std::complex<float>>(shape); | ||
| xt::xarray<std::complex<float>> input = e; | ||
|
|
||
| fftwf_complex* in = reinterpret_cast<fftwf_complex*>(input.data()); | ||
| fftwf_complex* out = reinterpret_cast<fftwf_complex*>(result.data()); | ||
|
|
||
| fftwf_plan plan = fftwf_plan_dft_1d(size, in, out, direction, FFTW_ESTIMATE); | ||
| fftwf_execute(plan); | ||
| fftwf_destroy_plan(plan); | ||
|
|
||
| if (normalize) { | ||
| result /= static_cast<float>(size); | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| // Helper function for 2D FFTW operations | ||
| template <class E> | ||
| inline auto fftw_2d_impl(E&& e, int direction, bool normalize) -> xt::xarray<std::complex<float>> { | ||
| auto shape = e.shape(); | ||
|
|
||
| if (shape.size() != 2) { | ||
| throw std::runtime_error(direction == FFTW_FORWARD ? "fft2 requires 2D input" : "ifft2 requires 2D input"); | ||
| } | ||
|
|
||
| auto n0 = shape[0]; | ||
| auto n1 = shape[1]; | ||
|
|
||
| std::vector<size_t> result_shape = {n0, n1}; | ||
| xt::xarray<std::complex<float>> result = xt::zeros<std::complex<float>>(result_shape); | ||
| xt::xarray<std::complex<float>> input = e; | ||
|
|
||
| fftwf_complex* in = reinterpret_cast<fftwf_complex*>(input.data()); | ||
| fftwf_complex* out = reinterpret_cast<fftwf_complex*>(result.data()); | ||
|
|
||
| fftwf_plan plan = fftwf_plan_dft_2d(n0, n1, in, out, direction, FFTW_ESTIMATE); | ||
| fftwf_execute(plan); | ||
| fftwf_destroy_plan(plan); | ||
|
|
||
| if (normalize) { | ||
| result /= static_cast<float>(n0 * n1); | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
| } // namespace detail | ||
|
|
||
| // FFT shift functions | ||
| template <class E> | ||
| inline auto fftshift(E&& e) -> xt::xarray<typename std::decay_t<E>::value_type> { | ||
| xt::xarray<typename std::decay_t<E>::value_type> result = e; | ||
|
|
||
| for (std::size_t ax = 0; ax < result.dimension(); ++ax) { | ||
| auto size = result.shape()[ax]; | ||
| auto shift = size / 2; | ||
| result = xt::roll(result, shift, ax); | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| template <class E> | ||
| inline auto ifftshift(E&& e) -> xt::xarray<typename std::decay_t<E>::value_type> { | ||
| xt::xarray<typename std::decay_t<E>::value_type> result = e; | ||
|
|
||
| for (std::size_t ax = 0; ax < result.dimension(); ++ax) { | ||
| auto size = result.shape()[ax]; | ||
| auto shift = (size + 1) / 2; // Different from fftshift for odd sizes | ||
| result = xt::roll(result, shift, ax); | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| // 1D FFT/IFFT wrappers - now using shared implementation | ||
| template <class E> | ||
| inline auto fft(E&& e) -> xt::xarray<std::complex<float>> { | ||
| return detail::fftw_1d_impl(std::forward<E>(e), FFTW_FORWARD, false); | ||
| } | ||
|
|
||
| template <class E> | ||
| inline auto ifft(E&& e) -> xt::xarray<std::complex<float>> { | ||
| return detail::fftw_1d_impl(std::forward<E>(e), FFTW_BACKWARD, true); | ||
| } | ||
|
|
||
| // 2D FFT/IFFT wrappers - now using shared implementation | ||
| template <class E> | ||
| inline auto fft2(E&& e) -> xt::xarray<std::complex<float>> { | ||
| return detail::fftw_2d_impl(std::forward<E>(e), FFTW_FORWARD, false); | ||
| } | ||
|
|
||
| template <class E> | ||
| inline auto ifft2(E&& e) -> xt::xarray<std::complex<float>> { | ||
| return detail::fftw_2d_impl(std::forward<E>(e), FFTW_BACKWARD, true); | ||
| } | ||
|
|
||
| } // namespace fftw_wrappers | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.