-
Notifications
You must be signed in to change notification settings - Fork 5
/
QiskitDriver.cs
39 lines (35 loc) · 1.23 KB
/
QiskitDriver.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using Microsoft.Quantum.Simulation.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Qiskit
{
abstract class QiskitDriver : OpenQasmDriver
{
public QiskitDriver(string key): base()
{
Key = key;
}
public string Key { get; set; }
protected override IEnumerable<Result> RunOpenQasm(StringBuilder qasm, int runs)
{
Console.WriteLine("");
Console.WriteLine("QASM file");
Console.Write(qasm.ToString());
Console.WriteLine("");
string result = QiskitExecutor.RunQasm(qasm, QBitCount, Key, Name, runs);
Console.WriteLine("Processed");
if (result.Length != QBitCount)
{
Console.WriteLine("Wrong measurement count. Offline ?");
return new List<Result>() { Result.Zero, Result.Zero, Result.Zero, Result.Zero, Result.Zero };
}
Console.WriteLine("Result=" + result);
return result.Select(c => c == '1' ? Result.One : Result.Zero)
.Reverse().ToList();
}
}
}