Introduction

This lesson gives a brief introduction to code vectorization and explains it with the help of an example.

Problem vectorization is much harder than code vectorization because it means that you fundamentally have to rethink your problem in order to make it vectorizable. Most of the time this means you have to use a different algorithm to solve your problem or even worse… to invent a new one. The difficulty is thus to think out-of-the-box.

To illustrate this, let’s consider a simple problem where given two vectors X and Y, we want to compute the sum of X[i]*Y[j] for all pairs of indices i, j.

One simple and obvious solution is given below.

Get hands-on with 1200+ tech skills courses.