Skip to main content

vec_add

Function vec_add 

Source
pub fn vec_add(v1: &[f64], v2: &[f64]) -> Result<Vec<f64>, String>
Expand description

Adds two vectors element-wise.

Formula: $\mathbf{r}_i = \mathbf{v1}_i + \mathbf{v2}_i$

§Arguments

  • v1 - The first vector.
  • v2 - The second vector.

§Returns

  • Ok(Vec<f64>) - The sum of the two vectors.

§Errors

Returns an error if the vectors have different lengths.