Skip to main content

Basis

Trait Basis 

Source
pub trait Basis: Send + Sync {
    type State: Copy + Eq + Send + Sync;

Show 14 methods // Required methods fn len(&self) -> usize; fn state(&self, index: usize) -> Result<Self::State>; fn index(&self, state: Self::State) -> Result<usize>; fn apply_local( &self, state: Self::State, operator: &str, sites: &[usize], ) -> Result<Option<(Self::State, Complex64)>>; // Provided methods fn apply_local_transitions( &self, state: Self::State, operator: &str, sites: &[usize], ) -> Result<LocalTransitions<Self::State>> { ... } fn apply_local_unreduced_transitions( &self, state: Self::State, operator: &str, sites: &[usize], ) -> Result<LocalTransitions<Self::State>> { ... } fn visit_local_unreduced_transitions<F>( &self, state: Self::State, operator: &str, sites: &[usize], visit: F, ) -> Result<()> where Self: Sized, F: FnMut(Self::State, Complex64) -> Result<()> { ... } fn transition_orbit_size(&self, _state: Self::State) -> Result<usize> { ... } fn reduction_image( &self, state: Self::State, ) -> Result<Option<ReductionImage<Self::State>>> { ... } fn reduce_transition( &self, state: Self::State, source_orbit_size: usize, ) -> Result<Option<(Self::State, Complex64)>> { ... } fn index_transition( &self, state: Self::State, source_orbit_size: usize, ) -> Result<Option<(usize, Complex64)>> { ... } fn operator_preserves_particle_sector( &self, _operator: &str, ) -> Result<bool> { ... } fn operator_preserves_particle_sector_on_sites( &self, operator: &str, _sites: &[usize], ) -> Result<bool> { ... } fn is_empty(&self) -> bool { ... }
}
Expand description

Finite Hilbert-space basis and its local operator semantics.

Required Associated Types§

Source

type State: Copy + Eq + Send + Sync

Integer-like state representation used by this basis.

Required Methods§

Source

fn len(&self) -> usize

Return the number of vectors in the basis.

Source

fn state(&self, index: usize) -> Result<Self::State>

Return the encoded state at a basis index.

Implementations return QmbedError::StateNotInBasis for an invalid row rather than panicking.

Source

fn index(&self, state: Self::State) -> Result<usize>

Locate an encoded state in the basis.

Source

fn apply_local( &self, state: Self::State, operator: &str, sites: &[usize], ) -> Result<Option<(Self::State, Complex64)>>

Apply one local operator string to one encoded state.

The result is None when the action is exactly zero. Bases whose actions branch override Basis::apply_local_transitions.

Provided Methods§

Source

fn apply_local_transitions( &self, state: Self::State, operator: &str, sites: &[usize], ) -> Result<LocalTransitions<Self::State>>

Applies a local operator and returns every nonzero destination.

Most spin-one-half, boson ladder, and fermion strings are deterministic, so the default implementation wraps Basis::apply_local. Higher-spin Cartesian operators and general user-defined local matrices can branch and override this method without changing the universal assembler.

Source

fn apply_local_unreduced_transitions( &self, state: Self::State, operator: &str, sites: &[usize], ) -> Result<LocalTransitions<Self::State>>

Local action before symmetry-sector reduction. Cross-sector builders use this path and let the target basis perform the reduction.

Source

fn visit_local_unreduced_transitions<F>( &self, state: Self::State, operator: &str, sites: &[usize], visit: F, ) -> Result<()>
where Self: Sized, F: FnMut(Self::State, Complex64) -> Result<()>,

Streams unreduced destinations directly to a consumer.

This is the universal hot-path interface used by assemblers. The default covers deterministic bases without constructing an intermediate collection; branching and symmetry-reduced bases override it while preserving the same consumer contract.

Source

fn transition_orbit_size(&self, _state: Self::State) -> Result<usize>

Orbit size of a canonical source state used in projector normalization.

Source

fn reduction_image( &self, state: Self::State, ) -> Result<Option<ReductionImage<Self::State>>>

Return the canonical reduction metadata for a physical state.

Explicit bases use a one-state orbit. Symmetry-reduced bases override this query without exposing their lookup-table representation.

Source

fn reduce_transition( &self, state: Self::State, source_orbit_size: usize, ) -> Result<Option<(Self::State, Complex64)>>

Map an unreduced physical target state into this basis.

Source

fn index_transition( &self, state: Self::State, source_orbit_size: usize, ) -> Result<Option<(usize, Complex64)>>

Reduces a physical target and locates its row in one operation.

Assemblers use this fused boundary to avoid looking up the same state once during reduction and again during indexing.

Source

fn operator_preserves_particle_sector(&self, _operator: &str) -> Result<bool>

Whether a local operator string preserves the particle-sector constraints represented by this basis. Unconstrained and custom bases accept every syntactically valid string by default.

Source

fn operator_preserves_particle_sector_on_sites( &self, operator: &str, _sites: &[usize], ) -> Result<bool>

Site-aware particle-sector check for bases whose local labels encode species as well as position.

Most bases depend only on the operator string and inherit this default. Multi-species bases may override it so a unified orbital convention remains physically meaningful without inserting a species separator.

Source

fn is_empty(&self) -> bool

Return whether the basis contains no vectors.

Implementors§

Source§

impl Basis for PackedBasis

Source§

impl Basis for WidePackedBasis

Source§

impl Basis for BosonBasis1D

Source§

impl Basis for PackedPhotonBasis

Source§

impl Basis for PackedTensorBasis

Source§

impl Basis for SpinBasis1D

Source§

impl Basis for SpinfulFermionBasis1D

Source§

impl Basis for SpinlessFermionBasis1D

Source§

impl<Left, Right> Basis for TensorBasis<Left, Right>
where Left: Basis, Right: Basis, Left::State: 'static, Right::State: 'static,

Source§

type State = (<Left as Basis>::State, <Right as Basis>::State)

Source§

impl<Matter> Basis for PhotonBasis<Matter>
where Matter: Basis, Matter::State: Hash + 'static,

Source§

type State = (<Matter as Basis>::State, u128)

Source§

impl<Parent> Basis for GeneralBasis<Parent>
where Parent: Basis, Parent::State: Hash + Ord + 'static,

Source§

type State = <Parent as Basis>::State

Source§

impl<State> Basis for UserBasis<State>
where State: Copy + Eq + Hash + Send + Sync + 'static,

Source§

type State = State

Source§

impl<const WORDS: usize> Basis for WideSpinBasis<WORDS>

Source§

type State = WideState<WORDS>