-
Notifications
You must be signed in to change notification settings - Fork 11
ControlBlock
should be primitive
#4
Comments
The definition of composition is Block constructed by other blocks. The reason why RotationGate is primitive is because the usually we only use XYZ block and use that as a mark, that's why it's primitive. But it's true, one can also rotate on a parametrized block, so making RotationGate a composite gate is more correct. On the other hand, if control become primitive, there'll be a large influence on printing, cache and block tree iteration. Note: the concept composition doesn't have anything to do with its methods. It's only about type. |
It should be special |
This is also the reason to make it composite, see what I replied above.
The tiny type system inside Yao is based on some basic type theory definition. This is already accurate enough: https://en.wikipedia.org/wiki/Composite_data_type The type system inside Yao for quantum operators, is just a mirror of Julia type system, and should not be different (or it will cause the library become non-idiomatic). The reason why there's nothing to do with a specific method is because we don't want to mangle type with methods, type is a separated concept. This is straight forward, well known and easy to understand.
I don't see any benefits to make this special. Making anything special will result in inconsistency, which is the original reason you mentioned in this issue. So it doesn't make any difference. If we make this special by re-writing a large amount of code to only make gate counting easier, I don't think it worth it, since you only need to define a single line to make gate counting correct: ngate(::ControlBlock) = 1 # or whatever this should be PS. the number of gates should depend on the structure of control block, if we are talking about hardware related gate counting. |
The only two primitive blocks that remains questionable are
and as for In fact, I'm specializing those |
I don't think so, like RotationGate, the file is not much longer than ControlBlock.
The major difference is the
|
I think is straight forward, and remember control gate has type parameters, you can/should dispatch it according to what's in it.
similar as above, you can just dispatch based on the type. And this could be why original
If the controlled block is a parameterized block, e.g
Again, composition is not about what methods it has. |
I would also suggest to make |
|
The example is not proper, Daggered is a type. |
apply!
of its block member.RotationGate
is primitive, for consistency, control block should also be primitive.The text was updated successfully, but these errors were encountered: