vecLib is comprised of the following 9 headers:
cblas.h / vBLAS.h | Interface for BLAS functions |
clapack.h | Interface for LAPACK functions |
vectorOps.h | Vector implementations of the BLAS routines. |
vBasicOps.h | Basic algebraic operations. 8-, 16-, 32-, 64-, 128-bit division, saturated addition / subtraction, shi / rotate, etc. |
vfp.h | Transcendental operations (sin, cos, log, etc.) on single vector floating point quantities. |
vForce.h | Transcendental operations on arrays of floating point quantities. |
vBigNum.h | Operations on large numbers (128-, 256-, 512-, 1024-bit quantities) |
vDSP.h | Digital signal processing algorithms including FFTs, signal clipping, filters, and type conversions. |
Fast-Fourier Transform (FFT) is the fundamental digital signal processing algorithm. It decomposes a sequence of values into components with different frequencies.
Although they have wide-ranging applications across mathematics and engineering, most application developers encounter FFTs for audio or video processing, as a way of determining the critical values in a noisy signal.
int x = 8;
int y = 8;
int dimensions = x * y;
int log2_x = (int)log2((double)x);
int log2_y = (int)log2((double)y);
DSPComplex *data = (DSPComplex *)malloc(sizeof(DSPComplex) * dimensions);
for (NSUInteger i = 0; i < dimensions; i++)
{
data[i].real = (float)i;
data[i].imag = (float)(dimensions - i) - 1.0f;
}
DSPSplitComplex input = {
.realp = (float *)malloc(sizeof(float) * dimensions),
.imagp = (float *)malloc(sizeof(float) * dimensions),
};
vDSP_ctoz(data, 2, &input, 1, dimensions);
FFTSetup weights = vDSP_create_fftsetup(fmax(log2_x, log2_y), kFFTRadix2);
vDSP_fft2d_zip(weights, &input, 1, 0, log2_x, log2_y, FFT_FORWARD);
vDSP_destroy_fftsetup(fft_weights);
vDSP_ztoc(&input, 1, data, 2, dimensions);
for (NSUInteger i = 0; i < dimensions; i++)
{
NSLog(@"%g %g", data[i].real, data[i].imag);
}
free(input.realp);
free(input.imagp);
free(data);