Practice question · Multiple choice
In graphics, a pixel colour (r, g, b), a 3D position (x, y, z) and a weight vector in a neural network are all handled by the same vector code. Why does one implementation serve three unrelated meanings?
Hints
- Write the function that adds two vectors. Does it need to know what they mean?
- Would the same code work on a 512-component vector?
Show the answer
D. Because the operations depend only on the vector space axioms.
Why
Write the addition routine and it never asks what the components mean, it adds them, and the same holds for scaling and the dot product. It generalises across dimension too: 3 for a colour, 512 for a word embedding, 150,000 for a document vector. Which is why a framework computing cosine similarity is running the identical dot-product code a renderer uses for lighting.
Practise Vectors and Vector Spaces
The app has 8 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.