I'm using the accelerate framework to optimize my DSP code. There are several times when I want to copy the contents of one array (or portion of an array) to another.
I can't seem to find an appropriate function to do this, so instead I've been doing something kind of silly, which is to multiply the array by 1 (or add 0) and get the copy that way.
float one = 1;
float sourceArray = new float[arrayLength];
/////....sourceArray is filled up with data
float destArray = new float[arrayLength];
vDSP_vsmul(sourceArray, 1, &one, destArray, 1, arrayLength);
there has to be a better way to do this!? Thanks!
If you're willing to use the BLAS portion of Accelerate, Jeff Biggus has benchmarked cblas_scopy()
as being faster than even memcpy()
.
How about memcpy?
#include <string.h>
memcpy(destArray, sourceArray, arrayLength * sizeof(float));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With