-
-Common fftshift function. Use Nim's openMP operator (||) for rank <= 3
-
Example:
-
importarraymancer
-letinput_tensor=randomTensor[float64](10,10,10,10.0)
-# output_tensor is the fftshift of input_tensor
-varoutput_tensor=fftshift(input_tensor)
-
-Common ifftshift function. Use Nim's openMP operator (||) for rank <= 3
-
Example:
-
importarraymancer
-letinput_tensor=randomTensor[float64](10,10,10,10.0)
-# output_tensor is the fftshift of input_tensor
-varoutput_tensor=ifftshift(input_tensor)
+
+Common fftshift function. Use Nim's openMP operator (||) for rank <= 3
+
Example:
+
importarraymancer
+letinput_tensor=randomTensor[float64](10,10,10,10.0)
+# output_tensor is the fftshift of input_tensor
+varoutput_tensor=fftshift(input_tensor)
+
+Common ifftshift function. Use Nim's openMP operator (||) for rank <= 3
+
Example:
+
importarraymancer
+letinput_tensor=randomTensor[float64](10,10,10,10.0)
+# output_tensor is the fftshift of input_tensor
+varoutput_tensor=ifftshift(input_tensor)
diff --git a/src/fftw3.nim b/src/fftw3.nim
index 8036e0a..1073121 100644
--- a/src/fftw3.nim
+++ b/src/fftw3.nim
@@ -46,15 +46,16 @@
import arraymancer
import sequtils
import complex
-import arraymancer/tensor/private/p_accessors
import fftw3/libutils
# Import mostly for documentation links
{.push warning[UnusedImport]: off.}
import fftw3/guru, fftw3/wisdom
{.pop.}
+import fftw3/fftshift
# export used types
export fftw_plan
export fftw_r2r_kind
+export fftshift
const
FFTW_MEASURE* = 0 ## ``fftw_plan`` planner flag.
@@ -92,95 +93,6 @@ const
##
## Compute an inverse DFT transform.
-
-# FFT Shift
-proc circshift_impl[T](t: Tensor[T], xshift: int, yshift: int, zshift: int): Tensor[T] =
- assert(t.rank == 3)
- var X = t.shape[0]
- var Y = t.shape[1]
- var Z = t.shape[2]
-
- result = newTensor[T](t.shape.toSeq)
- for i in 0||(X-1):
- var ii = (i + xshift) mod X
- for j in 0||(Y-1):
- var jj = (j + yshift) mod Y
- for k in 0||(Z-1):
- var kk = (k + zshift) mod Z
- result[ii, jj, kk] = t[i, j, k]
-
-proc circshift_impl[T](t: Tensor[T], xshift: int, yshift: int): Tensor[T] =
- assert(t.rank == 2)
- var X = t.shape[0]
- var Y = t.shape[1]
-
- result = newTensor[T](t.shape.toSeq)
- for i in 0||(X-1):
- var ii = (i + xshift) mod X
- for j in 0||(Y-1):
- var jj = (j + yshift) mod Y
- result[ii, jj] = t[i, j]
-
-proc circshift_impl[T](t: Tensor[T], xshift: int): Tensor[T] =
- assert(t.rank == 1)
- var X = t.shape[0]
-
- result = newTensor[T](t.shape.toSeq)
- for i in 0||(X-1):
- var ii = (i + xshift) mod X
- result[ii] = t[i]
-
-# TODO : Generic implementation in parallel
-proc circshift_impl[T](t: Tensor[T], shift: seq[int]): Tensor[T] =
- let shape = t.shape.toSeq
- result = newTensor[T](t.shape.toSeq)
- for coord, values in t:
- var newcoord: seq[int] = newSeq[int](t.rank)
- for i in 0..