Trait MAdd

Source
pub trait MAdd<Rhs: Matrix>: Matrix
where Self::Output: Matrix,
{ type Output; // Required method fn add(self, rhs: Rhs) -> Self::Output; }

Required Associated Types§

Required Methods§

Source

fn add(self, rhs: Rhs) -> Self::Output

Adds two matrices of equal dimensions

A + B

§Arguments
  • rhs - The addend matrix
§Examples
let a = [
    [1.0, 2.0],
    [3.0, 4.0]
];
let b = [
    [4.0, 3.0],
    [2.0, 1.0]
];
let s = [
    [a[0][0] + b[0][0], a[0][1] + b[0][1]],
    [a[1][0] + b[1][0], a[1][1] + b[1][1]]
];
assert_eq!(a.add(b), s);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T1, T2, const H: usize, const L: usize> MAdd<[[T2; L]; H]> for [[T1; L]; H]
where Self: Matrix, [[T2; L]; H]: Matrix, [[<T1 as Add<T2>>::Output; L]; H]: Matrix, T1: Add<T2> + Clone, T2: Clone,

Source§

type Output = [[<T1 as Add<T2>>::Output; L]; H]

Source§

fn add(self, rhs: [[T2; L]; H]) -> Self::Output

Implementors§