Skip to main content

TTScalar

Trait TTScalar 

Source
pub trait TTScalar:
    CommonScalar
    + TfScalar
    + TensorScalar { }
Expand description

Scalar trait bound shared by all simplett tensor types.

Combines [tensor4all_core::CommonScalar] (arithmetic, conversion) with [tenferro_algebra::Scalar] (backend compatibility). Both f64 and Complex64 implement this trait.

§Examples

use tensor4all_simplett::TTScalar;

// f64 satisfies TTScalar
fn uses_ttscalar<T: TTScalar>(x: T, y: T) -> T { x + y }

let result = uses_ttscalar(1.0_f64, 2.0_f64);
assert!((result - 3.0).abs() < 1e-15);

// Complex64 also satisfies TTScalar
use num_complex::Complex64;
let c = uses_ttscalar(Complex64::new(1.0, 0.0), Complex64::new(0.0, 1.0));
assert!((c.re - 1.0).abs() < 1e-15);
assert!((c.im - 1.0).abs() < 1e-15);

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.

Implementors§

Source§

impl<T> TTScalar for T
where T: CommonScalar + TfScalar + TensorScalar,