Skip to main content

dot

Function dot 

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

§dot(a, b)

Mathematical vector operation

Calculates the dot product of two slices of f64.

§Panics

This function will panic if the lengths of the slices a and b are not equal, due to the assert_eq! check.

§Usage

The developer is responsible for ensuring that a and b are of the same length before calling this function. If there’s a possibility of different lengths, handle that case externally or use an alternative approach.

§Example

use mathlab::math::dot;
let a = vec![0.0, 1.0, 2.0, -1.0];
let b = vec![3.0, 4.0, 5.0, 5.0];
let result = dot(&a, &b);
println!("{}", result); // Outputs 9.0

/// End Fun Doc