-
Notifications
You must be signed in to change notification settings - Fork 36
/
vDSP.h
8630 lines (6928 loc) · 268 KB
/
vDSP.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
File: vecLib/vDSP.h
Contains: AltiVec DSP Interfaces
Version: vecLib-516.0
Copyright: � 2000-2014 by Apple Inc., all rights reserved.
For vDSP documentation, search for "vDSP" at <http://developer.apple.com>
or search for one of the routine names below.
Some documentation for vDSP routines is provided below.
To report bugs, please use <http://developer.apple.com/bugreporter>.
*/
#ifndef __VDSP__
#define __VDSP__
// Tell compiler this file is idempotent (no need to process it more than once).
#if PRAGMA_ONCE
#pragma once
#endif
/* Documentation conventions:
Many of the routines below are documented with C-like pseudocode that
describes what they do. For example, vDSP_vadd is declared with:
extern void vDSP_vadd(
const float *__vDSP_A,
vDSP_Stride __vDSP_IA,
const float *__vDSP_B,
vDSP_Stride __vDSP_IB,
float *__vDSP_C,
vDSP_Stride __vDSP_IC,
vDSP_Length __vDSP_N)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
and is described with:
for (n = 0; n < N; ++n)
C[n] = A[n] + B[n];
The pseudocode uses two important simplifications:
Names are shorted.
The prefix "__vDSP_" is removed. This prefix is used in this
header file so that Apple parameter names do not conflict with
other developer macro names that might be used in source files
that include this header, as when a program might use "#define
N 1024" to set a preprocessor macro "N" to expand to "1024".
Vectors are simplified by omitting strides.
The parameters A and IA (with the prefix omitted) represent a
vector with its elements at memory locations A[i*IA], for
appropriate values of i. In the pseudocode, the stride IA
is omitted; the vector is treated as a simple mathematical
vector with elements A[i].
This default map is assumed for all vDSP routines unless stated
otherwise. An array without a stride parameter has unit
stride. Some routines have more complicated maps. These are
documented with each routine.
Default maps:
These default maps are used unless documented otherwise for a routine.
For real vectors:
Pseudocode: Memory:
C[n] C[n*IC]
For complex vectors:
Pseudocode: Memory:
C[n] C->realp[n*IC] + i * C->imagp[n*IC]
Observe that C[n] in the pseudocode is a complex number, with a real
component and an imaginary component.
Pseudocode:
The pseudo-code used to describe routines is largely C with some
additions:
e, pi, and i are the usual mathematical constants, approximately
2.71828182845, 3.1415926535, and sqrt(-1).
"**" is exponentiation. 3**4 is 81.
Re and Im are the real and imaginary parts of a complex number.
Re(3+4*i) is 3, and Im(3+4*i) is 4.
sum(f(j), 0 <= j < N) is the sum of f(j) evaluated for each integer
j from 0 (inclusive) to N (exclusive). sum(j**2, 0 <= j < 4) is
0 + 1 + 4 + 9 = 14. Multiple dimensions may be used. Thus,
sum(f(j, k), 0 <= j < M, 0 <= k < N) is the sum of f(j, k)
evaluated for each pair of integers (j, k) satisfying the
constraints.
conj(z) is the complex conjugate of z (the imaginary part is
negated).
|x| is the absolute value of x.
Exactness, IEEE 754 conformance:
vDSP routines are not expected to produce results identical to the
pseudo-code in the descriptions, because vDSP routines are free to
rearrange calculations for better performance. These rearrangements
are mathematical identities, so they would produce identical results
if exact arithmetic were used. However, floating-point arithmetic
is approximate, and the rounding errors will often be different when
operations are rearranged.
Generally, vDSP routines are not expected to conform to IEEE 754.
Notably, results may be not correctly rounded to the last bit even for
elementary operations, and operations involving infinities and NaNs may
be handled differently than IEEE 754 specifies.
Const:
vDSP does not modify the contents of input arrays (including input
scalars passed by address). If the specification of a routine does not
state that it alters the memory that a parameter points to, then the
routine does not alter that memory through that parameter. (It may of
course alter the same memory if it is also pointed to by an output
parameter. Such in-place operation is permitted for some vDSP routines
and not for others.)
Unfortunately, C semantics make it impractical to add "const" to
pointers inside structs, because such structs are type-incompatible
with structs containing pointers that are not const. Thus, vDSP
routines with complex parameters accept those parameters via
DSPSplitComplex and DSPDoubleSplitComplex structs (among other types)
and not via const versions of those structures.
Strides:
(Note: This section introduces strides. For an issue using strides
with complex data, see "Complex strides" below.)
Many vDSP routines use strides, which specify that the vector operated
on is embedded in a larger array in memory. Consider an array A of
1024 elements. Then:
Passing a vDSP routine: Says to operate on:
Address A and stride 1 Each element A[j]
Address A and stride 2 Every other element, A[j*2]
Address A+1 and stride 2 Every other element, starting
with A[1], so A[j*2+1]
Strides may be used to operate on columns of multi-dimensional arrays.
For example, consider a 32*64 element array, A[32][64]. Then passing
address A+13 and stride 64 instructs vDSP to operate on the elements of
column 13.
When strides are used, generally there is some accompanying parameter
that specifies the length of the operation. This length is typically
the number of elements to be processed, not the number in the larger
array. (Some vDSP routines have interactions between parameters so
that the length may specify some number of output elements but requires
a different numbe of input elements. This is documented with each
routine.)
Complex strides:
Strides with complex data (interleaved complex data, not split
complex data) are complicated by a legacy issue. Originally, complex
data was regarded as an array of individual elements, so that memory
containing values to represent complex numbers 2 + 3i, 4 + 5i, 6 + 7i,
and so on, contained individual floating-point elements:
A[0] A[1] A[2] A[3] A[4] A[5]…
2 3 4 5 6 7 …
This arrangement was said to have a stride of two, indicating that a
new complex number starts every two elements. In the modern view, we
would regard this as an array of struct with a stride of one struct.
Unfortunately, the vDSP interface is bound by requirements of backward
compatibility and must retain the original use.
Adding to this issue, a parameter is declared as a pointer to DSPComplex
or DSPDoubleComplex (both structures of two floating-point elements),
but its stride is still passed as a stride of floating-point elements.
This means that, in C, to refer to complex element i of a vector C with
stride IC, you must divide the stride by 2, using C[i*IC/2].
Essentially, the floating-point element stride passed to the vDSP
routine, IA, should be twice the complex-number struct stride.
*/
// For i386, translate new names to legacy names.
#if defined __i386__ && !defined __vDSP_TRANSLATE__
#include <vecLib/vDSP_translate.h>
#endif
#include <Availability.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#pragma options align=power
/* These symbols describe the vecLib version associated with this header.
vDSP_Version0 is a major version number.
vDSP_Version1 is a minor version number.
*/
#define vDSP_Version0 516
#define vDSP_Version1 0
/* Define types:
vDSP_Length for numbers of elements in arrays and for indices of
elements in arrays. (It is also used for the base-two logarithm of
numbers of elements, although a much smaller type is suitable for
that.)
vDSP_Stride for differences of indices of elements (which of course
includes strides).
*/
typedef unsigned long vDSP_Length;
typedef long vDSP_Stride;
/* A DSPComplex or DSPDoubleComplex is a pair of float or double values that
together represent a complex value.
*/
typedef struct DSPComplex {
float real;
float imag;
} DSPComplex;
typedef struct DSPDoubleComplex {
double real;
double imag;
} DSPDoubleComplex;
/* A DSPSplitComplex or DSPDoubleSplitComplex is a structure containing
two pointers, each to an array of float or double. These represent arrays
of complex values, with the real components of the values stored in one
array and the imaginary components of the values stored in a separate
array.
*/
typedef struct DSPSplitComplex {
float *realp;
float *imagp;
} DSPSplitComplex;
typedef struct DSPDoubleSplitComplex {
double *realp;
double *imagp;
} DSPDoubleSplitComplex;
/* The following statements declare a few simple types and constants used by
various vDSP routines.
*/
typedef int FFTDirection;
typedef int FFTRadix;
enum {
kFFTDirection_Forward = +1,
kFFTDirection_Inverse = -1
};
enum {
kFFTRadix2 = 0,
kFFTRadix3 = 1,
kFFTRadix5 = 2
};
enum {
vDSP_HALF_WINDOW = 1,
vDSP_HANN_DENORM = 0,
vDSP_HANN_NORM = 2
};
/* The following types define 24-bit data.
*/
typedef struct { uint8_t bytes[3]; } vDSP_uint24; // Unsigned 24-bit integer.
typedef struct { uint8_t bytes[3]; } vDSP_int24; // Signed 24-bit integer.
/* The following types are pointers to structures that contain data used
inside vDSP routines to assist FFT and biquad filter operations. The
contents of these structures may change from release to release, so
applications should manipulate the values only via the corresponding vDSP
setup and destroy routines.
*/
typedef struct OpaqueFFTSetup *FFTSetup;
typedef struct OpaqueFFTSetupD *FFTSetupD;
typedef struct vDSP_biquad_SetupStruct *vDSP_biquad_Setup;
typedef struct vDSP_biquad_SetupStructD *vDSP_biquad_SetupD;
/* vDSP_biquadm_Setup or vDSP_biquadm_SetupD is a pointer to a filter object
to be used with a multi-channel cascaded biquad IIR. This object carries
internal state which may be modified by any routine which uses it. Upon
creation, the state is initialized such that all delay elements are zero.
Each filter object should only be used in a single thread at a time.
*/
typedef struct vDSP_biquadm_SetupStruct *vDSP_biquadm_Setup;
typedef struct vDSP_biquadm_SetupStructD *vDSP_biquadm_SetupD;
/* vDSP_create_fftsetup and vDSP_create_ffsetupD allocate memory and prepare
constants used by single- and double-precision FFT routines, respectively.
vDSP_destroy_fftsetup and vDSP_destroy_fftsetupD free the memory. They
may be passed a null pointer, in which case they have no effect.
*/
extern FFTSetup vDSP_create_fftsetup(
vDSP_Length __vDSP_Log2n,
FFTRadix __vDSP_Radix)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
extern void vDSP_destroy_fftsetup(FFTSetup __vDSP_setup)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
extern FFTSetupD vDSP_create_fftsetupD(
vDSP_Length __vDSP_Log2n,
FFTRadix __vDSP_Radix)
__OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_4_0);
extern void vDSP_destroy_fftsetupD(FFTSetupD __vDSP_setup)
__OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_4_0);
/* vDSP_biquad_CreateSetup allocates memory and prepares the coefficients for
processing a cascaded biquad IIR filter.
vDSP_biquad_DestroySetup frees the memory allocated by
vDSP_biquad_CreateSetup.
*/
extern vDSP_biquad_Setup vDSP_biquad_CreateSetup(
const double *__vDSP_Coefficients,
vDSP_Length __vDSP_M)
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_6_0);
extern vDSP_biquad_SetupD vDSP_biquad_CreateSetupD(
const double *__vDSP_Coefficients,
vDSP_Length __vDSP_M)
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_6_0);
extern void vDSP_biquad_DestroySetup (vDSP_biquad_Setup __vDSP_setup)
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_6_0);
extern void vDSP_biquad_DestroySetupD(vDSP_biquad_SetupD __vDSP_setup)
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_6_0);
/* vDSP_biquadm_CreateSetup (for float) or vDSP_biquadm_CreateSetupD (for
double) allocates memory and prepares the coefficients for processing a
multi-channel cascaded biquad IIR filter. Delay values are set to zero.
Unlike some other setup objects in vDSP, a vDSP_biquadm_Setup or
vDSP_biquadm_SetupD contains data that is modified during a vDSP_biquadm or
vDSP_biquadmD call, and it therefore may not be used more than once
simultaneously, as in multiple threads.
vDSP_biquadm_DestroySetup (for single) or vDSP_biquadm_DestroySetupD (for
double) frees the memory allocated by the corresponding create-setup
routine.
*/
extern vDSP_biquadm_Setup vDSP_biquadm_CreateSetup(
const double *__vDSP_coeffs,
vDSP_Length __vDSP_M,
vDSP_Length __vDSP_N)
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);
extern vDSP_biquadm_SetupD vDSP_biquadm_CreateSetupD(
const double *__vDSP_coeffs,
vDSP_Length __vDSP_M,
vDSP_Length __vDSP_N)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);
extern void vDSP_biquadm_DestroySetup(vDSP_biquadm_Setup __vDSP_setup)
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);
extern void vDSP_biquadm_DestroySetupD(vDSP_biquadm_SetupD __vDSP_setup)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);
/* vDSP_biquadm_CopyState (for float) or vDSP_biquadm_CopyStateD (for double)
copies the current state between two biquadm setup objects. The two
objects must have been created with the same number of channels and
sections.
vDSP_biquadm_ResetState (for float) or vDSP_biquadm_ResetStateD (for
double) sets the delay values of a biquadm setup object to zero.
*/
extern void vDSP_biquadm_CopyState(
vDSP_biquadm_Setup __vDSP_dest,
const struct vDSP_biquadm_SetupStruct *__vDSP_src)
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);
extern void vDSP_biquadm_CopyStateD(
vDSP_biquadm_SetupD __vDSP_dest,
const struct vDSP_biquadm_SetupStructD *__vDSP_src)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);
extern void vDSP_biquadm_ResetState(vDSP_biquadm_Setup __vDSP_setup)
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);
extern void vDSP_biquadm_ResetStateD(vDSP_biquadm_SetupD __vDSP_setup)
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);
// Convert a complex array to a complex-split array.
extern void vDSP_ctoz(
const DSPComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
const DSPSplitComplex *__vDSP_Z,
vDSP_Stride __vDSP_IZ,
vDSP_Length __vDSP_N)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
extern void vDSP_ctozD(
const DSPDoubleComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
const DSPDoubleSplitComplex *__vDSP_Z,
vDSP_Stride __vDSP_IZ,
vDSP_Length __vDSP_N)
__OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_4_0);
/* Map:
Pseudocode: Memory:
C[n] C[n*IC/2].real + i * C[n*IC/2].imag
Z[n] Z->realp[n*IZ] + i * Z->imagp[n*IZ]
These compute:
for (n = 0; n < N; ++n)
Z[n] = C[n];
*/
// Convert a complex-split array to a complex array.
extern void vDSP_ztoc(
const DSPSplitComplex *__vDSP_Z,
vDSP_Stride __vDSP_IZ,
DSPComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
vDSP_Length __vDSP_N)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
extern void vDSP_ztocD(
const DSPDoubleSplitComplex *__vDSP_Z,
vDSP_Stride __vDSP_IZ,
DSPDoubleComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
vDSP_Length __vDSP_N)
__OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_4_0);
/* Map:
Pseudocode: Memory:
Z[n] Z->realp[n*IZ] + i * Z->imagp[n*IZ]
C[n] C[n*IC/2].real + i * C[n*IC/2].imag
These compute:
for (n = 0; n < N; ++n)
C[n] = Z[n];
*/
/* In-place complex Discrete Fourier Transform routines, with and without
temporary memory. We suggest you use the DFT routines instead of these.
*/
extern void vDSP_fft_zip(
FFTSetup __vDSP_Setup,
const DSPSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
extern void vDSP_fft_zipD(
FFTSetupD __vDSP_Setup,
const DSPDoubleSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_4_0);
extern void vDSP_fft_zipt(
FFTSetup __vDSP_Setup,
const DSPSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
const DSPSplitComplex *__vDSP_Buffer,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
extern void vDSP_fft_ziptD(
FFTSetupD __vDSP_Setup,
const DSPDoubleSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
const DSPDoubleSplitComplex *__vDSP_Buffer,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_4_0);
/* Maps:
For this routine, strides are shown explicitly; the default maps
are not used.
These compute:
N = 1 << Log2N;
scale = 0 < Direction ? 1 : 1./N;
// Define a complex vector, h:
for (j = 0; j < N; ++j)
h[j] = C->realp[j*IC] + i * C->imagp[j*IC];
// Perform Discrete Fourier Transform.
for (k = 0; k < N; ++k)
H[k] = scale * sum(h[j] * e**(-Direction*2*pi*i*j*k/N), 0 <= j < N);
// Store result.
for (k = 0; k < N; ++k)
{
C->realp[k*IC] = Re(H[k]);
C->imagp[k*IC] = Im(H[k]);
}
Setup must have been properly created by a call to vDSP_create_fftsetup
(for single precision) or vDSP_create_fftsetupD (for double precision)
and not subsequently destroyed.
Direction must be +1 or -1.
The temporary buffer versions perform the same operation but are
permitted to use the temporary buffer for improved performance. Each
of Buffer->realp and Buffer->imagp must contain the lesser of 16,384
bytes or N * sizeof *C->realp bytes and is preferably 16-byte aligned
or better.
*/
/* Out-of-place complex Discrete Fourier Transform routines, with and without
temporary memory. We suggest you use the DFT routines instead of these.
*/
extern void vDSP_fft_zop(
FFTSetup __vDSP_Setup,
const DSPSplitComplex *__vDSP_A,
vDSP_Stride __vDSP_IA,
const DSPSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
extern void vDSP_fft_zopt(
FFTSetup __vDSP_Setup,
const DSPSplitComplex *__vDSP_A,
vDSP_Stride __vDSP_IA,
const DSPSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
const DSPSplitComplex *__vDSP_Buffer,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
extern void vDSP_fft_zopD(
FFTSetupD __vDSP_Setup,
const DSPDoubleSplitComplex *__vDSP_A,
vDSP_Stride __vDSP_IA,
const DSPDoubleSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_4_0);
extern void vDSP_fft_zoptD(
FFTSetupD __vDSP_Setup,
const DSPDoubleSplitComplex *__vDSP_A,
vDSP_Stride __vDSP_IA,
const DSPDoubleSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
const DSPDoubleSplitComplex *__vDSP_Buffer,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_4_0);
/* Maps:
For this routine, strides are shown explicitly; the default maps
are not used.
These compute:
N = 1 << Log2N;
scale = 0 < Direction ? 1 : 1./N;
// Define a complex vector, h:
for (j = 0; j < N; ++j)
h[j] = A->realp[j*IA] + i * A->imagp[j*IA];
// Perform Discrete Fourier Transform.
for (k = 0; k < N; ++k)
H[k] = scale * sum(h[j] * e**(-Direction*2*pi*i*j*k/N), 0 <= j < N);
// Store result.
for (k = 0; k < N; ++k)
{
C->realp[k*IC] = Re(H[k]);
C->imagp[k*IC] = Im(H[k]);
}
Setup must have been properly created by a call to vDSP_create_fftsetup
(for single precision) or vDSP_create_fftsetupD (for double precision)
and not subsequently destroyed.
Direction must be +1 or -1.
The temporary buffer versions perform the same operation but are
permitted to use the temporary buffer for improved performance. Each
of Buffer->realp and Buffer->imagp must contain the lesser of 16,384
bytes or N * sizeof *C->realp bytes and is preferably 16-byte aligned
or better.
*/
/* In-place real-to-complex Discrete Fourier Transform routines, with and
without temporary memory. We suggest you use the DFT routines instead of
these.
*/
extern void vDSP_fft_zrip(
FFTSetup __vDSP_Setup,
const DSPSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
extern void vDSP_fft_zripD(
FFTSetupD __vDSP_Setup,
const DSPDoubleSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_4_0);
extern void vDSP_fft_zript(
FFTSetup __vDSP_Setup,
const DSPSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
const DSPSplitComplex *__vDSP_Buffer,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
extern void vDSP_fft_zriptD(
FFTSetupD __vDSP_Setup,
const DSPDoubleSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
const DSPDoubleSplitComplex *__vDSP_Buffer,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_4_0);
/* Maps:
For this routine, strides are shown explicitly; the default maps
are not used.
These compute:
N = 1 << Log2N;
If Direction is +1, a real-to-complex transform is performed, taking
input from a real vector that has been coerced into the complex
structure:
scale = 2;
// Define a real vector, h:
for (j = 0; j < N/2; ++j)
{
h[2*j + 0] = C->realp[j*IC];
h[2*j + 1] = C->imagp[j*IC];
}
// Perform Discrete Fourier Transform.
for (k = 0; k < N; ++k)
H[k] = scale *
sum(h[j] * e**(-Direction*2*pi*i*j*k/N), 0 <= j < N);
// Pack DC and Nyquist components into C->realp[0] and C->imagp[0].
C->realp[0*IC] = Re(H[ 0 ]).
C->imagp[0*IC] = Re(H[N/2]).
// Store regular components:
for (k = 1; k < N/2; ++k)
{
C->realp[k*IC] = Re(H[k]);
C->imagp[k*IC] = Im(H[k]);
}
Note that, for N/2 < k < N, H[k] is not stored. However, since
the input is a real vector, the output has symmetry that allows the
unstored elements to be derived from the stored elements: H[k] =
conj(H(N-k)). This symmetry also implies the DC and Nyquist
components are real, so their imaginary parts are zero.
If Direction is -1, a complex-to-real inverse transform is performed,
producing a real output vector coerced into the complex structure:
scale = 1./N;
// Define a complex vector, h:
h[ 0 ] = C->realp[0*IC];
h[N/2] = C->imagp[0*IC];
for (j = 1; j < N/2; ++j)
{
h[ j ] = C->realp[j*IC] + i * C->imagp[j*IC];
h[N-j] = conj(h[j]);
}
// Perform Discrete Fourier Transform.
for (k = 0; k < N; ++k)
H[k] = scale *
sum(h[j] * e**(-Direction*2*pi*i*j*k/N), 0 <= j < N);
// Coerce real results into complex structure:
for (k = 0; k < N/2; ++k)
{
C->realp[k*IC] = H[2*k+0];
C->imagp[k*IC] = H[2*k+1];
}
Note that, mathematically, the symmetry in the input vector compels
every H[k] to be real, so there are no imaginary components to be
stored.
Setup must have been properly created by a call to vDSP_create_fftsetup
(for single precision) or vDSP_create_fftsetupD (for double precision)
and not subsequently destroyed.
Direction must be +1 or -1.
The temporary buffer versions perform the same operation but are
permitted to use the temporary buffer for improved performance. Each
of Buffer->realp and Buffer->imagp must contain N/2 * sizeof *C->realp
bytes and is preferably 16-byte aligned or better.
*/
/* Out-of-place real-to-complex Discrete Fourier Transform routines, with and
without temporary memory. We suggest you use the DFT routines instead of
these.
*/
extern void vDSP_fft_zrop(
FFTSetup __vDSP_Setup,
const DSPSplitComplex *__vDSP_A,
vDSP_Stride __vDSP_IA,
const DSPSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
extern void vDSP_fft_zropD(
FFTSetupD __vDSP_Setup,
const DSPDoubleSplitComplex *__vDSP_A,
vDSP_Stride __vDSP_IA,
const DSPDoubleSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_4_0);
extern void vDSP_fft_zropt(
FFTSetup __vDSP_Setup,
const DSPSplitComplex *__vDSP_A,
vDSP_Stride __vDSP_IA,
const DSPSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
const DSPSplitComplex *__vDSP_Buffer,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
extern void vDSP_fft_zroptD(
FFTSetupD __vDSP_Setup,
const DSPDoubleSplitComplex *__vDSP_A,
vDSP_Stride __vDSP_IA,
const DSPDoubleSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC,
const DSPDoubleSplitComplex *__vDSP_Buffer,
vDSP_Length __vDSP_Log2N,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_4_0);
/* Maps:
For this routine, strides are shown explicitly; the default maps
are not used.
These compute:
N = 1 << Log2N;
If Direction is +1, a real-to-complex transform is performed, taking
input from a real vector that has been coerced into the complex
structure:
scale = 2;
// Define a real vector, h:
for (j = 0; j < N/2; ++j)
{
h[2*j + 0] = A->realp[j*IA];
h[2*j + 1] = A->imagp[j*IA];
}
// Perform Discrete Fourier Transform.
for (k = 0; k < N; ++k)
H[k] = scale *
sum(h[j] * e**(-Direction*2*pi*i*j*k/N), 0 <= j < N);
// Pack DC and Nyquist components into C->realp[0] and C->imagp[0].
C->realp[0*IC] = Re(H[ 0 ]).
C->imagp[0*IC] = Re(H[N/2]).
// Store regular components:
for (k = 1; k < N/2; ++k)
{
C->realp[k*IC] = Re(H[k]);
C->imagp[k*IC] = Im(H[k]);
}
Note that, for N/2 < k < N, H[k] is not stored. However, since
the input is a real vector, the output has symmetry that allows the
unstored elements to be derived from the stored elements: H[k] =
conj(H(N-k)). This symmetry also implies the DC and Nyquist
components are real, so their imaginary parts are zero.
If Direction is -1, a complex-to-real inverse transform is performed,
producing a real output vector coerced into the complex structure:
scale = 1./N;
// Define a complex vector, h:
h[ 0 ] = A->realp[0*IA];
h[N/2] = A->imagp[0*IA];
for (j = 1; j < N/2; ++j)
{
h[ j ] = A->realp[j*IA] + i * A->imagp[j*IA];
h[N-j] = conj(h[j]);
}
// Perform Discrete Fourier Transform.
for (k = 0; k < N; ++k)
H[k] = scale *
sum(h[j] * e**(-Direction*2*pi*i*j*k/N), 0 <= j < N);
// Coerce real results into complex structure:
for (k = 0; k < N/2; ++k)
{
C->realp[k*IC] = H[2*k+0];
C->imagp[k*IC] = H[2*k+1];
}
Note that, mathematically, the symmetry in the input vector compels
every H[k] to be real, so there are no imaginary components to be
stored.
Setup must have been properly created by a call to vDSP_create_fftsetup
(for single precision) or vDSP_create_fftsetupD (for double precision)
and not subsequently destroyed.
Direction must be +1 or -1.
The temporary buffer versions perform the same operation but are
permitted to use the temporary buffer for improved performance. Each
of Buffer->realp and Buffer->imagp must contain N/2 * sizeof *C->realp
bytes and is preferably 16-byte aligned or better.
*/
/* In-place two-dimensional complex Discrete Fourier Transform routines, with
and without temporary memory.
*/
extern void vDSP_fft2d_zip(
FFTSetup __vDSP_Setup,
const DSPSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC0,
vDSP_Stride __vDSP_IC1,
vDSP_Length __vDSP_Log2N0,
vDSP_Length __vDSP_Log2N1,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
extern void vDSP_fft2d_zipD(
FFTSetupD __vDSP_Setup,
const DSPDoubleSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC0,
vDSP_Stride __vDSP_IC1,
vDSP_Length __vDSP_Log2N0,
vDSP_Length __vDSP_Log2N1,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_4_0);
extern void vDSP_fft2d_zipt(
FFTSetup __vDSP_Setup,
const DSPSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC1,
vDSP_Stride __vDSP_IC0,
const DSPSplitComplex *__vDSP_Buffer,
vDSP_Length __vDSP_Log2N0,
vDSP_Length __vDSP_Log2N1,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
extern void vDSP_fft2d_ziptD(
FFTSetupD __vDSP_Setup,
const DSPDoubleSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC0,
vDSP_Stride __vDSP_IC1,
const DSPDoubleSplitComplex *__vDSP_Buffer,
vDSP_Length __vDSP_Log2N0,
vDSP_Length __vDSP_Log2N1,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_4_0);
/* Maps:
For this routine, strides are shown explicitly; the default maps
are not used.
These compute:
N0 = 1 << Log2N0;
N1 = 1 << Log2N1;
if (IC1 == 0) IC1 = IC0*N0;
scale = 0 < Direction ? 1 : 1. / (N1*N0);
// Define a complex matrix, h:
for (j1 = 0; j1 < N1; ++j1)
for (j0 = 0; j0 < N0; ++j0)
h[j1][j0] = C->realp[j1*IC1 + j0*IC0]
+ i * C->imagp[j1*IC1 + j0*IC0];
// Perform Discrete Fourier Transform.
for (k1 = 0; k1 < N1; ++k1)
for (k0 = 0; k0 < N0; ++k0)
H[k1][k0] = scale * sum(sum(h[j1][j0]
* e**(-Direction*2*pi*i*j0*k0/N0), 0 <= j0 < N0)
* e**(-Direction*2*pi*i*j1*k1/N1), 0 <= j1 < N1);
// Store result.
for (k1 = 0; k1 < N1; ++k1)
for (k0 = 0; k0 < N0; ++k0)
{
C->realp[k1*IC1 + k0*IC0] = Re(H[k1][k0]);
C->imagp[k1*IC1 + k0*IC0] = Im(H[k1][k0]);
}
Note that the 0 and 1 dimensions are separate and identical, except
that IC1 is set to a default, IC0*N0, if it is zero. If IC1 is not
zero, then the IC0 and N0 arguments may be swapped with the IC1 and N1
arguments without affecting the results.
Setup must have been properly created by a call to vDSP_create_fftsetup
(for single precision) or vDSP_create_fftsetupD (for double precision)
and not subsequently destroyed.
Direction must be +1 or -1.
The temporary buffer versions perform the same operation but are
permitted to use the temporary buffer for improved performance. Each
of Buffer->realp and Buffer->imagp must contain the lesser of 16,384
bytes or N1*N0 * sizeof *C->realp bytes and is preferably 16-byte
aligned or better.
*/
/* Out-of-place two-dimensional complex Discrete Fourier Transform routines,
with and without temporary memory.
*/
extern void vDSP_fft2d_zop(
FFTSetup __vDSP_Setup,
const DSPSplitComplex *__vDSP_A,
vDSP_Stride __vDSP_IA0,
vDSP_Stride __vDSP_IA1,
const DSPSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC0,
vDSP_Stride __vDSP_IC1,
vDSP_Length __vDSP_Log2N0,
vDSP_Length __vDSP_Log2N1,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_4_0);
extern void vDSP_fft2d_zopD(
FFTSetupD __vDSP_Setup,
const DSPDoubleSplitComplex *__vDSP_A,
vDSP_Stride __vDSP_IA0,
vDSP_Stride __vDSP_IA1,
const DSPDoubleSplitComplex *__vDSP_C,
vDSP_Stride __vDSP_IC0,
vDSP_Stride __vDSP_IC1,
vDSP_Length __vDSP_Log2N0,
vDSP_Length __vDSP_Log2N1,
FFTDirection __vDSP_Direction)
__OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_4_0);
extern void vDSP_fft2d_zopt(
FFTSetup __vDSP_Setup,
const DSPSplitComplex *__vDSP_A,