diff --git a/src/composite/composite.jl b/src/composite/composite.jl index 901347b72..d80d19bca 100644 --- a/src/composite/composite.jl +++ b/src/composite/composite.jl @@ -16,12 +16,12 @@ YaoBase.ishermitian(m::CompositeBlock) = all(ishermitian, subblocks(m)) || isher YaoBase.isreflexive(m::CompositeBlock) = all(isreflexive, subblocks(m)) || isreflexive(mat(m)) """ - AbstractContainer{N, T} <: CompositeBlock{N, T} + AbstractContainer{BT, N, T} <: CompositeBlock{N, T} Abstract type for container block. Container blocks are blocks contain a single block. Container block should have a """ -abstract type AbstractContainer{N, T, BT <: AbstractBlock} <: CompositeBlock{N, T} end +abstract type AbstractContainer{BT <: AbstractBlock, N, T} <: CompositeBlock{N, T} end """ content(x) @@ -76,8 +76,8 @@ for METHOD in (:ishermitian, :isreflexive, :isunitary) end end -function Base.:(==)(lhs::AbstractContainer{N, T, BT}, - rhs::AbstractContainer{N, T, BT}) where {N, T, BT} +function Base.:(==)(lhs::AbstractContainer{BT, N, T}, + rhs::AbstractContainer{BT, N, T}) where {BT, N, T} return content(lhs) == content(rhs) end diff --git a/src/composite/concentrator.jl b/src/composite/concentrator.jl index 4bdf03f20..66e0c43bc 100644 --- a/src/composite/concentrator.jl +++ b/src/composite/concentrator.jl @@ -2,12 +2,12 @@ using YaoBase export Concentrator, concentrate """ - Concentrator{N, T, BT <: AbstractBlock} <: AbstractContainer{N, T} + Concentrator{N, T, BT <: AbstractBlock} <: AbstractContainer{BT, N, T} concentrates serveral lines together in the circuit, and expose it to other blocks. """ -struct Concentrator{N, T, BT <: AbstractBlock, C} <: AbstractContainer{N, T, BT} +struct Concentrator{N, T, BT <: AbstractBlock, C} <: AbstractContainer{BT, N, T} content::BT locations::NTuple{C, Int} end diff --git a/src/composite/control.jl b/src/composite/control.jl index a8a798b16..e6c0b8e65 100644 --- a/src/composite/control.jl +++ b/src/composite/control.jl @@ -3,7 +3,7 @@ using YaoArrayRegister: matvec export ControlBlock, control -struct ControlBlock{N, BT<:AbstractBlock, C, M, T} <: AbstractContainer{N, T, BT} +struct ControlBlock{N, BT<:AbstractBlock, C, M, T} <: AbstractContainer{BT, N, T} ctrl_locs::NTuple{C, Int} ctrl_config::NTuple{C, Int} content::BT diff --git a/src/composite/put_block.jl b/src/composite/put_block.jl index 3ec606cc4..281eafb2b 100644 --- a/src/composite/put_block.jl +++ b/src/composite/put_block.jl @@ -5,7 +5,7 @@ export PutBlock, put Type for putting a block at given locations. """ -struct PutBlock{N, C, T, GT <: AbstractBlock} <: AbstractContainer{N, T, GT} +struct PutBlock{N, C, T, GT <: AbstractBlock} <: AbstractContainer{GT, N, T} content::GT locs::NTuple{C, Int} diff --git a/src/composite/repeated.jl b/src/composite/repeated.jl index e356efacc..cd558b6a3 100644 --- a/src/composite/repeated.jl +++ b/src/composite/repeated.jl @@ -6,7 +6,7 @@ export RepeatedBlock, repeat Repeat the same block on given locations. """ -struct RepeatedBlock{N, C, GT <: AbstractBlock, T} <: AbstractContainer{N, T, GT} +struct RepeatedBlock{N, C, GT <: AbstractBlock, T} <: AbstractContainer{GT, N, T} content::GT locs::NTuple{C, Int} end diff --git a/src/composite/tag/cache.jl b/src/composite/tag/cache.jl index 589362c77..e80f02fad 100644 --- a/src/composite/tag/cache.jl +++ b/src/composite/tag/cache.jl @@ -38,14 +38,14 @@ CacheServers.pull(frag::CacheFragment) = frag.storage[cache_key(frag.ref)] CacheServers.clear!(frag::CacheFragment) = (empty!(frag.storage); frag) """ - CachedBlock{ST, BT, N, T} <: AbstractContainer{N, T, BT} + CachedBlock{ST, BT, N, T} <: TagBlock{BT, N, T} A label type that tags an instance of type `BT`. It forwards every methods of the block it contains, except [`mat`](@ref) and [`apply!`](@ref), it will cache the matrix form whenever the program has. """ -struct CachedBlock{ST, BT, N, T} <: TagBlock{N, T, BT} +struct CachedBlock{ST, BT, N, T} <: TagBlock{BT, N, T} server::ST content::BT level::Int diff --git a/src/composite/tag/dagger.jl b/src/composite/tag/dagger.jl index 0bf87ae77..03dd0b788 100644 --- a/src/composite/tag/dagger.jl +++ b/src/composite/tag/dagger.jl @@ -5,12 +5,12 @@ export Daggered Wrapper block allowing to execute the inverse of a block of quantum circuit. """ -struct Daggered{N, T, BT <: AbstractBlock} <: TagBlock{N, T, BT} +struct Daggered{BT <: AbstractBlock, N, T} <: TagBlock{BT, N, T} content::BT end Daggered(x::BT) where {N, T, BT<:AbstractBlock{N, T}} = - Daggered{N, T, BT}(x) + Daggered{BT, N, T}(x) PreserveStyle(::Daggered) = PreserveAll() mat(blk::Daggered) = adjoint(mat(content(blk))) diff --git a/src/composite/tag/scale.jl b/src/composite/tag/scale.jl index 51b70673f..4004bb06b 100644 --- a/src/composite/tag/scale.jl +++ b/src/composite/tag/scale.jl @@ -2,7 +2,7 @@ using LinearAlgebra export Scale -struct Scale{S <: Union{Number, Val}, N, T, BT <: AbstractBlock{N, T}} <: TagBlock{N, T, BT} +struct Scale{S <: Union{Number, Val}, N, T, BT <: AbstractBlock{N, T}} <: TagBlock{BT, N, T} alpha::S content::BT end diff --git a/src/composite/tag/tag.jl b/src/composite/tag/tag.jl index 88af563df..43e698309 100644 --- a/src/composite/tag/tag.jl +++ b/src/composite/tag/tag.jl @@ -1,12 +1,12 @@ export TagBlock """ - TagBlock{N, T} <: AbstractContainer{N, T} + TagBlock{BT, N, T} <: AbstractContainer{BT, N, T} `TagBlock` is a special kind of Container block, it forwards most of the methods but tag the block with some extra information. """ -abstract type TagBlock{N, T, BT} <: AbstractContainer{N, T, BT} end +abstract type TagBlock{BT, N, T} <: AbstractContainer{BT, N, T} end cache_key(tb::TagBlock) = cache_key(content(tb)) occupied_locs(x::TagBlock) = occupied_locs(content(x)) diff --git a/src/layout.jl b/src/layout.jl index 88fb8312d..b576c8012 100644 --- a/src/layout.jl +++ b/src/layout.jl @@ -57,7 +57,7 @@ Base.show(io::IO, ::MIME"plain/text", blk::AbstractBlock) = print_tree(io, blk) function Base.show(io::IO, ::MIME"plain/text", - blk::TagBlock{N, T, <:PrimitiveBlock}) where {N, T} + blk::TagBlock{<:PrimitiveBlock}) return print_tree(io, blk; title=false, compact=false) end