이것은 내 첫 Q # 프로그램이며이 시작 링크를 따르고 있습니다. https://docs.microsoft.com/en-us/quantum/quantum-writeaquantumprogram?view=qsharp-preview퀀텀 프로그램 'BellTest'이름이 현재 컨텍스트에 존재하지 않습니다.
오류가
나는 단계를 수행하지 않습니다 . 이 작업을 찾을 수 없으므로이 오류가 보이는 것처럼 에서이름입니다 'BellTest'의 가진 오류를 구축 할 때 현재 컨텍스트 에 존재하지만 그것 Bell.cs에 정의
c# file
으로 작업을 가져 오는 방법을 모르겠습니다.
어떤 도움이 정말 여기
을 감사는Driver.cs
using Microsoft.Quantum.Simulation.Core;
using Microsoft.Quantum.Simulation.Simulators;
namespace Quantum.Bell
{
class Driver
{
static void Main(string[] args)
{
using (var sim = new QuantumSimulator())
{
// Try initial values
Result[] initials = new Result[] { Result.Zero, Result.One };
foreach (Result initial in initials)
{
var res = BellTest.Run(sim, 1000, initial).Result;
var (numZeros, numOnes) = res;
System.Console.WriteLine(
$"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4}");
}
}
System.Console.WriteLine("Press any key to continue...");
System.Console.ReadKey();
}
}
}
Bell.qs이
namespace Quantum.Bell
{
open Microsoft.Quantum.Primitive;
open Microsoft.Quantum.Canon;
operation Set (desired:Result,q1:Qubit) :()
{
body
{
let current = M(q1);
if (desired != current)
{
X(q1);
}
}
}
operation BellTest (count : Int, initial: Result) : (Int,Int)
{
body
{
mutable numOnes = 0;
using (qubits = Qubit[1])
{
for (test in 1..count)
{
Set (initial, qubits[0]);
let res = M (qubits[0]);
// Count the number of ones we saw:
if (res == One)
{
set numOnes = numOnes + 1;
}
}
Set(Zero, qubits[0]);
}
// Return number of times we saw a |0> and number of times we saw a |1>
return (count-numOnes, numOnes);
}
}
}
은 그 오류를 몇 번을 받았다 q # 코드에서 컴파일 오류가 발생했습니다. – speckledcarp