# A Fourier transform that skips dimension

I have a [29990, 1, 512, 1] dimension list. I want to do Fourier transform over all [ -- , 1,512,1] and skip the first dimension. I appreciate it if you could help me.

• so each element of your list looks like {{{x1}, {x2},.., {x512}}}...is there a specific reason the elements look like this instead of {x1,x2,...,x512} (I.e. dimension [29990,512] list)? I feel like that would make this much easier to think about, but there may be a specific reason you have it formatted like this
– ydd
Commented Jun 23, 2023 at 15:06
• Please can you write some Mathematica code that generates the matrix, perhaps with fewer values, and then state exactly what you are trying to do. Is this just a problem of extracting the correct data from a nested list of lists?
– Hugh
Commented Jun 23, 2023 at 15:18
• This should give you 29990 Fourier Transforms of each sublist. Fourier[#[[2]]] & /@ list Commented Jun 23, 2023 at 15:31
• Since two of the other dimensions are 1 it might be best to Map it to the remaining dimension. Commented Jun 23, 2023 at 15:42
• @DanielLichtblau Thanks for your help. The problem is I am confused about using the map. Can you help me in more detail about how to skip F.T with map? Commented Jun 23, 2023 at 15:53

Here is a small example that I think might do what you want. First create a random array of appropriate rank.

SeedRandom[1234];
array = RandomReal[{-1, 1}, {2, 1, 6, 1}]

(* Out[11]= {{{{0.753217}, {0.0439285}, {-0.827553}, {-0.244174}, \
{-0.976711}, {0.854532}}}, {{{0.0875135}, {-0.0413367}, {-0.509302}, \
{0.519792}, {0.969986}, {-0.56591}}}} *)


This is what you do NOT want.

ft1 = Fourier[array]

(* Out[18]= {{{{0.0184704 + 0. I}, {0.399096 - 0.40404 I}, {0.474158 +
0.261025 I}, {-0.30879 + 0. I}, {0.474158 -
0.261025 I}, {0.399096 + 0.40404 I}}}, {{{-0.24754 +
0. I}, {0.956957 + 0.0733171 I}, {0.081221 -
0.740906 I}, {-0.675784 + 0. I}, {0.081221 +
0.740906 I}, {0.956957 - 0.0733171 I}}}} *)


I think this gives what you want.

ft2 = Map[Fourier, array]

(* Out[19]= {{{{-0.161977 + 0. I}, {0.958875 - 0.233857 I}, {0.392712 -
0.339327 I}, {-0.6962 + 0. I}, {0.392712 +
0.339327 I}, {0.958875 + 0.233857 I}}}, {{{0.188098 +
0. I}, {-0.394467 - 0.337543 I}, {0.277848 +
0.708472 I}, {0.259504 + 0. I}, {0.277848 -
0.708472 I}, {-0.394467 + 0.337543 I}}}} *)


Or as I mentioned you could map it to the level at which it's needed.

ft3 = Map[Fourier, array, {2}]

(* Out[20]= {{{{-0.161977 + 0. I}, {0.958875 - 0.233857 I}, {0.392712 -
0.339327 I}, {-0.6962 + 0. I}, {0.392712 +
0.339327 I}, {0.958875 + 0.233857 I}}}, {{{0.188098 +
0. I}, {-0.394467 - 0.337543 I}, {0.277848 +
0.708472 I}, {0.259504 + 0. I}, {0.277848 -
0.708472 I}, {-0.394467 + 0.337543 I}}}} *)


We can recover the original array by mapping InverseFourier in the same way.

ift2 = Map[InverseFourier, ft2]

(* Out[21]= {{{{0.753217}, {0.0439285}, {-0.827553}, {-0.244174}, \
{-0.976711}, {0.854532}}}, {{{0.0875135}, {-0.0413367}, {-0.509302}, \
{0.519792}, {0.969986}, {-0.56591}}}} *)


I do not know for certain if this is what's wanted, but it's how I interpret the question. If this is wrong please follow up and someone (maybe even me, who knows?) will give a better answer.