pub struct UnfusedTensorInfo {
pub m: usize,
pub n: usize,
pub num_physical_dims: usize,
pub physical_dim: usize,
}Expand description
Information about the unfused tensor structure.
This helper provides metadata for reshaping the unfused tensors
produced by affine_transform_tensors_unfused.
§Examples
use tensor4all_quanticstransform::{AffineParams, UnfusedTensorInfo};
let params = AffineParams::from_integers(vec![1, 0, 0, 1], vec![0, 0], 2, 2).unwrap();
let info = UnfusedTensorInfo::new(¶ms);
assert_eq!(info.m, 2);
assert_eq!(info.n, 2);
assert_eq!(info.num_physical_dims, 4);
// Get shape for a tensor with bond dims 3 and 5
let shape = info.unfused_shape(3, 5);
assert_eq!(shape, vec![3, 2, 2, 2, 2, 5]);
// Round-trip encode/decode
let fused = info.encode_fused_index(&[1, 0], &[0, 1]);
let (y_bits, x_bits) = info.decode_fused_index(fused);
assert_eq!(y_bits, vec![1, 0]);
assert_eq!(x_bits, vec![0, 1]);Fields§
§m: usizeNumber of output variables (M)
n: usizeNumber of input variables (N)
num_physical_dims: usizeTotal physical dimensions per site (M + N)
physical_dim: usizeDimension of each physical index (always 2)
Implementations§
Source§impl UnfusedTensorInfo
impl UnfusedTensorInfo
Sourcepub fn new(params: &AffineParams) -> Self
pub fn new(params: &AffineParams) -> Self
Create info for the given affine parameters.
Sourcepub fn unfused_shape(&self, left_bond: usize, right_bond: usize) -> Vec<usize>
pub fn unfused_shape(&self, left_bond: usize, right_bond: usize) -> Vec<usize>
Get the shape for a fully unfused tensor at a given site.
Returns [left_bond, 2, 2, ..., 2, right_bond] where there are M+N 2s.
Trait Implementations§
Source§impl Clone for UnfusedTensorInfo
impl Clone for UnfusedTensorInfo
Source§fn clone(&self) -> UnfusedTensorInfo
fn clone(&self) -> UnfusedTensorInfo
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for UnfusedTensorInfo
impl RefUnwindSafe for UnfusedTensorInfo
impl Send for UnfusedTensorInfo
impl Sync for UnfusedTensorInfo
impl Unpin for UnfusedTensorInfo
impl UnsafeUnpin for UnfusedTensorInfo
impl UnwindSafe for UnfusedTensorInfo
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
Casts
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.