q

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 5 Imported by: 14

README

q

PkgGoDev Go Report Card tests codecov

  • quantum computation simulator
  • pure Go implementation
  • using only the standard library

Example

Bell state
qsim := q.New()

// generate qubits of |0>|0>
q0 := qsim.Zero()
q1 := qsim.Zero()

// apply quantum circuit
qsim.H(q0).CNOT(q0, q1)

for _, s := range qsim.State() {
  fmt.Println(s)
}
// [00][  0]( 0.7071 0.0000i): 0.5000
// [11][  3]( 0.7071 0.0000i): 0.5000

m0 := qsim.Measure(q0)
m1 := qsim.Measure(q1)
fmt.Println(m0.Equals(m1)) // always true

for _, s := range qsim.State() {
  fmt.Println(s)
}
// [00][  0]( 1.0000 0.0000i): 1.0000
// or
// [11][  3]( 1.0000 0.0000i): 1.0000
Quantum teleportation
qsim := q.New()

// generate qubits of |phi>|0>|0>
phi := qsim.New(1, 2)
q0 := qsim.Zero()
q1 := qsim.Zero()

// |phi> is normalized. |phi> = a|0> + b|1>, |a|^2 = 0.2, |b|^2 = 0.8
for _, s := range qsim.State(phi) {
  fmt.Println(s)
}
// [0][  0]( 0.4472 0.0000i): 0.2000
// [1][  1]( 0.8944 0.0000i): 0.8000

qsim.H(q0).CNOT(q0, q1)
qsim.CNOT(phi, q0).H(phi)

// Alice send mz, mx to Bob
mz := qsim.Measure(phi)
mx := qsim.Measure(q0)

// Bob Apply X and Z
qsim.CondX(mx.IsOne(), q1)
qsim.CondZ(mz.IsOne(), q1)

// Bob got |phi> state with q1
for _, s := range qsim.State(q1) {
  fmt.Println(s)
}
// [0][  0]( 0.4472 0.0000i): 0.2000
// [1][  1]( 0.8944 0.0000i): 0.8000
Error correction
qsim := q.New()

q0 := qsim.New(1, 2) // (0.2, 0.8)

// encoding
q1 := qsim.Zero()
q2 := qsim.Zero()
qsim.CNOT(q0, q1).CNOT(q0, q2)

// error: first qubit is flipped
qsim.X(q0)

// add ancilla qubit
q3 := qsim.Zero()
q4 := qsim.Zero()

// error correction
qsim.CNOT(q0, q3).CNOT(q1, q3)
qsim.CNOT(q1, q4).CNOT(q2, q4)

m3 := qsim.Measure(q3)
m4 := qsim.Measure(q4)

qsim.CondX(m3.IsOne() && m4.IsZero(), q0)
qsim.CondX(m3.IsOne() && m4.IsOne(), q1)
qsim.CondX(m3.IsZero() && m4.IsOne(), q2)

// decoding
qsim.CNOT(q0, q2).CNOT(q0, q1)

for _, s := range qsim.State(q0) {
  fmt.Println(s)
}
// [0][  0]( 0.4472 0.0000i): 0.2000
// [1][  1]( 0.8944 0.0000i): 0.8000
Grover's search algorithm
qsim := q.New()

// initial state
q0 := qsim.Zero()
q1 := qsim.Zero()
q2 := qsim.Zero()
q3 := qsim.Zero()

// superposition
qsim.H(q0, q1, q2, q3)

// iteration
N := number.Pow(2, qsim.NumberOfBit())
r := math.Floor(math.Pi / 4 * math.Sqrt(float64(N)))
for i := 0; i < int(r); i++ {
  // oracle for |110>|x>
  qsim.X(q2, q3)
  qsim.H(q3).CCCNOT(q0, q1, q2, q3).H(q3)
  qsim.X(q2, q3)

  // amplification
  qsim.H(q0, q1, q2, q3)
  qsim.X(q0, q1, q2, q3)
  qsim.H(q3).CCCNOT(q0, q1, q2, q3).H(q3)
  qsim.X(q0, q1, q2, q3)
  qsim.H(q0, q1, q2, q3)
}

