Skip to content

Commit 298121d

Browse files
committed
test: Add vector_dot test
1 parent 9fc565b commit 298121d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/math.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,15 @@ mod tests {
418418
assert_approx_eq(out1, out2);
419419
}
420420
}
421+
422+
#[test]
423+
fn test_vector_dot((x, y) in array2(10)) {
424+
let actual = vector_dot(&x[..], &y[..]);
425+
let x = ndarray::Array1::from_vec(x);
426+
let y = ndarray::Array1::from_vec(y);
427+
let expected = x.iter().zip(y.iter()).map(|(&x, &y)| x * y).sum();
428+
assert_approx_eq(actual, expected);
429+
}
421430
}
422431

423432
#[test]

0 commit comments

Comments
 (0)