learn-physics-0.6.0.0: Haskell code for learning physics

Physics.Learn.QuantumMat

Description

This module contains state vectors and matrices for quantum mechanics.

Synopsis

# State Vectors

The state resulting from a measurement of spin angular momentum in the x direction on a spin-1/2 particle when the result of the measurement is hbar/2.

The state resulting from a measurement of spin angular momentum in the x direction on a spin-1/2 particle when the result of the measurement is -hbar/2.

The state resulting from a measurement of spin angular momentum in the y direction on a spin-1/2 particle when the result of the measurement is hbar/2.

The state resulting from a measurement of spin angular momentum in the y direction on a spin-1/2 particle when the result of the measurement is -hbar/2.

The state resulting from a measurement of spin angular momentum in the z direction on a spin-1/2 particle when the result of the measurement is hbar/2.

The state resulting from a measurement of spin angular momentum in the z direction on a spin-1/2 particle when the result of the measurement is -hbar/2.

The state resulting from a measurement of spin angular momentum in the direction specified by spherical angles theta (polar angle) and phi (azimuthal angle) on a spin-1/2 particle when the result of the measurement is hbar/2.

The state resulting from a measurement of spin angular momentum in the direction specified by spherical angles theta (polar angle) and phi (azimuthal angle) on a spin-1/2 particle when the result of the measurement is -hbar/2.

Dimension of a vector.

Scale a complex vector by a complex number.

Complex inner product. First vector gets conjugated.

Length of a complex vector.

Return a normalized version of a given state vector.

Arguments

 :: Vector C state vector -> Vector Double vector of probabilities

Return a vector of probabilities for a given state vector.

gramSchmidt :: [Vector C] -> [Vector C] Source

Form an orthonormal list of complex vectors from a linearly independent list of complex vectors.

Conjugate the entries of a vector.

fromList :: [C] -> Vector C Source

Construct a vector from a list of complex numbers.

toList :: Vector C -> [C] Source

Produce a list of complex numbers from a vector.

# Matrices (operators)

The Pauli X matrix.

The Pauli Y matrix.

The Pauli Z matrix.

Scale a complex matrix by a complex number.

Matrix product.

Matrix-vector product.

Vector-matrix product

Conjugate transpose of a matrix.

fromLists :: [[C]] -> Matrix C Source

Construct a matrix from a list of lists of complex numbers.

toLists :: Matrix C -> [[C]] Source

Produce a list of lists of complex numbers from a matrix.

size :: Matrix C -> (Int, Int) Source

Size of a matrix.

# Density matrices

Complex outer product

Build a pure-state density matrix from a state vector.

Trace of a matrix.

Normalize a density matrix so that it has trace one.

The one-qubit totally mixed state.

# Quantum Dynamics

Given a time step and a Hamiltonian matrix, advance the state vector using the Schrodinger equation. This method should be faster than using `timeEvMat` since it solves a linear system rather than calculating an inverse matrix. The function assumes hbar = 1.

Given a time step and a Hamiltonian matrix, produce a unitary time evolution matrix. Unless you really need the time evolution matrix, it is better to use `timeEv`, which gives the same numerical results with doing an explicit matrix inversion. The function assumes hbar = 1.

# Measurement

The possible outcomes of a measurement of an observable. These are the eigenvalues of the matrix of the observable.

# Vector and Matrix

data Vector a :: * -> *

`Storable`-based vectors

Instances

 Normed Vector Double Normed Vector Float Storable a => Vector Vector a Normed Vector (Complex Double) Normed Vector (Complex Float) Source Source KnownNat m => Container Vector (Mod m I) KnownNat m => Container Vector (Mod m Z) Container Vector e => Build Int (e -> e) Vector e Storable a => IsList (Vector a) (Storable a, Eq a) => Eq (Vector a) (Data a, Storable a) => Data (Vector a) KnownNat m => Num (Vector (Mod m I)) KnownNat m => Num (Vector (Mod m Z)) (Storable a, Ord a) => Ord (Vector a) (Read a, Storable a) => Read (Vector a) (Show a, Storable a) => Show (Vector a) Storable a => Monoid (Vector a) NFData (Vector a) KnownNat m => Normed (Vector (Mod m I)) KnownNat m => Normed (Vector (Mod m Z)) Storable t => TransArray (Vector t) Storable a => Ixed (Vector a) Storable a => Wrapped (Vector a) (Storable a, (~) * t (Vector a')) => Rewrapped (Vector a) t Element t => Indexable (Matrix t) (Vector t) (Storable t, Indexable (Vector t) t) => Indexable (Vector (Mod m t)) (Mod m t) type IndexOf Vector = Int type Mutable Vector = MVector type ArgOf Vector a = a -> a type Item (Vector a) = a type ElementOf (Vector a) = a type Index (Vector a) = Int type IxValue (Vector a) = a type Unwrapped (Vector a) = [a] type TransRaw (Vector t) b = CInt -> Ptr t -> b type Trans (Vector t) b = CInt -> Ptr t -> b

data Matrix t :: * -> *

Matrix representation suitable for BLAS/LAPACK computations.

Instances

 Normed Matrix Double Normed Matrix Float (Num a, Element a, Container Vector a) => Container Matrix a Normed Matrix (Complex Double) Normed Matrix (Complex Float) Source (Num e, Container Vector e) => Konst e (Int, Int) Matrix (Storable t, NFData t) => NFData (Matrix t) KnownNat m => Testable (Matrix (Mod m I)) Storable t => TransArray (Matrix t) Element t => Indexable (Matrix t) (Vector t) (CTrans t, Container Vector t) => Transposable (Matrix t) (Matrix t) Container Matrix e => Build (Int, Int) (e -> e -> e) Matrix e type IndexOf Matrix = (Int, Int) type ArgOf Matrix a = a -> a -> a type ElementOf (Matrix a) = a type TransRaw (Matrix t) b = CInt -> CInt -> Ptr t -> b type Trans (Matrix t) b = CInt -> CInt -> CInt -> CInt -> Ptr t -> b