einsum_binary

Function einsum_binary 

Source
pub fn einsum_binary<Alg, Backend>(
    ctx: &mut BackendContext<Alg, Backend>,
    subscripts: &str,
    left: &Tensor<Alg::Scalar>,
    right: &Tensor<Alg::Scalar>,
    size_dict: Option<&HashMap<u32, usize>>,
) -> Result<Tensor<Alg::Scalar>>
where Alg: Semiring, Alg::Scalar: Scalar + Conjugate + HasAlgebra<Algebra = Alg>, Backend: EinsumBackend<Alg>, BackendContext<Alg, Backend>: TensorTempPoolContext,
Expand description

Execute a binary einsum from string notation.

This is the two-input specialization of crate::einsum. It is intended as a reusable primitive for building explicit contraction paths at higher layers.

§Examples

use tenferro_algebra::Standard;
use tenferro_einsum::einsum_binary;
use tenferro_tensor::{MemoryOrder, Tensor};
use tenferro_prims::{CpuBackend, CpuContext};

let mut ctx = CpuContext::new(1);
let col = MemoryOrder::ColumnMajor;
let a = Tensor::<f64>::from_slice(&[1.0, 2.0, 3.0, 4.0], &[2, 2], col).unwrap();
let b = Tensor::<f64>::from_slice(&[5.0, 6.0, 7.0, 8.0], &[2, 2], col).unwrap();
let c =
    einsum_binary::<Standard<f64>, CpuBackend>(&mut ctx, "ij,jk->ik", &a, &b, None).unwrap();