- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to understand the correct way to zero-pad the 2d-data.
This way I did not get the correct output.
MKL_LONG dim_child[2];
dim_child[0] = 9;
dim_child[1] = 17;
MKL_LONG dim_parent[2];
dim_parent[0] = 12;
dim_parent[1] = 23;
MKL_LONG status;
DFTI_DESCRIPTOR_HANDLE frwd_hndl = NULL;
DFTI_DESCRIPTOR_HANDLE bkwd_hndl = NULL;
double forward_scale = sqrt(2.0 * pi) / static_cast<double>(dim_child[0] * dim_child[1]);
status = DftiCreateDescriptor(&frwd_hndl, DFTI_DOUBLE, DFTI_COMPLEX, 2, dim_child);
status = DftiSetValue(frwd_hndl, DFTI_FORWARD_SCALE, forward_scale);
status = DftiCommitDescriptor(frwd_hndl);
status = DftiCreateDescriptor(&bkwd_hndl, DFTI_DOUBLE, DFTI_COMPLEX, 2, dim_parent);
status = DftiCommitDescriptor(bkwd_hndl);
int size_child = dim_child[0] * dim_child[1];
int size_parent = dim_parent[0] * dim_parent[1];
MKL_Complex16 *fourier_coeff = NULL;
MKL_Complex16 *filterd_coeff = NULL;
fourier_coeff = (MKL_Complex16*)mkl_malloc(size_child * sizeof(MKL_Complex16), 64);
filterd_coeff = (MKL_Complex16*)mkl_malloc(size_parent * sizeof(MKL_Complex16), 64);
for (int j=0; j<lg_child; j++)
{
for (int i=0; i<lt_child; i++)
{
int index = i + (j*lt_child);
fourier_coeff[index].real = // some_value;
fourier_coeff[index].imag = // some_value;
}
}
status = DftiComputeForward(frwd_hndl, fourier_coeff);
status = DftiFreeDescriptor(&frwd_hndl);
for (int j_prime=0; j_prime<lg_parent; j_prime++)
{
for (int j=0; j<lg_child; j++)
{
for (int i=0; i<lt_child; i++)
{
int index = i + (j * lt_child);
int index_filter = i + (j_prime * lt_parent);
// zero-padding at the end of each row of length (lt_parent - lt_child)
// [x x x x x x x x x x x x x x x x x 0 0 0 0 0 0 x x x x x x x x x x x x x x x x x 0 0 0 0 0 0...]
// _______________17________________ _____6_____
filterd_coeff[index_filter].real += (fourier_coeff[index].real);
filterd_coeff[index_filter].imag += (fourier_coeff[index].imag);
}
}
}
status = DftiComputeBackward(bkwd_hndl, filterd_coeff);
status = DftiFreeDescriptor(&bkwd_hndl);
for (int j=0; j<lg_parent; j++)
{
for (int i=0; i<lt_parent; i++)
{
int index = i + (j*lt_parent);
std::cout << filterd_coeff[index].real<<"\t"<<filterd_coeff[index].imag<<std::endl;
}
}
mkl_free(fourier_coeff);
mkl_free(filterd_coeff);
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for posting in the forum!
I'm trying to understand the issue here. It looks the code is trying to zero-pad the Fourier coefficients after the FFT. Could you please provide more information about what this zero-padding is trying to achieve and what output is expected?
Thanks,
Fengrui
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page