Hello,
I could not find a BLAS-1 function that would fit this bill and was wondering whether MKL has a function implementation for this. I know stl or boost has i.e. fill but I prefer one impl. that takes into account locality and parallelizes.
I create a column vector and want to initialize it to a given double value. memset only works for zeroing out the memory but AFAIK it boils down to doing a not so efficient loop.
Below my C code (pending moving to C++), is there a way to do this in a more locality/vectorized/parallel high performance way using MKL?
Many thanks in advance,
Best regards,
Giovanni
/**
* Initialize a vector with a default value
*/
tvector* vector_init_with_default(int capacity, double value) {
tvector* result = vector_init_static(capacity);
for (int i = 0; i < capacity; ++i) {
result->data = value;
}
return result;
}
Link Copied
For more complete information about compiler optimizations, see our Optimization Notice.