Skip to main content

TensorElement

Trait TensorElement 

Source
pub trait TensorElement:
    TensorScalar
    + Copy
    + Send
    + Sync
    + 'static {
    // Required methods
    fn dense_native_tensor_from_col_major(
        data: &[Self],
        dims: &[usize],
    ) -> Result<Tensor, Error>;
    fn diag_native_tensor_from_col_major(
        data: &[Self],
        logical_rank: usize,
    ) -> Result<Tensor, Error>;
    fn scalar_native_tensor(value: Self) -> Result<Tensor, Error>;
    fn dense_values_from_native_col_major(
        tensor: &Tensor,
    ) -> Result<Vec<Self>, Error>;
    fn diag_values_from_native_temp(tensor: &Tensor) -> Result<Vec<Self>, Error>;
}
Expand description

Public scalar element types supported by tensor4all dense/diag constructors.

Implemented for f32, f64, Complex32, and Complex64.

§Examples

use tensor4all_tensorbackend::TensorElement;

let t = f64::dense_native_tensor_from_col_major(&[1.0, 2.0], &[2]).unwrap();
assert_eq!(t.shape(), &[2]);

let vals = f64::dense_values_from_native_col_major(&t).unwrap();
assert_eq!(vals, vec![1.0, 2.0]);

Required Methods§

Source

fn dense_native_tensor_from_col_major( data: &[Self], dims: &[usize], ) -> Result<Tensor, Error>

Build a dense native tensor from column-major data.

Source

fn diag_native_tensor_from_col_major( data: &[Self], logical_rank: usize, ) -> Result<Tensor, Error>

Build a diagonal native tensor from column-major diagonal payload data.

Source

fn scalar_native_tensor(value: Self) -> Result<Tensor, Error>

Build a rank-0 native tensor.

Source

fn dense_values_from_native_col_major( tensor: &Tensor, ) -> Result<Vec<Self>, Error>

Materialize dense column-major values from a native tensor.

Source

fn diag_values_from_native_temp(tensor: &Tensor) -> Result<Vec<Self>, Error>

Materialize diagonal values from a dense native tensor.

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 TensorElement for f32

Source§

impl TensorElement for f64

Source§

impl TensorElement for Complex<f32>

Source§

impl TensorElement for Complex<f64>

Implementors§