Index

Struct Index 

Source
pub struct Index<Id, Tags = TagSet> {
    pub id: Id,
    pub dim: usize,
    pub plev: i64,
    pub tags: Tags,
}
Expand description

Index with generic identity type Id and tag type Tags.

  • Id = DynId for ITensors-like runtime identity
  • Id = ZST marker type for compile-time-known identity
  • Tags = TagSet for tags (default, Arc-wrapped for cheap cloning)

Note: This default implementation does not include symmetry (quantum numbers). For QSpace-compatible indices with non-Abelian symmetries, use a separate concrete type.

§Memory Layout

With default types (DynId, TagSet):

  • Size: 32 bytes (8 + 8 + 8 + 8)
  • Tags are shared via Arc, so cloning is cheap (reference count increment only)

Equality: Two Index values are considered equal if and only if their id and tags fields and plev match (matching ITensors.jl semantics where equality = id + plev + tags).

§Example

use tensor4all_core::index::{Index, DynId, TagSet};

// Create shared tags once
let site_tags = TagSet::from_str("Site").unwrap();

// Share the same tags across many indices (cheap clone)
let i1 = Index::<DynId>::new_dyn_with_tags(2, site_tags.clone());
let i2 = Index::<DynId>::new_dyn_with_tags(2, site_tags.clone());
// i1.tags and i2.tags point to the same Arc

Fields§

§id: Id

The unique identifier for this index.

§dim: usize

The dimension (size) of this index.

§plev: i64

The prime level of this index.

§tags: Tags

The tag set associated with this index.

Implementations§

Source§

impl<Id, Tags> Index<Id, Tags>
where Tags: Default,

Source

pub fn new(id: Id, dim: usize) -> Self

Create a new index with the given identity and dimension.

Source

pub fn new_with_tags(id: Id, dim: usize, tags: Tags) -> Self

Create a new index with the given identity, dimension, and tags.

Source

pub fn size(&self) -> usize

Get the dimension (size) of the index.

Source

pub fn tags(&self) -> &Tags

Get a reference to the tags.

Source§

impl<Id, Tags> Index<Id, Tags>
where Tags: Default,

Source

pub fn new_with_size(id: Id, size: usize) -> Self

Create a new index from dimension (convenience constructor).

Source

pub fn new_with_size_and_tags(id: Id, size: usize, tags: Tags) -> Self

Create a new index from dimension and tags.

Source§

impl Index<DynId, TagSet>

Source

pub fn new_dyn(size: usize) -> Self

Create a new index with a generated dynamic ID and no tags.

Source

pub fn new_dyn_with_tags(size: usize, tags: TagSet) -> Self

Create a new index with a generated dynamic ID and shared tags.

This is the most efficient way to create many indices with the same tags. The Arc is cloned (reference count increment only), not the underlying data.

§Example
use tensor4all_core::index::{Index, DynId, TagSet};

let site_tags = TagSet::from_str("Site").unwrap();
let i1 = Index::<DynId>::new_dyn_with_tags(2, site_tags.clone());
let i2 = Index::<DynId>::new_dyn_with_tags(2, site_tags.clone());
Source

pub fn new_dyn_with_tag(size: usize, tag: &str) -> Result<Self, TagSetError>

Create a new index with a generated dynamic ID and a single tag.

This creates a new TagSet with the given tag. For sharing the same tag across many indices, create the TagSet once and use new_dyn_with_tags instead.

Create a new bond index with “Link” tag (for SVD, QR, etc.).

This is a convenience method for creating bond indices commonly used in tensor decompositions like SVD and QR factorization.

Source§

impl Index<DynId>

Source

pub fn new_bond(dim: usize) -> Result<Self>

Create a new bond index with a fresh identity and the specified dimension.

This is used by factorization operations (SVD, QR) to create new internal bond indices connecting the factors.

§Arguments
  • dim - The dimension of the new index
§Returns

A new index with a unique identity and the specified dimension.

Source

pub fn prime(&self) -> Self

Return a copy of this index with its prime level incremented by one.

Source

pub fn noprime(&self) -> Self

Return a copy of this index with its prime level reset to zero.

Source

pub fn set_plev(&self, plev: i64) -> Self

Return a copy of this index with its prime level set explicitly.

Trait Implementations§

Source§

impl<Id: Clone, Tags: Clone> Clone for Index<Id, Tags>

Source§

fn clone(&self) -> Index<Id, Tags>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Id: Debug, Tags: Debug> Debug for Index<Id, Tags>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Id: Hash, Tags: Hash> Hash for Index<Id, Tags>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Id: PartialEq, Tags: PartialEq> PartialEq for Index<Id, Tags>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Id: Copy, Tags: Copy> Copy for Index<Id, Tags>

Source§

impl<Id: Eq, Tags: Eq> Eq for Index<Id, Tags>

Auto Trait Implementations§

§

impl<Id, Tags> Freeze for Index<Id, Tags>
where Id: Freeze, Tags: Freeze,

§

impl<Id, Tags> RefUnwindSafe for Index<Id, Tags>
where Id: RefUnwindSafe, Tags: RefUnwindSafe,

§

impl<Id, Tags> Send for Index<Id, Tags>
where Id: Send, Tags: Send,

§

impl<Id, Tags> Sync for Index<Id, Tags>
where Id: Sync, Tags: Sync,

§

impl<Id, Tags> Unpin for Index<Id, Tags>
where Id: Unpin, Tags: Unpin,

§

impl<Id, Tags> UnwindSafe for Index<Id, Tags>
where Id: UnwindSafe, Tags: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<U> As for U

§

fn as_<T>(self) -> T
where 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 more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> DistributionExt for T
where T: ?Sized,

§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

§

impl<T> DistributionExt for T
where T: ?Sized,

§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Boilerplate for T
where T: Copy + Send + Sync + Debug + PartialEq + 'static,

§

impl<T> Boilerplate for T
where T: Copy + Send + Sync + Debug + PartialEq + 'static,

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

§

impl<T> MaybeSend for T

§

impl<T> MaybeSendSync for T

§

impl<T> MaybeSync for T