q# - 为什么我在 q# 中使用 DumpMachine 时会出现错误?
问题描述
这是我的代码:
using (q = Qubit()) {
Message("Input:");
Message("q = ∣0❭, index = 1");
Message("Requaired Output:");
Message("∣0❭: 0.707107 + 0.000000 i");
Message("∣1❭: 0.000000 + -0.707107 i");
Task12(q, 1);
Message("Your Output:");
DumpMachine();
Reset(q);
}
但我得到这个错误:
The type or namespace name '_2e502c3cdee5457783e1ea9b1f54eb1b_DumpMachine' does not exist in the namespace 'Microsoft.Quantum.Diagnostics' (are you missing an assembly reference?)
有谁知道为什么?
解决方案
你能验证你是否open Microsoft.Quantum.Diagnostics;
列出了吗?
我复制了您的代码并添加了功能,它适用于我,我使用 .NET Core 3.1 和 VisualStudio 2019,这是我的代码,我还将它添加到 GitHub https://github.com/nahidf-adventures/qsharp-adventures /tree/master/src/QbitSample:
namespace QbitSample {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Measurement;
open Microsoft.Quantum.Diagnostics;
@EntryPoint()
operation HelloQ() : Unit {
using (q = Qubit()) {
Message("Input:");
Message("q = ∣0❭, index = 1");
Message("Requaired Output:");
Message("∣0❭: 0.707107 + 0.000000 i");
Message("∣1❭: 0.000000 + -0.707107 i");
Task12(q, 1);
Message("Your Output:");
DumpMachine();
Reset(q);
}
}
operation Task12(q: Qubit, count : Int) : Unit {
}
}
推荐阅读
- reactjs - 如何使用 Array.prototype.filter() 仅删除一个实例
- python - 日期时间数据类型未在视图 FLASK 上呈现
- r - 为什么括号会破坏我的 dplyr::filter() 输出?
- python - 在 Django 中访问模型中的值
- r - 我可以有条件地将数字添加到 r 列中的某些重复值吗
- forms - 新行上的 Symfony 表单小部件
- node.js - 如何在具有背压支持的节点中快速流式传输巨大的字符串?
- javascript - 我怎样才能防止 javscript 代码被盗
- javascript - AngularJS:更改视图后检查输入状态
- database - ArangoDB 从结果中获取所有唯一标签