q# - 你能在 Q# 中发送一个量子比特子数组作为参数吗?
问题描述
是否可以将量子比特的数组切片作为参数发送?像这样的东西:
using(q : Qubit[5]){
myOp(q[2:3]);
}
解决方案
Yes, Q# supports array slicing: https://docs.microsoft.com/en-us/quantum/quantum-qr-expressions#array-expressions. You can use Range
data type as an index to create a subarray of elements of the array indexed by elements of the range.
Your example will look like this:
using (q = Qubit[5]) {
myOp(q[2..3]);
}
推荐阅读
- python - Python Module CSV 在 CSV 文件的 writen 行之间添加一个空行
- python - 在 python 中创建带有正则表达式错误的 if/elif 语句
- javascript - 我得到了 base64 [目标文件],如何将其转换为正确的 base64 文件?
- reactjs - 无法在渲染中调用函数
- ruby-on-rails - Ajax 调用未从 ActiveRecord 返回最新数据
- android - BottomNavigationBar 在单击时不起作用
- powerbi - 确定为用户分配的角色
- python - python - 可以在不发送输入的情况下读取标准输入内容
- python - 以非 Root 用户身份在 python 中导入错误
- typescript - 打字稿如何覆盖相交的调用或构造签名