for _, s := range qsim.State() {
  fmt.Println(s)
}
// [0000][  0]( 0.0508 0.0000i): 0.0026
// [0001][  1]( 0.0508 0.0000i): 0.0026
// [0010][  2]( 0.0508 0.0000i): 0.0026
// [0011][  3]( 0.0508 0.0000i): 0.0026
// [0100][  4]( 0.0508 0.0000i): 0.0026
// [0101][  5]( 0.0508 0.0000i): 0.0026
// [0110][  6]( 0.0508 0.0000i): 0.0026
// [0111][  7]( 0.0508 0.0000i): 0.0026
// [1000][  8]( 0.0508 0.0000i): 0.0026
// [1001][  9]( 0.0508 0.0000i): 0.0026
// [1010][ 10]( 0.0508 0.0000i): 0.0026
// [1011][ 11]( 0.0508 0.0000i): 0.0026
// [1100][ 12](-0.9805 0.0000i): 0.9613 -> answer!
// [1101][ 13]( 0.0508 0.0000i): 0.0026
// [1110][ 14]( 0.0508 0.0000i): 0.0026
// [1111][ 15]( 0.0508 0.0000i): 0.0026
Shor's factoring algorithm
N := 15
a := 7 // co-prime

for i := 0; i < 10; i++{
  qsim := q.New()

  // initial state
  q0 := qsim.Zero()
  q1 := qsim.Zero()
  q2 := qsim.Zero()

  q3 := qsim.Zero()
  q4 := qsim.Zero()
  q5 := qsim.Zero()
  q6 := qsim.One()

  // superposition
  qsim.H(q0, q1, q2)

  // Controlled-U
  qsim.CNOT(q2, q4)
  qsim.CNOT(q2, q5)

  // Controlled-U^2
  qsim.CNOT(q3, q5).CCNOT(q1, q5, q3).CNOT(q3, q5)
  qsim.CNOT(q6, q4).CCNOT(q1, q4, q6).CNOT(q6, q4)

  // inverse QFT
  qsim.Swap(q0, q2)
  qsim.InvQFT(q0, q1, q2)

  // measure q0, q1, q2
  m := qsim.Measure(q0, q1, q2).BinaryString()

  // find s/r. 0.010 -> 0.25 -> 1/4, 0.110 -> 0.75 -> 3/4, ...
  s, r, d, ok := number.FindOrder(a, N, fmt.Sprintf("0.%s", m))
  if !ok || number.IsOdd(r) {
    continue
  }

  // gcd(a^(r/2)-1, N), gcd(a^(r/2)+1, N)
  p0 := number.GCD(number.Pow(a, r/2)-1, N)
  p1 := number.GCD(number.Pow(a, r/2)+1, N)
  if number.IsTrivial(N, p0, p1) {
    continue
  }

  // result
  fmt.Printf("i=%d: N=%d, a=%d. p=%v, q=%v. s/r=%d/%d ([0.%v]~%.3f)\n", i, N, a, p0, p1, s, r, m, d)
}

// i=2: N=15, a=7. p=3, q=5. s/r=1/4 ([0.010]~0.250)
Any quantum gate and its controlled gate
h := gate.U(math.Pi/2, 0, math.Pi)
x := gate.U(math.Pi, 0, math.Pi)

qsim := q.New()
q0 := qsim.Zero()
q1 := qsim.Zero()

qsim.Apply(h, q0)
qsim.C(x, q0, q1)

for _, s := range qsim.State() {
  fmt.Println(s)
}
// [00][  0]( 0.7071 0.0000i): 0.5000
// [11][  3]( 0.7071 0.0000i): 0.5000

References

  • Michael A. Nielsen, Issac L. Chuang. Quantum Computation and Quantum Information.

Documentation

Overview

Example (Any)
Output:

[00][  0]( 0.7071 0.0000i): 0.5000
[11][  3]( 0.7071 0.0000i): 0.5000
Example (BellState)
Output:

[00][  0]( 0.7071 0.0000i): 0.5000
[11][  3]( 0.7071 0.0000i): 0.5000
true
Example (BellState2)
Output:

11
Example (DeutschJozsa)
Output:

Correct!
Example (ErrorCorrection)
Output:

q0:
[0][  0]( 0.4472 0.0000i): 0.2000
[1][  1]( 0.8944 0.0000i): 0.8000
q0(flipped):
[0][  0]( 0.8944 0.0000i): 0.8000
[1][  1]( 0.4472 0.0000i): 0.2000
q0(corrected):
[0][  0]( 0.4472 0.0000i): 0.2000
[1][  1]( 0.8944 0.0000i): 0.8000
Example (Grover3qubit)
Output:

