Skip to main content

Vectorization refers to a programming paradigm where functions operate on whole arrays in one go. This affords benefits in terms of function calls, memory access, parallelization and code expressiveness. Some programming languages, such as MATLAB, are optimised to give the best performance when vectorized.

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.