Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Trouble running first QDK Bell test #547

Closed
stanescuUW opened this issue Oct 11, 2019 · 0 comments
Closed

Trouble running first QDK Bell test #547

stanescuUW opened this issue Oct 11, 2019 · 0 comments

Comments

@stanescuUW
Copy link

After having done the steps on the "Writing first program page" my codes (macOS) look like this:

Bell.qs

namespace Quantum.Bell
{
    open Microsoft.Quantum.Canon;
    open Microsoft.Quantum.Intrinsic;

    operation Set (desired: Result, q1: Qubit) : Unit {
        if (desired != M(q1)) {
            X(q1);
        }
    }
    operation BellTest (count : Int, initial: Result) : (Int, Int) {

        mutable numOnes = 0;
        using (qubit = Qubit()) {

            for (test in 1..count) {
                Set (initial, qubit);
                let res = M (qubit);

                // Count the number of ones we saw:
                if (res == One) {
                    set numOnes += 1;
                }
            }
            Set(Zero, qubit);
        }

        // Return number of times we saw a |0> and number of times we saw a |1>
        return (count-numOnes, numOnes);
    }
}

and the Driver.cs looks like this:

using System;

using Microsoft.Quantum.Simulation.Core;
using Microsoft.Quantum.Simulation.Simulators;

namespace BellTest
{
    class Driver
    {
        static void Main(string[] args)
        {
            using (var qsim = new QuantumSimulator())
            {
                // Try initial values
                Result[] initials = new Result[] { Result.Zero, Result.One };
                foreach (Result initial in initials)
                {
                    var res = BellTest.Run(qsim, 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...");
            Console.ReadKey();
        }
    }
}

However, I get the following error messages upon running:

 Restore completed in 26.27 ms for /Users/danstanescu/Dropbox/JupyterNotebooks/MicrosoftQDK/Bell/Bell.csproj.
/Users/danstanescu/Dropbox/JupyterNotebooks/MicrosoftQDK/Bell/Driver.cs(18,31): error CS0234: The type or namespace name 'Run' does not exist in the namespace 'BellTest' (are you missing an assembly reference?) [/Users/danstanescu/Dropbox/JupyterNotebooks/MicrosoftQDK/Bell/Bell.csproj]
/Users/danstanescu/Dropbox/JupyterNotebooks/MicrosoftQDK/Bell/Driver.cs(19,26): error CS8130: Cannot infer the type of implicitly-typed deconstruction variable 'numZeros'. [/Users/danstanescu/Dropbox/JupyterNotebooks/MicrosoftQDK/Bell/Bell.csproj]
/Users/danstanescu/Dropbox/JupyterNotebooks/MicrosoftQDK/Bell/Driver.cs(19,36): error CS8130: Cannot infer the type of implicitly-typed deconstruction variable 'numOnes'. [/Users/danstanescu/Dropbox/JupyterNotebooks/MicrosoftQDK/Bell/Bell.csproj]
The terminal process terminated with exit code: 1

Any help will be greatly appreciated.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant