Last active
January 27, 2022 23:10
-
-
Save theoknock/ba6b9809530bf7a571c81cb606c896f6 to your computer and use it in GitHub Desktop.
Using vDSP and Objective-C to add arrays of floats. This is the Objective-C version of the Swift example(s) for using vDSP for vector processing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void (^add_float_arrays)(void) = ^{ | |
float a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; | |
float b[] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; | |
float c[] = {[0 ... 9] = NAN}; | |
vDSP_vadd(a, 1, b, 1, c, 1, 10); | |
for (int i = 0; i < 10; i++) printf("%f\n", c[i]); | |
/* | |
Console output: | |
11.000000 | |
22.000000 | |
33.000000 | |
44.000000 | |
55.000000 | |
66.000000 | |
77.000000 | |
88.000000 | |
99.000000 | |
110.000000 | |
*/ | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment