Skip to main content

Use this tag if your code contains vectorized operations - where functions operate on whole arrays in one go. If it doesn't, but you want it to, then you should make those changes (perhaps with help from elsewhere) before presenting code for review.

Vectorization refers to a programming paradigm where the process of loop-based, scalar-oriented code is instead written using matrix and vector operations. Vectorization has the following benefits:

  • Performance: Vectorized code has better performance regarding function calls and memory access, and as a result, often runs much faster than the corresponding code containing loops.

  • Appearance: Vectorized code appears more like the textbook mathematical expressions, making the code more comprehensible.

  • Less Error Prone: vectorized code is shorter than loop based code, hence there are fewer opportunities to introduce programming bugs.

Some programming languages, in particular MATLAB, are optimised to give the best performance when vectorized.