2024-12-07 21:24:22 -08:00
|
|
|
(defpackage :cl-quantum/math
|
2024-12-08 22:06:58 -08:00
|
|
|
(:documentation "Basic linear algebra subroutines used to implement the
|
|
|
|
quantum operators.")
|
2024-12-07 21:24:22 -08:00
|
|
|
(:use :cl)
|
|
|
|
(:export #:domatrix
|
|
|
|
#:mapmatrix
|
2024-12-19 12:25:23 -08:00
|
|
|
#:matrixp
|
2024-12-07 21:24:22 -08:00
|
|
|
#:minor
|
|
|
|
#:cofactor
|
|
|
|
#:det
|
|
|
|
#:invert
|
|
|
|
#:transpose
|
|
|
|
#:norm
|
|
|
|
#:*mm
|
|
|
|
#:*mv
|
|
|
|
#:*vm
|
|
|
|
#:dot
|
|
|
|
#:+mm
|
|
|
|
#:+vv
|
|
|
|
#:-mm
|
|
|
|
#:-vv
|
|
|
|
#:*ms
|
|
|
|
#:*vs
|
|
|
|
#:/ms
|
|
|
|
#:/vs
|
|
|
|
#:mconj
|
|
|
|
#:vconj
|
|
|
|
#:squarep
|
|
|
|
#:singularp
|
|
|
|
#:mtrace
|
|
|
|
#:make-identity-matrix
|
|
|
|
#:copy-matrix
|
|
|
|
#:nswap-rows
|
|
|
|
#:swap-rows
|
|
|
|
#:nscale-row
|
|
|
|
#:scale-row
|
|
|
|
#:nreplace-row-with-sum
|
|
|
|
#:replace-row-with-sum
|
|
|
|
#:tensor-mm
|
|
|
|
#:tensor-vv
|
|
|
|
#:round-to-place
|
|
|
|
#:round-vector
|
|
|
|
#:round-matrix
|
|
|
|
#:count-digits
|
|
|
|
#:build-float
|
|
|
|
#:mexp
|
|
|
|
#:wholep
|
|
|
|
#:mexpt
|
|
|
|
#:matrix=
|
|
|
|
#:vector=))
|
|
|
|
|
|
|
|
(defpackage :cl-quantum/state
|
2024-12-08 22:06:58 -08:00
|
|
|
(:documentation "Functions for creating and applying quantum gates.")
|
2024-12-07 21:24:22 -08:00
|
|
|
(:use :cl :cl-quantum/math)
|
2024-12-08 22:06:58 -08:00
|
|
|
(:export #:define-constant
|
|
|
|
#:+unset-projector+
|
2024-12-08 09:41:05 -08:00
|
|
|
#:+set-projector+
|
|
|
|
#:+identity-2x2+
|
|
|
|
#:+pauli-x-gate+
|
|
|
|
#:+pauli-y-gate+
|
|
|
|
#:+pauli-z-gate+
|
|
|
|
#:+hadamard-gate+
|
|
|
|
#:+phase-gate+
|
|
|
|
#:+pi/8-gate+
|
|
|
|
#:+cnot-gate+
|
|
|
|
#:+cz-gate+
|
|
|
|
#:+swap-gate+
|
|
|
|
#:+ccnot-gate+
|
|
|
|
#:normal-state-p
|
2024-12-07 21:24:22 -08:00
|
|
|
#:normalize-state
|
|
|
|
#:nnormalize-state
|
|
|
|
#:state-bits
|
2024-12-08 22:06:58 -08:00
|
|
|
#:make-zero-state
|
2024-12-07 21:24:22 -08:00
|
|
|
#:make-normal-state
|
|
|
|
#:make-uniform-normal-state
|
|
|
|
#:bit-unset-index
|
|
|
|
#:bit-set-index
|
|
|
|
#:bit-probability
|
|
|
|
#:nmeasure
|
|
|
|
#:measure
|
2024-12-08 09:41:05 -08:00
|
|
|
#:ncollapse
|
|
|
|
#:collapse
|
2024-12-07 21:24:22 -08:00
|
|
|
#:make-operator
|
|
|
|
#:make-controlled-operator
|
2024-12-08 22:06:58 -08:00
|
|
|
#:make-n-toffoli-operator
|
|
|
|
#:make-n-controlled-z-operator
|
|
|
|
#:replace-state
|
|
|
|
#:apply-gate
|
|
|
|
#:napply-gate
|
|
|
|
#:apply-controlled-gate
|
|
|
|
#:napply-controlled-gate))
|
2024-12-07 21:24:22 -08:00
|
|
|
|
|
|
|
(defpackage :cl-quantum/circuit
|
2024-12-08 22:06:58 -08:00
|
|
|
(:documentation "High-level interface for building quantum circuits.")
|
2024-12-07 21:24:22 -08:00
|
|
|
(:use :cl :cl-quantum/math :cl-quantum/state)
|
2024-12-08 09:41:05 -08:00
|
|
|
(:export #:*circuit-measure-places*
|
|
|
|
#:*circuit-operators*
|
|
|
|
#:make-circuit
|
|
|
|
#:add-to-circuit
|
|
|
|
#:with-build-circuit
|
|
|
|
#:run-circuit))
|
|
|
|
|
|
|
|
(defpackage :cl-quantum/pprint
|
2024-12-08 22:06:58 -08:00
|
|
|
(:documentation "High-level interface for building quantum circuits.")
|
2024-12-08 09:41:05 -08:00
|
|
|
(:use :cl :cl-quantum/math :cl-quantum/state)
|
|
|
|
(:export #:pprint-complex
|
|
|
|
#:pprint-format-bits
|
|
|
|
#:pprint-format-linear
|
|
|
|
#:pprint-state))
|