Liking cljdoc? Tell your friends :D

org.soulspace.qclojure.domain.observables

Domain for quantum observables - Hermitian operators representing measurable quantities.

Observables in quantum mechanics are represented by Hermitian matrices. This namespace provides functions for creating and manipulating observables, calculating expectation values, and working with composite observables.

Design Philosophy:

  • Observables are simple data (matrices) - no complex wrapping
  • Pure functions for all operations
  • Compose complex observables from simple primitives
  • Separate representation, computation, and measurement concerns
Domain for quantum observables - Hermitian operators representing measurable quantities.

Observables in quantum mechanics are represented by Hermitian matrices.
This namespace provides functions for creating and manipulating observables,
calculating expectation values, and working with composite observables.

Design Philosophy:
- Observables are simple data (matrices) - no complex wrapping
- Pure functions for all operations
- Compose complex observables from simple primitives
- Separate representation, computation, and measurement concerns
raw docstring

expectation-valueclj

(expectation-value observable quantum-state)

Calculate expectation value ⟨ψ|O|ψ⟩ of observable O in state ψ

Parameters:

  • observable: Hermitian matrix representing the observable
  • quantum-state: quantum state vector (normalized)

Returns: Real number representing the expectation value

Example: (expectation-value pauli-z |0⟩) ; returns 1.0

Calculate expectation value ⟨ψ|O|ψ⟩ of observable O in state ψ

Parameters:
- observable: Hermitian matrix representing the observable
- quantum-state: quantum state vector (normalized)

Returns:
  Real number representing the expectation value

Example:
  (expectation-value pauli-z |0⟩) ; returns 1.0
sourceraw docstring

hermitian-conjugateclj

(hermitian-conjugate matrix)

Compute Hermitian conjugate (complex conjugate transpose) of matrix

Compute Hermitian conjugate (complex conjugate transpose) of matrix
sourceraw docstring

identity-opclj

Identity observable (I)

Identity observable (I)
sourceraw docstring

is-hermitian?clj

(is-hermitian? matrix)

Check if a matrix is Hermitian (O = O†)

Parameters:

  • matrix: matrix to check

Returns: Boolean indicating if matrix is Hermitian

Check if a matrix is Hermitian (O = O†)

Parameters:
- matrix: matrix to check

Returns:
  Boolean indicating if matrix is Hermitian
sourceraw docstring

linear-combinationclj

(linear-combination coeffs-observables)

Create a linear combination of observables: Σᵢ cᵢ Oᵢ

Parameters:

  • coeffs-observables: sequence of [coefficient observable] pairs

Returns: Matrix representing the linear combination

Example: (linear-combination [[0.5 pauli-x] [0.5 pauli-z]])

Create a linear combination of observables: Σᵢ cᵢ Oᵢ

Parameters:
- coeffs-observables: sequence of [coefficient observable] pairs

Returns:
  Matrix representing the linear combination

Example:
  (linear-combination [[0.5 pauli-x] [0.5 pauli-z]])
sourceraw docstring

matrix-addclj

(matrix-add m1 m2)

Add two matrices element-wise

Add two matrices element-wise
sourceraw docstring

matrix-equal?clj

(matrix-equal? m1 m2)

Check if two matrices are equal within tolerance

Check if two matrices are equal within tolerance
sourceraw docstring

matrix-multclj

(matrix-mult m1 m2)

Multiply two matrices

Multiply two matrices
sourceraw docstring

matrix-scalar-multclj

(matrix-scalar-mult scalar matrix)

Multiply matrix by scalar

Multiply matrix by scalar
sourceraw docstring

measurement-probabilitiesclj

(measurement-probabilities observable quantum-state)

Calculate measurement probabilities for an observable's eigenvalues

For a two-level system observable, returns probabilities for +1 and -1 eigenvalues. This is a simplified version - full implementation would require eigendecomposition.

Parameters:

  • observable: Hermitian matrix (currently supports Pauli observables)
  • quantum-state: quantum state vector

Returns: Map with keys representing eigenvalues and values representing probabilities

Calculate measurement probabilities for an observable's eigenvalues

For a two-level system observable, returns probabilities for +1 and -1 eigenvalues.
This is a simplified version - full implementation would require eigendecomposition.

Parameters:
- observable: Hermitian matrix (currently supports Pauli observables)
- quantum-state: quantum state vector

Returns:
  Map with keys representing eigenvalues and values representing probabilities
sourceraw docstring

pauli-char->matrixclj

(pauli-char->matrix pauli-char)

Convert a single Pauli character to its matrix representation

Convert a single Pauli character to its matrix representation
sourceraw docstring

pauli-string->observableclj

(pauli-string->observable pauli-str)

Convert a Pauli string to an observable matrix

Parameters:

  • pauli-str: string like 'XZYI' representing multi-qubit Pauli operator

Returns: Matrix representing the tensor product of Pauli matrices

Example: (pauli-string->observable 'XZ') ; creates X ⊗ Z

Convert a Pauli string to an observable matrix

Parameters:
- pauli-str: string like 'XZYI' representing multi-qubit Pauli operator

Returns:
  Matrix representing the tensor product of Pauli matrices

Example:
  (pauli-string->observable 'XZ') ; creates X ⊗ Z
sourceraw docstring

pauli-xclj

Pauli-X observable (σₓ)

Pauli-X observable (σₓ)
sourceraw docstring

pauli-yclj

Pauli-Y observable (σᵧ)

Pauli-Y observable (σᵧ)
sourceraw docstring

pauli-zclj

Pauli-Z observable (σᵤ)

Pauli-Z observable (σᵤ)
sourceraw docstring

projector-0clj

Projector onto |0⟩ state

Projector onto |0⟩ state
sourceraw docstring

projector-1clj

Projector onto |1⟩ state

Projector onto |1⟩ state
sourceraw docstring

tensor-productclj

(tensor-product observables)

Create tensor product of observables: O₁ ⊗ O₂ ⊗ ... ⊗ Oₙ

Parameters:

  • observables: sequence of observable matrices

Returns: Matrix representing the tensor product

Example: (tensor-product [pauli-x pauli-z])

Create tensor product of observables: O₁ ⊗ O₂ ⊗ ... ⊗ Oₙ

Parameters:
- observables: sequence of observable matrices

Returns:
  Matrix representing the tensor product

Example:
  (tensor-product [pauli-x pauli-z])
sourceraw docstring

varianceclj

(variance observable quantum-state)

Calculate variance of observable: ⟨O²⟩ - ⟨O⟩²

Parameters:

  • observable: Hermitian matrix representing the observable
  • quantum-state: quantum state vector (normalized)

Returns: Real number representing the variance

Calculate variance of observable: ⟨O²⟩ - ⟨O⟩²

Parameters:
- observable: Hermitian matrix representing the observable
- quantum-state: quantum state vector (normalized)

Returns:
  Real number representing the variance
sourceraw docstring

zero-matrixclj

(zero-matrix rows cols)

Create a zero matrix of given dimensions

Create a zero matrix of given dimensions
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close