Skip to main content

mat_mul_owned

Function mat_mul_owned 

Source
pub fn mat_mul_owned<T: BlasMul>(
    a: Matrix<T>,
    b: Matrix<T>,
) -> Result<Matrix<T>, MatrixMulError>
Expand description

Matrix multiplication: consume A and B, returning A * B.

Uses BLAS-backed einsum via tenferro. Compared with mat_mul, this reuses the input matrix buffers when building tenferro tensors.

§Errors

Returns an error when the operation fails (a shape or index mismatch, or /// a backend failure).

§Examples

use tensor4all_tensorbackend::{from_vec2d, mat_mul_owned};

let a = from_vec2d(vec![vec![1.0_f64, 2.0], vec![3.0, 4.0]]);
let b = from_vec2d(vec![vec![5.0, 6.0], vec![7.0, 8.0]]);
let c = mat_mul_owned(a, b).unwrap();
assert_eq!(c.as_col_major_slice(), &[19.0, 43.0, 22.0, 50.0]);