dot_product

Function dot_product 

Source
pub fn dot_product(a: &[f64], b: &[f64]) -> f64
Expand description

Calculate dot product between two vectors

Dot product is the raw similarity without normalization. It requires consistent vector scaling and can produce unbounded results.

§Arguments

  • a - First vector
  • b - Second vector (must have same length as a)

§Returns

Dot product value (unbounded range):

  • Positive values indicate similar direction
  • Zero indicates orthogonal vectors
  • Negative values indicate opposite direction

§Panics

Panics if vectors have different lengths.

§Examples

use vectorlite::dot_product;

let a = vec![1.0, 2.0, 3.0];
let b = vec![1.0, 2.0, 3.0];
let product = dot_product(&a, &b);
assert!((product - 14.0).abs() < 1e-10); // 1*1 + 2*2 + 3*3 = 14