Skip to main content

dot

Macro dot 

Source
macro_rules! dot {
    ($a:expr, $b:expr $(,)?) => { ... };
    ($a:expr, $b:expr, $($c:expr),+ $(,)?) => { ... };
}
Expand description

Allocate a direct contraction of the last axis of a with the first of b.

Uses the same rank-dependent storage as rlst_dynamic_array! and dot_into! for multiplication. Arguments are evaluated and borrowed once. The output concatenates the remaining input axes, with a ZeroDimArray of shape [] for two vectors; multiplication does not conjugate either input.

Stable Rust requires the independent output rank to be inferred from context, for example an explicit DynArray<_, R> or ZeroDimArray<_> annotation. There is no rank cap.

For general dense matrices, dot_blas! is significantly faster than dot! and is the recommended choice for matrix multiplication. Sparse matrices and abstract operators retain their existing .dot() behavior. With the mpi feature, distributed CSR matrices accept distributed vectors and matrices collectively, returning owned local storage on the range layout. Their multi-operand products are evaluated from right to left. For dense contractions, use two operands and explicitly type intermediate results; dot_blas! also supports chains of dense matrix products.

ยงPanics

Panics for zero input ranks, incompatible contracted dimensions or output rank, or overflowing shape-size arithmetic, before allocating the output.

let a = rlst::rlst_dynamic_array!(f64, [2, 3, 4]);
let b = rlst::rlst_dynamic_array!(f64, [4, 5]);
let c: rlst::DynArray<f64, 3> = rlst::dot!(a.r(), b.r());
assert_eq!(c.shape(), [2, 3, 5]);