pub trait TensorConstructionLike: TensorContractionLike {
// Required methods
fn diagonal(
input_index: &<Self as TensorIndex>::Index,
output_index: &<Self as TensorIndex>::Index,
) -> Result<Self, Self::Error>;
fn scalar_one() -> Result<Self, Self::Error>;
fn ones(
indices: &[<Self as TensorIndex>::Index],
) -> Result<Self, Self::Error>;
fn onehot(
index_vals: &[(<Self as TensorIndex>::Index, usize)],
) -> Result<Self, Self::Error>;
// Provided methods
fn delta(
input_indices: &[<Self as TensorIndex>::Index],
output_indices: &[<Self as TensorIndex>::Index],
) -> Result<Self, Self::Error> { ... }
fn select_indices(
&self,
selected_indices: &[<Self as TensorIndex>::Index],
positions: &[usize],
) -> Result<Self, Self::Error> { ... }
}Expand description
Constructors and selection helpers for index-labelled tensors.
Required Methods§
Sourcefn diagonal(
input_index: &<Self as TensorIndex>::Index,
output_index: &<Self as TensorIndex>::Index,
) -> Result<Self, Self::Error>
fn diagonal( input_index: &<Self as TensorIndex>::Index, output_index: &<Self as TensorIndex>::Index, ) -> Result<Self, Self::Error>
Create a diagonal (Kronecker delta) tensor for a single index pair.
§Errors
Returns Self::Error when the input and output indices have unequal
dimensions (a shape mismatch) or the underlying construction
reports a failure.
Sourcefn scalar_one() -> Result<Self, Self::Error>
fn scalar_one() -> Result<Self, Self::Error>
Create a scalar tensor with value 1.0.
§Errors
Returns Self::Error when the scalar type does not support the
required construction (an invalid scalar dtype or a backend
construction failure).
Sourcefn ones(indices: &[<Self as TensorIndex>::Index]) -> Result<Self, Self::Error>
fn ones(indices: &[<Self as TensorIndex>::Index]) -> Result<Self, Self::Error>
Create a tensor filled with 1.0 for the given indices.
§Errors
Returns Self::Error when an index dimension product overflows (an
overflow failure) or the underlying construction reports a failure.
Sourcefn onehot(
index_vals: &[(<Self as TensorIndex>::Index, usize)],
) -> Result<Self, Self::Error>
fn onehot( index_vals: &[(<Self as TensorIndex>::Index, usize)], ) -> Result<Self, Self::Error>
Create a one-hot tensor with value 1.0 at the specified index positions.
§Errors
Returns Self::Error when a position is out of range for its index
(an out of bounds failure) or the underlying construction reports a
failure.
Provided Methods§
Sourcefn delta(
input_indices: &[<Self as TensorIndex>::Index],
output_indices: &[<Self as TensorIndex>::Index],
) -> Result<Self, Self::Error>
fn delta( input_indices: &[<Self as TensorIndex>::Index], output_indices: &[<Self as TensorIndex>::Index], ) -> Result<Self, Self::Error>
Create a delta (identity) tensor as outer product of diagonals.
§Errors
Returns Self::Error when the input and output index lists differ in
length (a length mismatch) or when a constituent diagonal or outer
product reports a failure; propagates failures from Self::diagonal,
Self::scalar_one, and [Self::outer_product].
Sourcefn select_indices(
&self,
selected_indices: &[<Self as TensorIndex>::Index],
positions: &[usize],
) -> Result<Self, Self::Error>
fn select_indices( &self, selected_indices: &[<Self as TensorIndex>::Index], positions: &[usize], ) -> Result<Self, Self::Error>
Select fixed coordinates for a subset of this tensor’s external indices.
§Errors
Returns Self::Error when selected_indices and positions differ in
length (a length mismatch), when an index is selected more than once
(a duplicate-index failure), when a coordinate is out of range (an
out of bounds failure), or when the underlying one-hot construction or
contraction reports a failure; propagates failures from
Self::onehot and [Self::contract].
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".