[000 1][  0   1](-0.1768 0.0000i): 0.0313
[001 1][  1   1](-0.1768 0.0000i): 0.0313
[010 1][  2   1](-0.1768 0.0000i): 0.0313
[011 1][  3   1](-0.8839 0.0000i): 0.7813
[100 1][  4   1](-0.1768 0.0000i): 0.0313
[101 1][  5   1](-0.1768 0.0000i): 0.0313
[110 1][  6   1](-0.1768 0.0000i): 0.0313
[111 1][  7   1](-0.1768 0.0000i): 0.0313
Example (Grover4qubit)
Output:

[0000][  0]( 0.0508 0.0000i): 0.0026
[0001][  1]( 0.0508 0.0000i): 0.0026
[0010][  2]( 0.0508 0.0000i): 0.0026
[0011][  3]( 0.0508 0.0000i): 0.0026
[0100][  4]( 0.0508 0.0000i): 0.0026
[0101][  5]( 0.0508 0.0000i): 0.0026
[0110][  6]( 0.0508 0.0000i): 0.0026
[0111][  7]( 0.0508 0.0000i): 0.0026
[1000][  8]( 0.0508 0.0000i): 0.0026
[1001][  9]( 0.0508 0.0000i): 0.0026
[1010][ 10]( 0.0508 0.0000i): 0.0026
[1011][ 11]( 0.0508 0.0000i): 0.0026
[1100][ 12](-0.9805 0.0000i): 0.9613
[1101][ 13]( 0.0508 0.0000i): 0.0026
[1110][ 14]( 0.0508 0.0000i): 0.0026
[1111][ 15]( 0.0508 0.0000i): 0.0026
Example (QFT)
Output:

[000][  0]( 0.3536 0.0000i): 0.1250
[001][  1]( 0.0000 0.3536i): 0.1250
[010][  2](-0.3536 0.0000i): 0.1250
[011][  3]( 0.0000-0.3536i): 0.1250
[100][  4]( 0.3536 0.0000i): 0.1250
[101][  5]( 0.0000 0.3536i): 0.1250
[110][  6](-0.3536 0.0000i): 0.1250
[111][  7]( 0.0000-0.3536i): 0.1250
Example (QuantumTeleportation)
Output:

phi:
[0][  0]( 0.4472 0.0000i): 0.2000
[1][  1]( 0.8944 0.0000i): 0.8000
q1:
[0][  0]( 0.4472 0.0000i): 0.2000
[1][  1]( 0.8944 0.0000i): 0.8000
Example (QuantumTeleportation2)
Output:

phi:
[0][  0]( 0.4472 0.0000i): 0.2000
[1][  1]( 0.8944 0.0000i): 0.8000
q1:
[0][  0]( 0.4472 0.0000i): 0.2000
[1][  1]( 0.8944 0.0000i): 0.8000
Example (ShorFactoring15)
Output:

N=15, a=7. p=3, q=5. s/r=3/4 ([0.110]~0.750)
Example (ShorFactoring21)
Output:

N=21, a=8. p=7, q=3. s/r=1/2 ([0.1000]~0.500)
Example (ShorFactoring51)
Output:

N=51, a=5. p=3, q=17. s/r=7/16 ([0.0111]~0.438)
Example (ShorFactoring85)
Output:

N=85, a=14. p=5, q=17. s/r=7/16 ([0.0111]~0.438)
Example (SuperDenseCoding)
Output:

I : 00
X : 01
Z : 10
ZX: 11
Example (Top)
Output:

[1000][  8]( 0.4330 0.0000i): 0.1875
[0000][  0]( 0.4330 0.0000i): 0.1875
[1101][ 13](-0.3485 0.0000i): 0.1214
[1011][ 11](-0.3485 0.0000i): 0.1214
[0011][  3](-0.3485 0.0000i): 0.1214
[0101][  5](-0.3485 0.0000i): 0.1214
[0100][  4](-0.1443 0.0000i): 0.0208
[0110][  6]( 0.1443 0.0000i): 0.0208
[1010][ 10]( 0.1443 0.0000i): 0.0208
[0010][  2]( 0.1443 0.0000i): 0.0208

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Index

