# Forums - fcvFFTu8 and fcvIFFTf32 usage not clear

7 posts / 0 new
fcvFFTu8 and fcvIFFTf32 usage not clear
kappaiah
Join Date: 21 Mar 13
Posts: 3
Posted: Tue, 2014-06-03 15:59

Hi.

I'm trying to understand how the new FFT functions work. Here's my sample code:

```void
testFFT()
{
uint8_t FASTCV_ALIGN128(x[]) = {1, 2, 3, 4};
size_t length = sizeof(x) / sizeof(x[0]);
uint8_t FASTCV_ALIGN128(y[length]);
float32_t FASTCV_ALIGN128(f[2 * length]);
fcvFFTu8(x, length, 1, length, f, 2 * length * sizeof(float32_t));
for (size_t i = 0; i < length; ++i) {
IPRINTF("FFT %d: %f + %fj", i, f[2 * i], f[2 * i + 1]);
}
fcvIFFTf32(f, length * 2, 1, length * 2 * sizeof(float32_t), y, length);
for (size_t i = 0; i < length; ++i) {
IPRINTF("IFFT %d: %f", i, y[i]);
}
}

```

The output I get is:

```FFT 0: 20.000000 + 0.000000j
FFT 1: -4.000000 + 0.000000j
FFT 2: -4.000000 + 0.000000j
FFT 3: -4.000000 + 0.000000j
IFFT 0: 0.000000
IFFT 1: 0.000000
IFFT 2: 0.000000
IFFT 3: 0.000000
```

Now, my questions are: (1) why does the FFT output "round" the complex values? Second, why does the IFFT look like all zeros? Am I doing something wrong here?

Thanks.

jeff4s Moderator
Join Date: 4 Nov 12
Posts: 106
Posted: Fri, 2014-06-06 16:19

Hi,

Currently FFT/IFFT works on sequence of length 8 or larger. In next release it will be enhanced to handle shorter sequence like the one in your example.

Cheers,

-Jeff

• 0
• 0
kappaiah
Join Date: 21 Mar 13
Posts: 3
Posted: Mon, 2014-06-09 07:14

Thanks Jeff, but that doesn't seem to do it for me. For example:

```void
testFFT()
{
uint8_t FASTCV_ALIGN128(x[]) = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
size_t length = sizeof(x) / sizeof(x[0]);
uint8_t FASTCV_ALIGN128(y[length]);
float32_t FASTCV_ALIGN128(f[2 * length]);
fcvFFTu8(x, length, 1, length, f, 2 * length * sizeof(float32_t));
IPRINTF("FFT Length: %d/%d", sizeof(x), sizeof(x[0]));
for (size_t i = 0; i < length; ++i) {
IPRINTF("FFT %d: %f + %fj", i, f[2 * i], f[2 * i + 1]);
}
f[0] = 10.0f;
f[1] = 0.0f;
f[2] = -2.0f;
f[3] = 2.0f;
f[4] = -2.0f;
f[5] = 0.0f;
f[6] = -2.0f;
f[7] = -2.0f;

fcvIFFTf32(f, length * 2, 1, length * 2 * sizeof(float32_t), y, length);
for (size_t i = 0; i < length; ++i) {
IPRINTF("IFFT %d: %f", i, y[i]);
}
}
```

This gives me this output:

```FFT 0: 136.000000 + 0.000000j
FFT 1: -9.000000 + 40.000000j
FFT 2: -8.000000 + 19.000000j
FFT 3: -9.000000 + 11.000000j
FFT 4: -8.000000 + 7.000000j
FFT 5: -8.000000 + 5.000000j
FFT 6: -8.000000 + 3.000000j
FFT 7: -8.000000 + 1.000000j
FFT 8: -8.000000 + 0.000000j
FFT 9: -8.000000 + -2.000000j
FFT 10: -8.000000 + -4.000000j
FFT 11: -8.000000 + -6.000000j
FFT 12: -8.000000 + -8.000000j
FFT 13: -9.000000 + -12.000000j
FFT 14: -8.000000 + -20.000000j
FFT 15: -9.000000 + -41.000000j
IFFT 0: 0.000000
IFFT 1: 0.000000
IFFT 2: 0.000000
IFFT 3: 0.000000
IFFT 4: 0.000000
IFFT 5: 0.000000
IFFT 6: 0.000000
IFFT 7: 0.000000
IFFT 8: 0.000000
IFFT 9: 0.000000
IFFT 10: 0.000000
IFFT 11: 0.000000
IFFT 12: 0.000000
IFFT 13: 0.000000
IFFT 14: 0.000000
IFFT 15: 0.000000
```

What am I doing wrong?

Thanks.

• 0
• 0
kappaiah
Join Date: 21 Mar 13
Posts: 3
Posted: Mon, 2014-06-09 07:18

Oh, and even this gives me the same output:

```void
testFFT()
{
uint8_t FASTCV_ALIGN128(x[]) = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
size_t length = sizeof(x) / sizeof(x[0]);
uint8_t FASTCV_ALIGN128(y[length]);
float32_t FASTCV_ALIGN128(f[2 * length]);
fcvFFTu8(x, length, 1, length, f, 2 * length * sizeof(float32_t));
IPRINTF("FFT Length: %d/%d", sizeof(x), sizeof(x[0]));
for (size_t i = 0; i < length; ++i) {
IPRINTF("FFT %d: %f + %fj", i, f[2 * i], f[2 * i + 1]);
}
fcvIFFTf32(f, length * 2, 1, length * 2 * sizeof(float32_t), y, length);
for (size_t i = 0; i < length; ++i) {
IPRINTF("IFFT %d: %f", i, y[i]);
}
}
```
• 0
• 0
jeff4s Moderator
Join Date: 4 Nov 12
Posts: 106
Posted: Wed, 2014-06-18 14:55

The output of IFFT is u8 type, and you should use %d to print.

• 0
• 0
Kazem
Join Date: 28 Jul 14
Location: Montreal
Posts: 10
Posted: Thu, 2014-07-31 16:01

Hi,

Is it possible to run this algorithm in Hexagon?

Is there any other implemetation for using FFT?

Thanks,

• 0
• 0
jeff4s Moderator
Join Date: 4 Nov 12
Posts: 106
Posted: Thu, 2014-07-31 18:13

Yes FFT has Hexagon implementation. Obviously it can only run on Snapdragon platform and the platform must have FastCV 1.5.0 or later version pre-installed.

Cheers,

-Jeff

• 0
• 0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.