Skip to content

Commit a237c95

Browse files
committed
new trace operator
1 parent 5c497d5 commit a237c95

File tree

6 files changed

+33
-2
lines changed

6 files changed

+33
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Disclaimer: **this package is still under development and needs further polish.*
2222
## Contents
2323

2424
- [x] [QFT](https://github.com/QuantumBFS/YaoExtensions.jl)
25-
- [x] Grover search
2625
- [x] Phase Estimation
2726
- [x] Imaginary Time Evolution Quantum Eigensolver
2827
- [x] Variational Quantum Eigensolver
@@ -37,6 +36,7 @@ In examples folder, you will find
3736
- [x] Quantum Circuit Born Machine
3837
- [x] QuGAN
3938
- [x] Shor
39+
- [x] Grover search
4040

4141
- [x] [QuODE](https://github.com/QuantumBFS/QuDiffEq.jl)
4242
- [x] [TensorNetwork Inspired Circuits](https://github.com/GiggleLiu/QuantumPEPS.jl)

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ function generate(islocal::Bool="local" in ARGS)
5858
)
5959
end
6060

61-
generate(true)
61+
generate(false)

docs/src/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ A curated implementation of quantum algorithms with [Yao.jl](https://github.com/
99
## Tutorial
1010
```@contents
1111
Pages = [
12+
"tutorial/Grover.md",
1213
"tutorial/VQE.md",
1314
"tutorial/Shor.md",
1415
]
1516
Depth = 1
1617
```
1718

19+
Some examples are not yet documented, please refer the [README](https://github.com/QuantumBFS/QuAlgorithmZoo.jl) for a full list of algorithms.
20+
1821
## Manual
22+
23+
The manual is a references of utilities defined in QuAlgorithmZoo,
24+
like `Adam` optimizer and `NumberTheory` submodule.
1925
```@contents
2026
Pages = [
2127
"man/zoo.md",

examples/TraceOperator/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Tracing an operator
2+
3+
To compute $\Re[{\rm Tr}(Ue^{-i\theta})]$, we utilize the Hadamard test.
4+
5+
The circuit is
6+
![trace circuit](traceop.png)
7+
8+
This result can be proved from its tensor network representation.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Yao
2+
using QuAlgorithmZoo
3+
using YaoBlocks.ConstGate
4+
using Test
5+
using LinearAlgebra
6+
7+
@testset "hadamard test" begin
8+
n = 2
9+
U = chain(put(n, 2=>Rx(0.2)), put(n, 1=>Rz(1.2)), put(n, 1=>phase(0.4)))
10+
US = chain(2n, put(2n, (3,4)=>U),
11+
chain(2n, [swap(2n,i,i+n) for i=1:n]))
12+
reg = zero_state(2n)
13+
reg |> repeat(2n, H, 1:n) |> chain(2n, [cnot(2n,i,i+n) for i=1:n])
14+
@show real(tr(mat(U)))/(1<<n)
15+
@test hadamard_test(US, reg, 0.0) real(tr(mat(U)))/(1<<n)
16+
@test hadamard_test(US, reg, -π/2) imag(tr(mat(U)))/(1<<n)
17+
end

examples/TraceOperator/traceop.png

25.6 KB
Loading

0 commit comments

Comments
 (0)