Skip to content
Prev 256444 / 398506 Next

How do I make this faster?

On 04/11/2011 10:28 AM, Andreas Borg wrote:
In this piece of code you concatenate correlation and correlations.
Because you dynamically change correllations the operating system is
looking for a spot of memory for the object often. Preallocating the
space you need, or a bit is also fine, will make this much faster. You
can do this by not creating zero-length vectors for 'correlations' and
'vectors' before the start of the loop, but creating them already at the
desired length and assign values in the loop, not concatenate. This
could possibly speed up your codes by several orders of magnitude.

cheers,
Paul