NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
ifftshift.hpp
Go to the documentation of this file.
1
28#pragma once
29
31#include "NumCpp/NdArray.hpp"
32
33namespace nc::fft
34{
35 //===========================================================================
36 // Method Description:
47 template<typename dtype>
49 {
51
52 switch (inAxis)
53 {
54 case Axis::NONE:
55 {
56 auto shift = inX.size() / 2;
57 shift += inX.size() % 2 == 1 ? 1 : 0;
58 return roll(inX, shift, inAxis);
59 }
60 case Axis::COL:
61 {
62 auto shift = inX.numCols() / 2;
63 shift += inX.numCols() % 2 == 1 ? 1 : 0;
64 return roll(inX, shift, inAxis);
65 }
66 case Axis::ROW:
67 {
68 auto shift = inX.numRows() / 2;
69 shift += inX.numRows() % 2 == 1 ? 1 : 0;
70 return roll(inX, shift, inAxis);
71 }
72 default:
73 {
74 THROW_INVALID_ARGUMENT_ERROR("Unimplemented axis type.");
75 return {};
76 }
77 }
78 }
79} // namespace nc::fft
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition StaticAsserts.hpp:56
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:135
size_type size() const noexcept
Definition NdArrayCore.hpp:4600
size_type numCols() const noexcept
Definition NdArrayCore.hpp:3541
size_type numRows() const noexcept
Definition NdArrayCore.hpp:3553
Definition FFT/FFT.hpp:40
NdArray< dtype > ifftshift(const NdArray< dtype > &inX, Axis inAxis=Axis::NONE)
Definition ifftshift.hpp:48
Axis
Enum To describe an axis.
Definition Enums.hpp:36
@ ROW
Definition Enums.hpp:38
@ COL
Definition Enums.hpp:39
@ NONE
Definition Enums.hpp:37
NdArray< dtype > roll(const NdArray< dtype > &inArray, int32 inShift, Axis inAxis=Axis::NONE)
Definition roll.hpp:52