In this series of posts, I will try looking at different aspects of vectorization. We will start today with a scalar/vector/matrix notations, and try explaining what are the benefits and complications related to using such notations. I won’t be talking much about the performance or programming in the strict sense, but I will rather try explaining what is the problem in finding a fair notation. The mathematics presented here are simplified so that non-mathematicians could also follow the thought process without (too) much effort. Although the knowledge about real vector/matrix algebra might be of some use.
Vectorizing scalar equations
The vector term originates from mathematics. Say you have a group of equations, like:
All of the variables: are used in the equation of the same exact form:
In order to simplify the first notation, you can first group the variables at the same position in equations in a following way, forming vectors:
Now you can replace the original set of equations with a vector form (a cautious mathematician can now point that ‘‘ is not a correct vector operation symbol here, and that we should use instead. This is a part of the thought experiment. Please bear with me in this insanity for a while.):
An entity representing a singular value, such as is called a scalar. A list (or more precisely ‘an ordered-set’) of elements, such as is called a vector.
By vectorizing our equations, we replaced an unknown number of equations () of known number of variables (), with a known number of equations (1), and unknown number of packed variables().
The obvious gain we will get from having vector notation is the simplification of mathematical proofs. Instead of repeating each time that a certain property applies to equations for we can simply state that the property applies to all elements of . We still have more complicated definition of the types we manipulate, but we usually have to deal with that only in the beginning and possibly at the end of a proof.
Now imagine following set of equations:
If we apply our vector notation then we have:
And the re-written equations:
So we replaced a long set of equations, with a shorter set of equations. But again if we start performing proofs on such equations, we would end up repeating everything as in the first example.
We can also think about another way of representing the same set of equations. Instead of grouping all ‘s and all ‘s together, we could use following grouping:
Our second vector form becomes then:
While in this case we didn’t decrease the number of equations, we made each of them much simpler. As for the previous transformation, we could vectorize again and get yet simpler notation for the set of our equations. We will do that in a moment. But first we need to clarify something about ‘‘ symbol we’ve been using carelessly so far.
The continuation in: Vectorization #1: the difficulty of notation, part 2