You can use vDSP_vclr and vDSP_vadd as follows:
int sourceLength = 3; float* source = (float*)malloc(sourceLength * sizeof(float)); // source is filled with data, let say [5, 5, 5] int destinationLength = 10; float* destination = (float*)malloc(destinationLength * sizeof(float)); // destination is filled with ones so [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] // Prepare the destination array to receive the source array // by setting its values to 0 in the range [initialIndex, initialIndex + N-1] int initialIndex = 2; vDSP_vclr((destination+initialIndex), 1, sourceLength); // We add source[0, N-1] into destination[initialIndex, initialIndex + N-1] vDSP_vadd(source, 1, (destination+initialIndex), 1, (destination+initialIndex), 1, sourceLength);
Or more concise you can also use 'cblas_scopy' as Brad Larson said
// Init source and destination // We copy source[0, sourceLength] into destination[initialIndex, initialIndex + sourceLength] cblas_scopy(sourceLength, source, 1, (destination+initialIndex), 1);
source share