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§
Required Methods§
Sourcefn state(&self, index: usize) -> Result<Self::State>
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.
Sourcefn apply_local(
&self,
state: Self::State,
operator: &str,
sites: &[usize],
) -> Result<Option<(Self::State, Complex64)>>
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§
Sourcefn apply_local_transitions(
&self,
state: Self::State,
operator: &str,
sites: &[usize],
) -> Result<LocalTransitions<Self::State>>
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.
Sourcefn apply_local_unreduced_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>>
Local action before symmetry-sector reduction. Cross-sector builders use this path and let the target basis perform the reduction.
Sourcefn visit_local_unreduced_transitions<F>(
&self,
state: Self::State,
operator: &str,
sites: &[usize],
visit: F,
) -> Result<()>
fn visit_local_unreduced_transitions<F>( &self, state: Self::State, operator: &str, sites: &[usize], visit: F, ) -> 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.
Sourcefn transition_orbit_size(&self, _state: Self::State) -> Result<usize>
fn transition_orbit_size(&self, _state: Self::State) -> Result<usize>
Orbit size of a canonical source state used in projector normalization.
Sourcefn reduction_image(
&self,
state: Self::State,
) -> Result<Option<ReductionImage<Self::State>>>
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.
Sourcefn reduce_transition(
&self,
state: Self::State,
source_orbit_size: usize,
) -> Result<Option<(Self::State, Complex64)>>
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.
Sourcefn index_transition(
&self,
state: Self::State,
source_orbit_size: usize,
) -> Result<Option<(usize, Complex64)>>
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.
Sourcefn operator_preserves_particle_sector(&self, _operator: &str) -> Result<bool>
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.
Sourcefn operator_preserves_particle_sector_on_sites(
&self,
operator: &str,
_sites: &[usize],
) -> Result<bool>
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.