Skip to main content

DensityMatrix5

Struct DensityMatrix5 

Source
pub struct DensityMatrix5 {
    pub entries: [Complex; 25],
}
Expand description

5x5 density matrix for the locomotion Hilbert space H_loc = C^5. Basis: |I>=Idle, |M>=Moving, |J>=Jumping, |L>=Landing, |S>=Sprinting.

Hermitian: rho_dag = rho (entries[i][j] = conj(entries[j][i])) Positive semidefinite: all eigenvalues >= 0 Trace 1: sum_k rho_kk = 1

This is the standard density matrix from quantum information theory. Diagonal entries are mode populations. Off-diagonal entries carry coherence.

Fields§

§entries: [Complex; 25]

Flat 5x5 complex entries. entries[i*5+j] = rho_{ij}.

Implementations§

Source§

impl DensityMatrix5

Source

pub fn pure_state(k: usize) -> Self

Pure state |k><k| — all population in mode k.

Source

pub fn from_state_vector(amplitudes: &[Complex; 5]) -> Self

Create from a state vector (5 complex amplitudes). rho = |psi><psi| where |psi> = sum alpha_k |k>

Source

pub fn trace(&self) -> f32

Trace: sum_k rho_kk

Source

pub fn populations(&self) -> [f32; 5]

Diagonal populations (mode probabilities).

Source

pub fn coherence_magnitude(&self) -> f32

Total off-diagonal coherence magnitude: sum_{i<j} |rho_{ij}|

Source

pub fn dephased(&self) -> Self

Completely dephase: zero all off-diagonals. rho -> Delta(rho).

Source

pub fn apply_dephasing(&mut self, epsilon: f32)

Partial dephasing channel: rho -> (1-eps)rho + eps*Delta(rho). eps in [0,1]. eps=0: no change. eps=1: full dephasing.

Source

pub fn apply_unitary(&mut self, u: &[Complex; 25])

Apply unitary evolution: rho -> U * rho * U_dag. U is a 5x5 complex matrix (flat, row-major).

Source

pub fn measure(&self, seed: u64) -> usize

Born rule measurement: p_k = rho_kk. Returns mode index sampled from probability distribution. Uses deterministic seed for reproducible gameplay.

Auto Trait Implementations§

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> 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, 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.