package main import "fmt" import "math" func Xgate(in complex128) complex128{ return in * complex(-1,0) } func Zgate(in complex128) complex128{ return in * complex(0,-1) } func Hgate(in complex128) complex128{ a := real(in) b := imag(in) c := (a + b) / math.Sqrt(2) d := (a - b) / math.Sqrt(2) return complex(c, d) } func CNOTgate(in1 complex128, in2 complex128) (complex128, complex128){ out1 := in1 out2 := complex(imag(in2), real(in2)) return out1, out2 } func main() { a := 1 + 3i b := 3 + 2i c := 1i fmt.Println(a * b) fmt.Println(a / b) fmt.Println(c) d := Hgate(a) fmt.Println(d) e,f := CNOTgate(a,b) fmt.Println(e) fmt.Println(f) }