dotProduct static method
Computes the dot product (scalar product) of two vectors.
The dot product measures how much two vectors "align" with each other.
For vectors a and b: dot(a,b) = sum(a[i] * b[i])
for all dimensions i.
This is a key component in cosine similarity calculation.
Implementation
static double dotProduct(Float64List a, Float64List b) {
assert(a.length == b.length);
// Sum the element-wise products across all dimensions
var sum = 0.0;
for (var i = 0; i < a.length; ++i) {
sum += a[i] * b[i];
}
return sum;
}