ccfftip
Perform in-place fast Fourier transform.
The function interface declaration is as follows:
- Initialization:
vsip_fft_f *vsip_ccfftip_create_f(uint32_t N, float scale, vsip_fft_dir dir, uint32_t ntimes, vsip_alg_hint hint);
- Main function:
void vsip_ccfftip_f(const vsip_fft_f *Offt, const vsip_cvview_f *x);
- Memory release:
int32_t vsip_fft_destroy_f(vsip_fft_f *fft);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
N |
Vector length |
(1,∞) |
Input |
scale |
Scaling coefficient after fast Fourier transform is complete. |
Any real number |
Input |
dir |
Direction of fast Fourier transform |
Enumerated values of vsip_fft_dir: VSIP_FFT_FWD = -1: Forward VSIP_FFT_INV = +1: Inverse |
Input |
ntimes |
Number of times that fast Fourier transform is performed. This parameter is invalid. |
Any |
Input |
hint |
Algorithm used in fast Fourier transform. This parameter is invalid. |
Enumerated values of vsip_alg_hint: VSIP_ALG_SPACE = 0: Memory space VSIP_ALG_TIME = 1: Time consumption VSIP_ALG_NOISE = 2: Noise |
Input |
Offt/fft |
Pointer to the fast Fourier transform structure |
The value cannot be NULL. |
Input |
x |
Pointer to the source vector |
The value cannot be NULL. |
Input/Output |
Abnormal Input
When a null pointer is input, the function directly returns a result.
Note
- Before this interface is called for calculation, the create function must be called to initialize the vsip_fft_f standard structure.
- The initialization of the vsip_fft_f structure needs to be applied for in the create function. You cannot apply for and define this structure by yourself.
- After the vsip_fft_f structure has been initialized, if a main function fails to be executed, the destroy function must be used to release the structure.
Example
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "kvsip.h"
#include "vsip.h"
#include "vsip_type.h"
#define BUFFER_SIZE_T 10
void CcfftipExample()
{
float src[BUFFER_SIZE_T] = {1.64f, 1.63f, -1.09f, 0.71f, -3.20f, -0.43f, 0.41f, -4.83f, 5.36f, -4.40f};
float dst[BUFFER_SIZE_T] = {1.64f, 1.63f, -1.09f, 0.71f, -3.20f, -0.43f, 0.41f, -4.83f, 5.36f, -4.40f};
int64_t stride = 1;
int64_t cvLen = BUFFER_SIZE_T / 2;
uint64_t offset = 0;
vsip_cblock_f *block_r = vsip_cblockbind_f(dst, NULL, cvLen, VSIP_MEM_NONE);
vsip_cvview_f *r = vsip_cvbind_f(block_r, offset, stride, cvLen);
vsip_cblockadmit_f(block_r, VSIP_TRUE);
vsip_fft_f *Offt = vsip_ccfftip_create_f(cvLen, 1.0f, VSIP_FFT_FWD, 0, VSIP_ALG_SPACE);
vsip_ccfftip_f(Offt, r);
(void)vsip_fft_destroy_f(Offt);
vsip_cvalldestroy_f(r);
printf("src before:\n");
for (int32_t i = 0; i < cvLen; ++i) {
printf("%.2f ", src[i * 2]);
printf("%.2f ", src[i * 2 + 1]);
}
printf("\nsrc after:\n");
for (int32_t i = 0; i < cvLen; ++i) {
printf("%.2f ", dst[i * 2]);
printf("%.2f ", dst[i * 2 + 1]);
}
printf("\n");
}
int main(void) {
CcfftipExample();
return 0;
}
Output:
src before: 1.64 1.63 -1.09 0.71 -3.20 -0.43 0.41 -4.83 5.36 -4.40 src after: 3.12 -7.32 12.66 13.00 -3.86 3.35 -1.50 2.63 -2.23 -3.51