Skip to main content

TensorConstructionLike

Trait TensorConstructionLike 

Source
pub trait TensorConstructionLike: TensorContractionLike {
    // Required methods
    fn diagonal(
        input_index: &<Self as TensorIndex>::Index,
        output_index: &<Self as TensorIndex>::Index,
    ) -> Result<Self>;
    fn scalar_one() -> Result<Self>;
    fn ones(indices: &[<Self as TensorIndex>::Index]) -> Result<Self>;
    fn onehot(
        index_vals: &[(<Self as TensorIndex>::Index, usize)],
    ) -> Result<Self>;

    // Provided methods
    fn delta(
        input_indices: &[<Self as TensorIndex>::Index],
        output_indices: &[<Self as TensorIndex>::Index],
    ) -> Result<Self> { ... }
    fn select_indices(
        &self,
        selected_indices: &[<Self as TensorIndex>::Index],
        positions: &[usize],
    ) -> Result<Self> { ... }
}
Expand description

Constructors and selection helpers for index-labelled tensors.

Required Methods§

Source

fn diagonal( input_index: &<Self as TensorIndex>::Index, output_index: &<Self as TensorIndex>::Index, ) -> Result<Self>

Create a diagonal (Kronecker delta) tensor for a single index pair.

Source

fn scalar_one() -> Result<Self>

Create a scalar tensor with value 1.0.

Source

fn ones(indices: &[<Self as TensorIndex>::Index]) -> Result<Self>

Create a tensor filled with 1.0 for the given indices.

Source

fn onehot(index_vals: &[(<Self as TensorIndex>::Index, usize)]) -> Result<Self>

Create a one-hot tensor with value 1.0 at the specified index positions.

Provided Methods§

Source

fn delta( input_indices: &[<Self as TensorIndex>::Index], output_indices: &[<Self as TensorIndex>::Index], ) -> Result<Self>

Create a delta (identity) tensor as outer product of diagonals.

Source

fn select_indices( &self, selected_indices: &[<Self as TensorIndex>::Index], positions: &[usize], ) -> Result<Self>

Select fixed coordinates for a subset of this tensor’s external indices.

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§