Skip to main content

ChainCore

Trait ChainCore 

Source
pub trait ChainCore<T>: Sized {
    type Error: From<ChainCompressionError>;

    // Required methods
    fn view(&self) -> Result<ColMajorArrayRef<'_, T>, Self::Error>;
    fn from_col_major(
        shape: [usize; 3],
        data: Vec<T>,
    ) -> Result<Self, Self::Error>;
}
Expand description

Storage adapter that lets the chain sweeps read and rebuild rank-3 cores.

ColMajorArray implements it directly; other crates implement it for their own core types so that compress_chain_lu_mut and compress_chain_cores_mut can update them in place.

§Examples

use tensor4all_core::{ChainCore, ColMajorArray};
let core = <ColMajorArray<f64> as ChainCore<f64>>::from_col_major([1, 2, 1], vec![1.0, 2.0])?;
let view = ChainCore::<f64>::view(&core)?;
assert_eq!(view.shape(), &[1, 2, 1]);
assert_eq!(view.data(), &[1.0, 2.0]);

Required Associated Types§

Source

type Error: From<ChainCompressionError>

Error returned when reading or rebuilding a core, and by the sweeps.

Required Methods§

Source

fn view(&self) -> Result<ColMajorArrayRef<'_, T>, Self::Error>

Borrow the shape and flat data in column-major order.

§Errors

Returns the adapter’s error for noncompact or device-only storage, or a shape mismatch between the declared extents and borrowed data.

Source

fn from_col_major(shape: [usize; 3], data: Vec<T>) -> Result<Self, Self::Error>

Rebuild a core from column-major data.

§Errors

Returns the adapter’s error for a shape mismatch with the data length or a shape or stride overflow.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§