func Index(qb ...Qubit) []int

Index returns the index list of qubits.

func Theta added in v0.0.3

func Theta(k int) float64

Theta returns 2 * pi / 2**k

Types

type Q

type Q struct {
	Rand func() float64
	// contains filtered or unexported fields
}

Q is a quantum computation simulator.

func New

func New() *Q

New returns a new quantum computation simulator.

func (*Q) Amplitude

func (q *Q) Amplitude() []complex128

Amplitude returns the amplitude of qubits.

Example
Output:

(0.7071067811865476+0i)
(0+0i)
(0+0i)
(0.7071067811865476+0i)

func (*Q) Apply

func (q *Q) Apply(m matrix.Matrix, qb ...Qubit) *Q

Apply applies matrix to qubits.

Example
Output:

[00][  0]( 0.7071 0.0000i): 0.5000
[11][  3]( 0.7071 0.0000i): 0.5000

func (*Q) C

func (q *Q) C(m matrix.Matrix, control, target Qubit) *Q
Example
Output:

[00][  0]( 0.7071 0.0000i): 0.5000
[11][  3]( 0.7071 0.0000i): 0.5000

func (*Q) CCCNOT

func (q *Q) CCCNOT(control0, control1, control2, target Qubit) *Q

CCCNOT applies CCCNOT gate.

func (*Q) CCNOT

func (q *Q) CCNOT(control0, control1, target Qubit) *Q

CCNOT applies CCNOT gate.

func (*Q) CCZ

func (q *Q) CCZ(control0, control1, target Qubit) *Q

func (*Q) CModExp2

func (q *Q) CModExp2(a, N int, control []Qubit, target []Qubit) *Q

CModExp2 applies Controlled-ModExp2 gate.

Example
Output:

[111 0001][  7   1]( 1.0000 0.0000i): 1.0000
[111 1101][  7  13]( 1.0000 0.0000i): 1.0000

func (*Q) CNOT

func (q *Q) CNOT(control, target Qubit) *Q

CNOT applies CNOT gate.

func (*Q) CR

func (q *Q) CR(theta float64, control, target Qubit) *Q

CR applies Controlled-R gate.

func (*Q) CZ

func (q *Q) CZ(control, target Qubit) *Q

func (*Q) Clone

func (q *Q) Clone() *Q

Clone returns a clone of a quantum computation simulator.

Example
Output:

[(1+0i) (0+0i) (0+0i) (0+0i)]
[(0+0i) (0+0i) (0+0i) (1+0i)]
[(0+0i) (0+0i) (0+0i) (1+0i)]

func (*Q) Cond added in v0.0.3

func (q *Q) Cond(condition bool, m matrix.Matrix, qb ...Qubit) *Q

Cond applies m if condition is true.

func (*Q) CondX added in v0.0.3

func (q *Q) CondX(condition bool, qb ...Qubit) *Q

CondX applies X gate if condition is true.

Example
Output:

[0][  0]( 1.0000 0.0000i): 1.0000
[1][  1]( 1.0000 0.0000i): 1.0000

func (*Q) CondZ added in v0.0.3

func (q *Q) CondZ(condition bool, qb ...Qubit) *Q

CondZ applies Z gate if condition is true.

Example
Output:

[1][  1]( 1.0000 0.0000i): 1.0000
[1][  1](-1.0000 0.0000i): 1.0000

func (*Q) Controlled

func (q *Q) Controlled(m matrix.Matrix, control []Qubit, target Qubit) *Q

func (*Q) ControlledModExp2

func (q *Q) ControlledModExp2(a, j, N int, control Qubit, target []Qubit) *Q

ControlledModExp2 applies Controlled-ModExp2 gate.

Example (Mod15)
Output:

[1 0001][  1   1]( 1.0000 0.0000i): 1.0000
[1 0111][  1   7]( 1.0000 0.0000i): 1.0000
[1 1101][  1  13]( 1.0000 0.0000i): 1.0000
[1 1101][  1  13]( 1.0000 0.0000i): 1.0000
Example (Mod21)
Output:

