Next: , Previous: Linear Algebra, Up: Top


19 Vectorization and Faster Code Execution

Vectorization is a programming technique that uses vector operations instead of element-by-element loop-based operations. Besides frequently writing more succinct code, vectorization also allows for better optimization of the code. The optimizations may occur either in Octave's own Fortran, C, or C++ internal implementation, or even at a lower level depending on the compiler and external numerical libraries used to build Octave. The ultimate goal is to make use of your hardware's vector instructions if possible or to perform other optimizations in software.

Vectorization is not a concept unique to Octave, but is particularly important because Octave is a matrix-oriented language. Vectorized Octave code will see a dramatic speed up in most cases.

This chapter discusses vectorization and other techniques for faster code execution.