QuantumBFS / Yao.jl

Extensible, Efficient Quantum Algorithm Design for Humans.
https://yaoquantum.org
Other
924 stars 122 forks source link

Qudits instructions #379

Closed GiggleLiu closed 2 years ago

GiggleLiu commented 2 years ago

Measuring Qudits

julia> using Yao

julia> measure(product_state(dit"012;3"); nshots=3)
3-element Vector{BitBasis.DitStr64{3, 3}}:
 012 ₍₃₎
 012 ₍₃₎
 012 ₍₃₎

Dit string Indexing

Now you can play with operators indexing and propagation.

julia> using Yao

julia> h = EasyBuild.heisenberg(60);

julia> cleanup(h[:,cleanup(h[:,BitStr{60}(234)])]) |> length
22

julia> @time cleanup(h[:,cleanup(h[:,BitStr{60}(234)])]);
  0.017032 seconds (169.35 k allocations: 4.729 MiB)

julia> @btime $h[BitStr{60}(235),BitStr{60}(234)]
  161.038 μs (1213 allocations: 57.03 KiB)
0.0 + 0.0im

julia> h[:,BitStr{60}(234)] |> cleanup
EntryTable{DitStr{2, 60, Int64}, ComplexF64}:
  000000000000000000000000000000000000000000000000000011011010 ₍₂₎   2.0 + 0.0im
  000000000000000000000000000000000000000000000000000011100110 ₍₂₎   2.0 + 0.0im
  000000000000000000000000000000000000000000000000000011101001 ₍₂₎   2.0 + 0.0im
  000000000000000000000000000000000000000000000000000011101010 ₍₂₎   48.0 + 0.0im
  000000000000000000000000000000000000000000000000000011101100 ₍₂₎   2.0 + 0.0im
  000000000000000000000000000000000000000000000000000011110010 ₍₂₎   2.0 + 0.0im
  000000000000000000000000000000000000000000000000000101101010 ₍₂₎   2.0 + 0.0im

julia> h[BitStr{60}(235),BitStr{60}(234)]
0.0 + 0.0im

AbstractAdd

AbstractAdd{D} <: CompositeBlock{D}

The abstract add interface, aimed to support Hamiltonian types.

Required Interfaces

Provides

codecov[bot] commented 2 years ago

Codecov Report

Merging #379 (73e5b7f) into master (fc3046e) will increase coverage by 1.19%. The diff coverage is 96.75%.

@@            Coverage Diff             @@
##           master     #379      +/-   ##
==========================================
+ Coverage   87.47%   88.67%   +1.19%     
==========================================
  Files          72       73       +1     
  Lines        3849     4327     +478     
==========================================
+ Hits         3367     3837     +470     
- Misses        482      490       +8     
Impacted Files Coverage Δ
lib/YaoBlocks/src/YaoBlocks.jl 100.00% <ø> (ø)
lib/YaoBlocks/src/autodiff/mat_back.jl 91.66% <0.00%> (ø)
lib/YaoBlocks/src/composite/composite.jl 75.00% <ø> (-5.00%) :arrow_down:
lib/YaoBlocks/src/primitive/primitive.jl 100.00% <ø> (ø)
lib/YaoBlocks/src/primitive/rotation_gate.jl 91.48% <ø> (+1.74%) :arrow_up:
lib/YaoSym/src/symengine/instruct.jl 71.42% <66.66%> (ø)
lib/YaoArrayRegister/src/instruct.jl 89.80% <87.50%> (-0.05%) :arrow_down:
lib/YaoBlocks/src/composite/tag/dagger.jl 86.36% <92.85%> (+11.36%) :arrow_up:
lib/YaoArrayRegister/src/qudit_instruct.jl 95.55% <95.55%> (ø)
lib/YaoBlocks/src/routines.jl 95.98% <96.15%> (+0.09%) :arrow_up:
... and 25 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update fc3046e...73e5b7f. Read the comment docs.