[1 00001][  1   1]( 1.0000 0.0000i): 1.0000
[1 00010][  1   2]( 1.0000 0.0000i): 1.0000
[1 01000][  1   8]( 1.0000 0.0000i): 1.0000
[1 00010][  1   2]( 1.0000 0.0000i): 1.0000
[1 01000][  1   8]( 1.0000 0.0000i): 1.0000

func (*Q) ControlledNot

func (q *Q) ControlledNot(control []Qubit, target Qubit) *Q

ControlledNot applies CNOT gate.

func (*Q) ControlledR

func (q *Q) ControlledR(theta float64, control []Qubit, target Qubit) *Q

func (*Q) ControlledZ

func (q *Q) ControlledZ(control []Qubit, target Qubit) *Q

ControlledZ applies Controlled-Z gate.

func (*Q) H

func (q *Q) H(qb ...Qubit) *Q

H applies H gate.

func (*Q) I

func (q *Q) I(qb ...Qubit) *Q

I applies I gate.

Example
Output:

[0][  0]( 1.0000 0.0000i): 1.0000

func (*Q) IQFT

func (q *Q) IQFT(qb ...Qubit) *Q

IQFT applies Inverse Quantum Fourier Transform.

Example
Output:

[010][  2]( 1.0000 0.0000i): 1.0000

func (*Q) InvQFT

func (q *Q) InvQFT(qb ...Qubit) *Q

InvQFT applies Inverse Quantum Fourier Transform.

Example
Output:

[010][  2]( 1.0000 0.0000i): 1.0000

func (*Q) InverseQFT

func (q *Q) InverseQFT(qb ...Qubit) *Q

InverseQFT applies Inverse Quantum Fourier Transform.

func (*Q) M

func (q *Q) M(qb ...Qubit) *qubit.Qubit

M returns the measured state of qubits.

Example
Output:

[(0+0i) (1+0i)]
[(0+0i) (0+0i) (0+0i) (0+0i) (1+0i) (0+0i) (0+0i) (0+0i)]
[(0+0i) (0+0i) (0+0i) (0+0i) (1+0i) (0+0i) (0+0i) (0+0i)]

func (*Q) Measure

func (q *Q) Measure(qb ...Qubit) *qubit.Qubit

Measure returns the measured state of qubits.

Example
Output:

[(0+0i) (1+0i)]
[(0+0i) (0+0i) (0+0i) (0+0i) (1+0i) (0+0i) (0+0i) (0+0i)]
[(0+0i) (0+0i) (0+0i) (0+0i) (1+0i) (0+0i) (0+0i) (0+0i)]

func (*Q) New

func (q *Q) New(v ...complex128) Qubit

New returns a new qubit.

func (*Q) NewOf

func (q *Q) NewOf(binary string) []Qubit

NewOf returns a new qubit from binary string.

Example
Output:

[(1+0i) (0+0i)]
[(0+0i) (1+0i)]
[(1+0i) (0+0i)]
[(0+0i) (1+0i)]

func (*Q) NumberOfBit

func (q *Q) NumberOfBit() int

NumberOfBit returns the number of qubits.

func (*Q) One

func (q *Q) One() Qubit

One returns a qubit in the one state.

func (*Q) OneWith

func (q *Q) OneWith(n int) []Qubit

One returns n qubits in the one state.

Example
Output:

[00][  0]( 0.5000 0.0000i): 0.2500
[01][  1](-0.5000 0.0000i): 0.2500
[10][  2](-0.5000 0.0000i): 0.2500
[11][  3]( 0.5000 0.0000i): 0.2500

func (*Q) Probability

func (q *Q) Probability() []float64

Probability returns the probability of qubits.

Example
Output:

0.5000
0.0000
0.0000
0.5000

func (*Q) QFT

func (q *Q) QFT(qb ...Qubit) *Q

QFT applies Quantum Fourier Transform.

Example
Output:

[000][  0]( 0.3536 0.0000i): 0.1250
[001][  1]( 0.0000 0.3536i): 0.1250
[010][  2](-0.3536 0.0000i): 0.1250
[011][  3]( 0.0000-0.3536i): 0.1250
[100][  4]( 0.3536 0.0000i): 0.1250
[101][  5]( 0.0000 0.3536i): 0.1250
[110][  6](-0.3536 0.0000i): 0.1250
[111][  7]( 0.0000-0.3536i): 0.1250

func (*Q) R

func (q *Q) R(theta float64, qb ...Qubit) *Q

