feat: enhance linear algebra operations (#2972)

- Add `dot()` for vector/matrix products
- Implement the `Frobenius` norm
- Add `mv()` for matrix-vector multiply
This commit is contained in:
飘尘
2025-05-29 15:41:01 +08:00
committed by GitHub
parent 1a183c988a
commit 5aed817f1b
3 changed files with 105 additions and 0 deletions

View File

@ -1880,3 +1880,11 @@ fn tensor_new() -> Result<()> {
);
Ok(())
}
#[test]
fn tensor_norm() -> Result<()> {
let t = Tensor::new(&[[3., 4.], [0., 0.]], &Device::Cpu)?;
let norm = t.norm()?;
assert_eq!(norm.to_scalar::<f64>()?, 5.);
Ok(())
}