Closed Elukej closed 1 year ago
@dancazarin Please
Hello, FFT size is 8 in your case. But then you're passing data that is less than 8 elements. So the code reads the data past the end of the input array. Pass an array with the correct size to make it work. To pad with zeros:
univector<complex<double>> full = truncate(padded(make_univector(arr)), 8);
The data will be copied but it's the only way to pass an array padded with zeros considering the fact that FFT requires the full array.
Some bounds checks are omitted for performance reasons but maybe throwing error is a good solution for detecting such cases as passing data with incorrect size.
KFR FFT algorithm always requires contiguous input and output data. So only contiguous tensors (or tensor slices that are tensors as well) are valid for FFT and can be passed directly (if size matches the selected FFT size). The above code that will make a copy will work well with any tensors.
@dancazarin Thank you! My issue is resolved. The copying of data is the way to go then for non contigious tensor slices.
Hello. I want to apply
dft
to one of the dimensions of atensor
and expand that dimension to have more elements as to represent higher resolution of thedft
. For example, row length oftensor
is 4 and I want to get outputtensor
to have row length of 8. If I would do this with inputunivector
that has 4 elements, and outputunivector
of 8 elements and adft_plan
that is of size 8, it would treat input like it was padded with 4 zeros and the result would be higher resolutiondft
like I desire. The problem arises if I extract the row of atensor
and createunivector_ref
from it.When I try to apply the transform like in the snippet above, the
univector_ref
is taking the next 4 items from the tensor so it does the tranformation over{1,2,3,4,5,6,7,8}
instead of just{1,2,3,4}
(or{1,2,3,4,0,0,0,0}
) like in the first case. The output that snippet produces which ilustrates the point is:The same behavior happens if the output array is
univector_ref
to row of some outputtensor
that has expanded rows to accept higher resolutiondft
. Is it possible with kfr to achieve the first behavior(like in the first plan execution) without copying inputtensor
into atensor
that matches the wanted outputtensor
layout with zero padding on the added dimension first and only then applyingdft
?