Skip to content

Commit

Permalink
update docs (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger-luo authored and GiggleLiu committed May 19, 2019
1 parent 34c1a38 commit 5b01922
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ For CUDA support, see [CuYao.jl](https://github.com/QuantumBFS/CuYao.jl).

## Documentation

- [**STABLE**](https://quantumbfs.github.io/Yao.jl/stable)
- [**LATEST**](https://quantumbfs.github.io/Yao.jl/latest)
- [**STABLE**](https://quantumbfs.github.io/Yao.jl/stable) — most recently tagged version of the documentation.
- [**LATEST**](https://quantumbfs.github.io/Yao.jl/latest) — in-development version of the documentation.

## Communication

Expand Down
9 changes: 0 additions & 9 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ end

const PAGES = [
"Home" => "index.md",
# "Tutorial" => Any[
# "tutorial/registers.md",
# "tutorial/blocks.md",
# "tutorial/bit_operations.md",
# ],
"Examples" => map(x->joinpath("examples", x * ".md"), Examples),
"Manual" => Any[
"man/array_registers.md",
Expand All @@ -28,10 +23,6 @@ const PAGES = [
"man/bitbasis.md",
"man/extending_blocks.md",
],
# "Developer Guide" => Any[
# "dev/customize_blocks.md",
# "dev/benchmarking.md",
# ],
]

makedocs(
Expand Down
1 change: 1 addition & 0 deletions docs/src/examples/QCBM.jmd
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ end

history = train(qcbm, κ, opt, pg)
trained_pg = probs(zero_state(nqubits(qcbm)) |> qcbm)
history
```

And we have the history of training which is
Expand Down
8 changes: 3 additions & 5 deletions docs/src/examples/QFT.jmd
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,8 @@ going to use the subblocks of `QFT`, if you need to use its subblocks, it'd
be better to define it under [`CompositeBlock`](@ref).

```julia
struct QFT{N, T} <: PrimitiveBlock{N, T} end

QFT(::Type{T}, n::Int) where T = QFT{n, T}()
QFT(n::Int) = QFT(ComplexF64, n)
struct QFT{N} <: PrimitiveBlock{N} end
QFT(n::Int) = QFT{n}()
```

Now, let's define its circuit
Expand All @@ -106,7 +104,7 @@ circuit(::QFT{N}) where N = qft(N)
And forward [`mat`](@ref) to its circuit's matrix

```julia
YaoBlocks.mat(x::QFT) = mat(circuit(x))
YaoBlocks.mat(::Type{T}, x::QFT) where T = mat(T, circuit(x))
```

You may notice, it is a little ugly to print `QFT` at the moment,
Expand Down
10 changes: 5 additions & 5 deletions docs/src/man/extending_blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ Primitive blocks are the most basic block to build a quantum circuit, if a primi
```julia
using YaoBlocks

mutable struct PhaseGate{T} <: PrimitiveBlock{1, Complex{T}}
mutable struct PhaseGate{T <: Real} <: PrimitiveBlock{1}
theta::T
end
```

If your insterested block is a composition of other blocks, you should define a [`CompositeBlock`](@ref), e.g

```julia
struct ChainBlock{N, T, MT <: AbstractBlock{N, T}} <: CompositeBlock{N, T}
blocks::Vector{MT}
struct ChainBlock{N} <: CompositeBlock{N}
blocks::Vector{AbstractBlock{N}}
end
```

Expand All @@ -71,13 +71,13 @@ Besides types, there are several interfaces you could define for a block, but do
The matrix form of a block is the minimal requirement to make a custom block functional, defining it is super simple, e.g for phase gate:

```julia
mat(x::PhaseGate{T}) where T = exp(im * x.theta) * Matrix{Complex{T}}(I, 2, 2)
mat(::Type{T}, gate::PhaseGate) where T = exp(T(im * gate.theta)) * Matrix{Complex{T}}(I, 2, 2)
```

Or for composite blocks, you could just calculate the matrix by call `mat` on its subblocks.

```julia
mat(c::ChainBlock) = prod(x->mat(x), reverse(c.blocks))
mat(::Type{T}, c::ChainBlock) where T = prod(x->mat(T, x), reverse(c.blocks))
```

The rest will just work, but might be slow since you didn't define any specification for this certain block.
Expand Down

0 comments on commit 5b01922

Please sign in to comment.