Skip to main content

SumFromStorage

Trait SumFromStorage 

Source
pub trait SumFromStorage: Sized {
    // Required method
    fn sum_from_storage(storage: &Storage) -> Self;
}
Expand description

Types that can be computed as the result of a reduction over Storage.

This lets callers write let s: T = tensor.sum(); without matching on the storage variant. Implemented for f64 and Complex64.

§Examples

use tensor4all_tensorbackend::{Storage, SumFromStorage};

let s = Storage::from_dense_col_major(vec![1.0_f64, 2.0, 3.0], &[3]).unwrap();
let total: f64 = f64::sum_from_storage(&s);
assert!((total - 6.0).abs() < 1e-10);

Required Methods§

Source

fn sum_from_storage(storage: &Storage) -> Self

Compute the sum of all elements in the storage.

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 SumFromStorage for f64

Source§

fn sum_from_storage(storage: &Storage) -> Self

Source§

impl SumFromStorage for Complex64

Source§

fn sum_from_storage(storage: &Storage) -> Self

Implementors§