← Lectures·L4

Vectors, Matrices, and Convolutions

Prof. Dr. Alessandro Del Vecchio · 7 concepts · 5 questions

Concept 1 / 7

Vectors — A List of Numbers

A vector is a 1D np.ndarray — the simplest multi-element data structure in NumPy. The same concept appears across radically different domains:


DomainVector contentsExample shape
Tabular data (one patient)(age, height, weight, BMI)(4,)
Image pixel (colour)(R, G, B)(3,)
LLM embedding1536 semantic dimensions(1536,)
EMG feature(RMS, ARV, mean_freq) per window(3,)

NumPy is natively vectorised — all basic operations work element-wise without Python loops:


import numpy as np
u = np.array([1.0, 2.0, 3.0])
v = np.array([4.0, 5.0, 6.0])

print(u + v)       # [5. 7. 9.]  — element-wise addition
print(2.5 * u)     # [2.5 5.  7.5]  — scalar scaling

Writing explicit Python for loops over NumPy arrays is almost always slower and unnecessary — embrace vectorised operations.