# Better Documentation of \[,Dims\] for Julia FFT function

**URL:** https://discourse.julialang.org/t/better-documentation-of-dims-for-julia-fft-function/9016
**Category:** General Usage
**Tags:** question
**Created:** [February 12, 2018, 4:00pm UTC](https://discourse.julialang.org/t/better-documentation-of-dims-for-julia-fft-function/9016 "2018-02-12T16:00:58Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Jordan\_Cluts](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jordan_cluts/32/13753_2.png) [@Jordan\_Cluts](https://discourse.julialang.org/u/Jordan_Cluts)
#### Post date: [February 12, 2018, 4:00pm UTC](https://discourse.julialang.org/t/better-documentation-of-dims-for-julia-fft-function/9016/1 "2018-02-12T16:00:58Z")

</div>

I am attempting to find the FFT of a set of vectors. In particular I have an array that is 2234 rows long with each row being a signal to perform an FFT on. The documentation on FFT states that

> The optional dims argument specifies an iterable subset of dimensions (e.g. an integer, range, tuple, or array) to transform along

There are no examples or further description of this functionality however. I could of course do

```julia
for k=1:length(Array[:,1])
    FFTout[k,:]=fft(Array[k,:])
end

```

But I cannot tell if this could be sped up by the dims functionality (or by broadcasting FFT with some sort of input into the function e.g. FFT.(Array[1:end,:]) perhaps)

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [February 12, 2018, 4:47pm UTC](https://discourse.julialang.org/t/better-documentation-of-dims-for-julia-fft-function/9016/2 "2018-02-12T16:47:54Z")

</div>

You want to fft the rows (along the 2nd index dimension), so pass 2 for the `dims` argument.

This is similar to the `dims` argument to `sum` etc.

And if you really care about performance, use `plan_fft` and a preallocated output array.

---

<div class="post-metadata">

### Author: ![Jordan\_Cluts](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jordan_cluts/32/13753_2.png) [@Jordan\_Cluts](https://discourse.julialang.org/u/Jordan_Cluts)
#### Post date: [February 12, 2018, 4:56pm UTC](https://discourse.julialang.org/t/better-documentation-of-dims-for-julia-fft-function/9016/3 "2018-02-12T16:56:22Z")

</div>

Ah excellent, FFTout=fft(Array,[2]) does precisely what I need and makes clear how plan\_fft could be used as well as preallocation for increased performance if needed.

Being pointed to the sum function and its description of dims was very helpful as well, thanks.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [February 12, 2018, 5:20pm UTC](https://discourse.julialang.org/t/better-documentation-of-dims-for-julia-fft-function/9016/4 "2018-02-12T17:20:24Z")

</div>

> [@Jordan\_Cluts](#):
>
> `fft(Array,[2])` does precisely what I need

It is equivalent to do `fft(Array,2)`, and it avoids allocating the temporary array `[2]`. (If you have multiple dimensions to transform, I would use a tuple.)
