Skip to main content

Observable

Struct Observable 

Source
pub struct Observable<R: RealField, const D: usize> { /* private fields */ }
Expand description

A named projector carrying its own read-out.

This is the measurement boundary of the verdict law: the only site at which a verdict enters a QCL pipeline. Every stage upstream carries operators; here a state meets a projection and a number comes out, through the shipped born_projective_probability, or a Prob through born_projective_prob. The observable folds no verdicts itself, because the fold rule depends on which kind of verdict a world carries; it exposes its Projection so that adjudicate can ask commutes_with of a pair before folding projection-valued verdicts.

Implementations§

Source§

impl<R, const D: usize> Observable<R, D>

Source

pub fn new(name: impl Into<String>, projection: Projection<R, D>) -> Self

A named observable over a validated projection.

Source

pub fn from_ket( name: impl Into<String>, ket: &CausalTensor<Complex<R>>, ) -> Result<Self, QuantumError>

The rank-1 observable |ψ⟩⟨ψ| of a ket, validated by the shipped Projection::from_ket.

§Errors

As Projection::from_ket: a ket of the wrong shape or dimension, or a near-zero ket.

Source

pub fn read_out(&self, plant: &QuantumPlant<R>) -> Result<R, QuantumError>

The Born probability Tr(Pρ) on the plant’s state, in [0, 1].

§Errors

QuantumError::DimensionMismatch naming both dimensions when the plant’s dim() differs from D, which is the error born_projective_probability already raises.

Source

pub fn read_out_prob( &self, plant: &QuantumPlant<R>, ) -> Result<Prob, QuantumError>
where R: Into<f64>,

The read-out as the Prob verdict, the boundary where the number becomes a classical proposition.

§Errors

As read_out.

Source

pub fn sample( &self, plant: &QuantumPlant<R>, shots: u64, seed: u64, ) -> Result<CountHistogram, QuantumError>

shots samples of the accepting outcome at seed, drawn from the Born probability this observable reads out. Outcome 1 is “accepted”, 0 is “rejected”.

§Errors

As read_out; nothing is drawn on the error path.

Source§

impl<R: RealField, const D: usize> Observable<R, D>

Source

pub fn name(&self) -> &str

The name.

Source

pub fn projection(&self) -> &Projection<R, D>

The projection, for adjudicate’s commutation guard.

Source

pub fn dim(&self) -> usize

Always D.

Trait Implementations§

Source§

impl<R: Clone + RealField, const D: usize> Clone for Observable<R, D>

Source§

fn clone(&self) -> Observable<R, D>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<R: Debug + RealField, const D: usize> Debug for Observable<R, D>

Source§

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

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

impl<R, const D: usize> Default for Observable<R, D>

The zero projection under an empty name, because the causal monad requires a Default for every value it carries.

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<R, const D: usize> Freeze for Observable<R, D>
where Projection<R, D>: Freeze,

§

impl<R, const D: usize> RefUnwindSafe for Observable<R, D>

§

impl<R, const D: usize> Send for Observable<R, D>
where Projection<R, D>: Send,

§

impl<R, const D: usize> Sync for Observable<R, D>
where Projection<R, D>: Sync,

§

impl<R, const D: usize> Unpin for Observable<R, D>
where Projection<R, D>: Unpin,

§

impl<R, const D: usize> UnsafeUnpin for Observable<R, D>
where Projection<R, D>: UnsafeUnpin,

§

impl<R, const D: usize> UnwindSafe for Observable<R, D>
where Projection<R, D>: 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
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
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
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<Borrowed> SampleBorrow<Borrowed> for Borrowed

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.