Skip to content

torfstack/goco

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goco

goco is a library to construct quantum circuits in Go. It is inspired by Qiskit, a quantum computing library in Python. Quantum circuits can be constructed with an unlimited number of qubits and gates. The library also supports the simulation of quantum circuits. As the simulation is based on the statevector representation, the number of qubits should be limited to 20 or less to avoid memory issues.

Installation

go get github.com/torfstack/goco

Example

package main

import (
	"fmt"
	"github.com/torfstack/goco/backend"
	"github.com/torfstack/goco/quantum"
)

func main() {
	// Create a quantum circuit with 2 qubits
	qs := quantum.NewSystem(2) // 2 qubits

	// Apply a Hadamard gate to the first qubit
	qs.H(0)

	// Apply a CNOT gate to the first and second qubits
	qs.CNOT(0, 1)

	// Simulate the circuit
	b := backend.NewLinearAlgebraBackend(&qs)
	result := b.Simulate()

	// Print the result: [0.5, 0, 0, 0.5]
	fmt.Println(result)
}