# Custom array with padding through a view

**URL:** <https://discourse.julialang.org/t/custom-array-with-padding-through-a-view/91914>\
**Category:** General Usage\
**Created:** [December 20, 2022, 9:07pm UTC](https://discourse.julialang.org/t/custom-array-with-padding-through-a-view/91914 "2022-12-20T21:07:53Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![uniment](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uniment/32/24532_2.png) [@uniment](https://discourse.julialang.org/u/uniment)\
**Post date:** [December 23, 2022, 10:27am UTC](https://discourse.julialang.org/t/custom-array-with-padding-through-a-view/91914/6 "2022-12-23T10:27:50Z")

</div>

> [@mkoculak](#):
>
> However, this should work fine for a native Julia FFT, if it ever comes to be, right?

It should! Although to really capitalize on it, you’d want a custom FFT function too which is optimized for memory efficiency.

With all the brainiacs here, I don’t doubt that someday we’ll have a full-Julia FFT package. It could get really fun.

I wrote a toy FFT in fourteen lines (ten excluding comments) as a demo for a syntax proposal [here](https://discourse.julialang.org/t/fixing-the-piping-chaining-issue-rev-3/90836/67) and did some rough benchmarking. IIRC, on initial runs it was about 20% slower than FFTW with absolutely zero optimization, no compiler hints, no nothing. Not bad!

But then, on subsequent runs FFTW runs like ten times faster 😅 it turns out that most of the time is spent computing the twiddle factors (values of e^{-i\theta} where 0\le \theta\<\pi). For a given dimensionality of data, the twiddle factors are constant so FFTW will [memoize](https://juliapackages.com/p/memoize) the values to allow later runs to be faster.

I was just toying with syntax, so I couldn’t be bothered to optimize it. Also, FFTW works with non-radix-2 data and multi-dimensional arrays… humanity has spent a fair bit of time developing the package so it’s darn near perfect.

But who knows! Maybe someday somebody will be motivated to port it to Julia (maybe to get automatic differentiation or something?), and then the real fun can begin.

---

_[View the full topic](https://discourse.julialang.org/t/custom-array-with-padding-through-a-view/91914)._
