|
|
|
|
|
by taneq
3413 days ago
|
|
I had a similar 'aha' moment a few years ago about inner product (aka dot product) and the choice of '.' as an operator to access elements of a structure. struct Example {
int elem1;
int elem2;
...
};
Example ex1 = { 1, 2, ... };
int a = ex1.elem1;
int b = ex1.elem2;
...
If we think of ex1 as a vector, and elem1 as a constant vector [1, 0, 0...] (and elem2 as a constant vector [0, 1, 0, ...] and so on) then ex1.elem1 is literally the inner product of ex1 and the constant elem1.I have no idea if that was the original thinking behind dot notation but it's neat and I like it. |
|