R applies R gate with theta.

Example
Output:

[1][  1]( 0.0000 1.0000i): 1.0000

func (*Q) RX

func (q *Q) RX(theta float64, qb ...Qubit) *Q

RX applies RX gate with theta.

Example
Output:

[1][  1]( 0.0000-1.0000i): 1.0000

func (*Q) RY

func (q *Q) RY(theta float64, qb ...Qubit) *Q

RY applies RY gate with theta.

Example
Output:

[1][  1]( 1.0000 0.0000i): 1.0000

func (*Q) RZ

func (q *Q) RZ(theta float64, qb ...Qubit) *Q

RZ applies RZ gate with theta.

Example
Output:

[0][  0]( 0.0000-1.0000i): 1.0000

func (*Q) Raw

func (q *Q) Raw() *qubit.Qubit

Raw returns the internal qubit.

Example
Output:

0
1

func (*Q) Reset

func (q *Q) Reset(qb ...Qubit)

Reset sets qubits to the zero state.

Example
Output:

[00][  0]( 1.0000 0.0000i): 1.0000
[00][  0]( 1.0000 0.0000i): 1.0000

func (*Q) S

func (q *Q) S(qb ...Qubit) *Q

S applies S gate.

Example
Output:

[1][  1]( 0.0000 1.0000i): 1.0000

func (*Q) State

func (q *Q) State(reg ...any) []qubit.State

State returns the state of qubits.

func (*Q) String

func (q *Q) String() string

String returns the string representation of a quantum computation simulator.

Example
Output:

[(0+0i) (0+0i) (1+0i) (0+0i)]

func (*Q) Swap

func (q *Q) Swap(qb ...Qubit) *Q

Swap applies Swap gate.

func (*Q) T

func (q *Q) T(qb ...Qubit) *Q

T applies T gate.

Example
Output:

[1][  1]( 0.7071 0.7071i): 1.0000

func (*Q) Toffoli

func (q *Q) Toffoli(control0, control1, target Qubit) *Q

Toffoli applies Toffoli gate.

Example
Output:

[111][  7]( 1.0000 0.0000i): 1.0000

func (*Q) U

func (q *Q) U(theta, phi, lambda float64, qb ...Qubit) *Q

U applies U gate.

Example
Output:

[1][  1]( 1.0000 0.0000i): 1.0000

func (*Q) X

func (q *Q) X(qb ...Qubit) *Q

X applies X gate.

Example
Output:

[1][  1]( 1.0000 0.0000i): 1.0000

func (*Q) Y

func (q *Q) Y(qb ...Qubit) *Q

Y applies Y gate.

Example
Output:

[0][  0]( 0.0000-1.0000i): 1.0000

func (*Q) Z

func (q *Q) Z(qb ...Qubit) *Q

Z applies Z gate.

Example
Output:

[1][  1](-1.0000 0.0000i): 1.0000

func (*Q) Zero

func (q *Q) Zero() Qubit

Zero returns a qubit in the zero state.

Example
Output:

[00][  0]( 0.5000 0.0000i): 0.2500
[01][  1]( 0.5000 0.0000i): 0.2500
[10][  2]( 0.5000 0.0000i): 0.2500
[11][  3]( 0.5000 0.0000i): 0.2500

func (*Q) ZeroLog2

func (q *Q) ZeroLog2(N int) []Qubit

ZeroLog2 returns n qubits in the zero state. n is greater than or equal to log2(N).

Example
Output:

[00][  0]( 0.5000 0.0000i): 0.2500
[01][  1]( 0.5000 0.0000i): 0.2500
[10][  2]( 0.5000 0.0000i): 0.2500
[11][  3]( 0.5000 0.0000i): 0.2500

func (*Q) ZeroWith

func (q *Q) ZeroWith(n int) []Qubit

ZeroWith returns n qubits in the zero state.

Example
Output:

[00][  0]( 0.5000 0.0000i): 0.2500
[01][  1]( 0.5000 0.0000i): 0.2500
[10][  2]( 0.5000 0.0000i): 0.2500
[11][  3]( 0.5000 0.0000i): 0.2500

type Qubit

type Qubit int

Qubit is a quantum bit.

func (Qubit) Index

func (q Qubit) Index() int

Index returns the index of qubit.

Directories

Path Synopsis
cmd
math
quantum

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL