Question

In the vDSP functions of the Accelerate Framework, all the functions require you to input a result vector. Is it correct to pass the input vector (or one of the input vectors) as the result vector if I no longer need whatever was in the original input vector?

Example of what I mean:

vDSP_vsadd(input_vector,1,scalar_addition,input_vector,1,length);

This would take the input_vector and add a scalar_addition to all the elements. The result would be stored in the input_vector.

Was it helpful?

Solution

The simple vector operations in vDSP all work correctly in-place (so long as they are strictly in-place; for instance you can't use &input_vector[length/2] for output and expect to get meaningful results). In fact, using them in-place will often give better performance, as it can reduce cache pressure.

Some of the more complicated vDSP operations do not support in-place operation with one or more of their arguments; this should be called out in the vDSP reference guide.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top