pub trait TensorElement:
TensorScalar
+ Copy
+ Send
+ Sync
+ 'static {
// Required methods
fn dense_native_tensor_from_col_major(
data: &[Self],
dims: &[usize],
) -> Result<NativeTensor>;
fn diag_native_tensor_from_col_major(
data: &[Self],
logical_rank: usize,
) -> Result<NativeTensor>;
fn scalar_native_tensor(value: Self) -> Result<NativeTensor>;
fn dense_values_from_native_col_major(
tensor: &NativeTensor,
) -> Result<Vec<Self>>;
fn diag_values_from_native_temp(tensor: &NativeTensor) -> Result<Vec<Self>>;
}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§
Sourcefn dense_native_tensor_from_col_major(
data: &[Self],
dims: &[usize],
) -> Result<NativeTensor>
fn dense_native_tensor_from_col_major( data: &[Self], dims: &[usize], ) -> Result<NativeTensor>
Build a dense native tensor from column-major data.
§Errors
Returns an error when the data length does not match the dimensions (a /// shape mismatch) or the backend conversion fails.
Sourcefn diag_native_tensor_from_col_major(
data: &[Self],
logical_rank: usize,
) -> Result<NativeTensor>
fn diag_native_tensor_from_col_major( data: &[Self], logical_rank: usize, ) -> Result<NativeTensor>
Build a diagonal native tensor from column-major diagonal payload data.
§Errors
Returns an error when the diagonal payload is incompatible (a shape /// mismatch) or the backend conversion fails.
Sourcefn scalar_native_tensor(value: Self) -> Result<NativeTensor>
fn scalar_native_tensor(value: Self) -> Result<NativeTensor>
Build a rank-0 native tensor.
§Errors
Returns an error when the scalar cannot be converted (a dtype mismatch or /// backend failure).
Sourcefn dense_values_from_native_col_major(
tensor: &NativeTensor,
) -> Result<Vec<Self>>
fn dense_values_from_native_col_major( tensor: &NativeTensor, ) -> Result<Vec<Self>>
Materialize dense column-major values from a native tensor.
§Errors
Returns an error when the native tensor cannot be materialized (a dtype /// mismatch or backend failure).
Sourcefn diag_values_from_native_temp(tensor: &NativeTensor) -> Result<Vec<Self>>
fn diag_values_from_native_temp(tensor: &NativeTensor) -> Result<Vec<Self>>
Materialize diagonal values from a dense native tensor.
§Errors
Returns an error when the native tensor cannot be materialized (a dtype /// mismatch or backend failure).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".