pub enum DefaultScalarsView<'a> {
F32(TypedTensorView<'a, f32, DynRank, Host>),
F64(TypedTensorView<'a, f64, DynRank, Host>),
I32(TypedTensorView<'a, i32, DynRank, Host>),
I64(TypedTensorView<'a, i64, DynRank, Host>),
Bool(TypedTensorView<'a, bool, DynRank, Host>),
C32(TypedTensorView<'a, Complex32, DynRank, Host>),
C64(TypedTensorView<'a, Complex64, DynRank, Host>),
}Expand description
Variants§
F32(TypedTensorView<'a, f32, DynRank, Host>)
F64(TypedTensorView<'a, f64, DynRank, Host>)
I32(TypedTensorView<'a, i32, DynRank, Host>)
I64(TypedTensorView<'a, i64, DynRank, Host>)
Bool(TypedTensorView<'a, bool, DynRank, Host>)
C32(TypedTensorView<'a, Complex32, DynRank, Host>)
C64(TypedTensorView<'a, Complex64, DynRank, Host>)
Implementations§
Source§impl<'a> DefaultScalarsView<'a>
impl<'a> DefaultScalarsView<'a>
Sourcepub fn dtype(&self) -> DType
pub fn dtype(&self) -> DType
Return this view’s dtype.
§Examples
use tenferro_tensor::{DefaultScalars, DType};
let tensor = DefaultScalars::from_vec_col_major(vec![1], vec![1.0_f32])?;
assert_eq!(tensor.as_view().dtype(), DType::F32);Sourcepub fn shape(&self) -> &[usize]
pub fn shape(&self) -> &[usize]
Borrow this view’s shape.
§Examples
use tenferro_tensor::DefaultScalars;
let tensor = DefaultScalars::from_vec_col_major(vec![1], vec![1.0_f64])?;
assert_eq!(tensor.as_view().shape(), &[1]);Sourcepub fn rank(&self) -> usize
pub fn rank(&self) -> usize
Return the view rank.
§Examples
use tenferro_tensor::DefaultScalars;
let tensor = DefaultScalars::from_vec_col_major(vec![1, 1], vec![1_i64])?;
assert_eq!(tensor.as_view().rank(), 2);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Return whether this view has zero logical elements.
§Examples
use tenferro_tensor::DefaultScalars;
let tensor = DefaultScalars::from_vec_col_major(vec![0], Vec::<f64>::new())?;
assert!(tensor.as_view().is_empty());Sourcepub fn reshape_view(&self, shape: impl AsRef<[usize]>) -> Result<Self>
pub fn reshape_view(&self, shape: impl AsRef<[usize]>) -> Result<Self>
Return a metadata-only reshape of this dynamic view.
§Examples
use tenferro_tensor::DefaultScalars;
let tensor = DefaultScalars::from_vec_col_major(vec![4], vec![1_i32, 2, 3, 4])?;
assert_eq!(tensor.as_view().reshape_view(vec![2, 2])?.shape(), &[2, 2]);§Errors
Returns a validation error carrying tenferro_tensor_core::ValidationError::ShapeMismatch
when the element counts differ,
tenferro_tensor_core::ValidationError::NonContiguousViewAsSlice when the view’s strides
cannot express the new shape, or tenferro_tensor_core::ValidationError::IntegerOverflow
when shape arithmetic overflows.
Sourcepub fn transpose_view(&self, axes: &[usize]) -> Result<Self>
pub fn transpose_view(&self, axes: &[usize]) -> Result<Self>
Return a metadata-only transposed dynamic view with axes in the requested order.
§Examples
use tenferro_tensor::DefaultScalars;
let tensor = DefaultScalars::from_vec_col_major(vec![1, 2], vec![1_i64, 2])?;
assert_eq!(tensor.as_view().transpose_view(&[1, 0])?.shape(), &[2, 1]);§Errors
Returns a validation error carrying
tenferro_tensor_core::ValidationError::InvalidPermutationLength,
tenferro_tensor_core::ValidationError::AxisOutOfBounds or
tenferro_tensor_core::ValidationError::DuplicateAxis when axes is not a permutation of
the view rank.
Sourcepub fn slice_view(&self, spec: &[StridedSliceSpec]) -> Result<Self>
pub fn slice_view(&self, spec: &[StridedSliceSpec]) -> Result<Self>
Return a metadata-only positive-step slice of this dynamic view.
§Examples
use tenferro_tensor::{DefaultScalars, StridedSliceSpec};
let tensor = DefaultScalars::from_vec_col_major(vec![3], vec![1_i64, 2, 3])?;
assert_eq!(
tensor.as_view().slice_view(&[StridedSliceSpec::new(1, Some(3), 1)])?.shape(),
&[2],
);§Errors
Returns crate::Error::Validation for a rank mismatch or invalid
slice bounds or step.
Trait Implementations§
Source§impl<'a> Clone for DefaultScalarsView<'a>
impl<'a> Clone for DefaultScalarsView<'a>
Source§fn clone(&self) -> DefaultScalarsView<'a>
fn clone(&self) -> DefaultScalarsView<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more