My question is related to this post
I have a 1D vector, the target vector, represented as 2D (knowing the nr of cols and rows) to which i need to apply an FFT2D. Having only the FFT1D, in order to obtain a FFT2D, i will need to apply it on each row and then on each column.
std::vector<double> targetVector;
int nrColTargetVector = 18, nrRowTargetVector = 17, fft2Cols, fft2Rows;
std::vector<complex> fft1DTargetVectorRows;
std::vector<complex> fft2DTargetVector;
auto newFFT = new FFT;
int flag = 0;
// FFT1D on rows
for(int i = 0 ; i < nrRowTargetVector ; i++)
{
std::vector<complex> tempVectorFFT;
for (int j = 0; j < nrColTargetVector; j++)
tempVectorFFT.push_back(complexVictor[i * nrColTargetVector + j]);
std::vector<complex> tempFFTtransformROW = newFFT->transform(tempVectorFFT);
copy(tempFFTtransformROW.begin(), tempFFTtransformROW.end(), back_inserter(fft1DTargetVectorRows));
}
//FFT1D on columns
fft2Cols = (fft1DTargetVectorRows.size()/nrRowTargetVector);
fft2DTargetVector.reserve(0*0);
for(int i = 0; i <fft2Cols ; i++)
{
std::vector<complex> tempVectorFFT;
for (int j = 0; j < nrRowTargetVector; j++)
tempVectorFFT.push_back(fft1DTargetVectorRows[i + fft2Cols *j]);
std::vector<complex> tempFFTtransformCOLUMN = newFFT->transform(tempVectorFFT);
if(!flag)
{
//to insert values at certain indexes we need to resize the result vector
fft2Rows = tempFFTtransformCOLUMN.size();
fft2DTargetVector.reserve(fft2Rowsfft2Cols);
flag ++;
}
for(int k = 0; k < tempFFTtransformCOLUMN.size(); k++)
fft2DTargetVector[i + tempFFTtransformCOLUMN.size() k] = tempFFTtransformCOLUMN[k];
}
My FFT1D algorithm is doing padding until the next position power of 2. So for each row i am adding 0-s until position 32 and then on each column the same.
I have a suspicion that the 0-padding to each line and then column is not really correct since it adds 0-s in between the 1D vector's position that holds my data .