Expand description
Matrix multiplication and tensor contraction
use mdarray::tensor;
use mdarray_linalg::prelude::*;
use mdarray_linalg::Naive;
let a = tensor![[1., 2.], [3., 4.]].into_dyn(); // requires dynamic tensor
let b = tensor![[5., 6.], [7., 8.]].into_dyn();
let expected_all = tensor![[70.0]].into_dyn();
let result_all = Naive.contract_all(&a, &b).eval();
let result_contract_k = Naive.contract_n(&a, &b, 2).eval();
assert_eq!(result_contract_k, expected_all);
let expected_matmul = tensor![[19., 22.], [43., 50.]].into_dyn();
let result_specific = Naive
.contract(&a, &b, vec![1], vec![0])
.eval();
assert_eq!(result_specific, expected_matmul);Enums§
- Axes
- Side
- Specifies whether the left or right matrix has the special property
- Triangle
- Specifies whether a matrix is lower or upper triangular
- Type
- Identifies the structural type of a matrix (Hermitian, symmetric, or triangular)
Traits§
- Contract
Builder - Builder interface for configuring tensor contraction operations
- MatMul
- Matrix-matrix multiplication and related operations
- MatMul
Builder - Builder interface for configuring matrix-matrix operations
Functions§
- _contract
- Helper for implementing contraction through matrix multiplication