Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void MultiExpReferenceTest(
Exp_cpp(sim, 3, Paulis, angle, qubits);
// Old simulator Exp
std::vector<Gates::Basis> actualPaulis = { (Gates::Basis)Paulis[0],(Gates::Basis)Paulis[1], (Gates::Basis)Paulis[2] };
apply_exp(vector_rep, actualPaulis, angle, std::vector<unsigned>{ 0, 1, 2 });
apply_exp(vector_rep, actualPaulis, angle, std::vector<logical_qubit_id>{ (logical_qubit_id)0, (logical_qubit_id)1, (logical_qubit_id)2 });
for (size_t i = 0; i < 8; i++) {
amplitude result = getSimulator(sim)->probe(std::bitset<3>(i).to_string());
assert_amplitude_equality(vector_rep[i], result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class SparseSimulator
// Implies that the caller of this function is tracking
// free qubits
void allocate_specific_qubit(logical_qubit_id qubit) {
size_t num_qubits = _quantum_state->get_num_qubits();
logical_qubit_id num_qubits = _quantum_state->get_num_qubits();
// Checks that there are enough qubits
if (qubit >= num_qubits){
// We create a new wavefunction and reallocate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using namespace Microsoft::Quantum::SPARSESIMULATOR;
namespace SparseSimulatorTestHelpers
{

inline std::size_t make_mask(std::vector<unsigned> const& qs)
inline std::size_t make_mask(std::vector<logical_qubit_id> const& qs)
{
std::size_t mask = 0;
for (std::size_t q : qs)
Expand Down Expand Up @@ -73,11 +73,11 @@ namespace SparseSimulatorTestHelpers
std::vector<amplitude>& wfn,
std::vector<Gates::Basis> b,
double phi,
std::vector<unsigned> qs)
std::vector<logical_qubit_id> qs)
{
removeIdentities(b, qs);
if (qs.size() == 0) { return; }
unsigned lowest = *std::min_element(qs.begin(), qs.end());
logical_qubit_id lowest = *std::min_element(qs.begin(), qs.end());

std::size_t offset = 1ull << lowest;
if (isDiagonal(b))
Expand Down
2 changes: 1 addition & 1 deletion src/Simulation/Simulators/SparseSimulator/Native/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft::Quantum::SPARSESIMULATOR
using simulator_id_type = unsigned;

// Logical qubit id is visible to the clients and is immutable during the lifetime of the qubit.
using logical_qubit_id = unsigned;
using logical_qubit_id = intptr_t;

using real_type = double;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30907.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SparseSimulatorTests", "SparseSimulatorTests\SparseSimulatorTests.vcxproj", "{E1663845-BBA8-41EA-AC31-50A092EEA728}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SparseSimulator", "SparseSimulatorCS\SparseSimulator.csproj", "{1E901047-6E72-4B99-8683-A5B64D755400}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1CECBF17-34F0-41FF-BE04-88659415074A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SparseSimQSharpTests", "SparseSimQSharpTests\SparseSimQSharpTests.csproj", "{2D6F4915-A10D-4109-8B83-DA6E5C36AEA4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SparseSimQSharpTests", "SparseSimQSharpTests\SparseSimQSharpTests.csproj", "{2D6F4915-A10D-4109-8B83-DA6E5C36AEA4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -21,16 +19,6 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E1663845-BBA8-41EA-AC31-50A092EEA728}.Debug|Any CPU.ActiveCfg = Debug|Win32
{E1663845-BBA8-41EA-AC31-50A092EEA728}.Debug|x64.ActiveCfg = Debug|x64
{E1663845-BBA8-41EA-AC31-50A092EEA728}.Debug|x64.Build.0 = Debug|x64
{E1663845-BBA8-41EA-AC31-50A092EEA728}.Debug|x86.ActiveCfg = Debug|Win32
{E1663845-BBA8-41EA-AC31-50A092EEA728}.Debug|x86.Build.0 = Debug|Win32
{E1663845-BBA8-41EA-AC31-50A092EEA728}.Release|Any CPU.ActiveCfg = Release|Win32
{E1663845-BBA8-41EA-AC31-50A092EEA728}.Release|x64.ActiveCfg = Release|x64
{E1663845-BBA8-41EA-AC31-50A092EEA728}.Release|x64.Build.0 = Release|x64
{E1663845-BBA8-41EA-AC31-50A092EEA728}.Release|x86.ActiveCfg = Release|Win32
{E1663845-BBA8-41EA-AC31-50A092EEA728}.Release|x86.Build.0 = Release|Win32
{1E901047-6E72-4B99-8683-A5B64D755400}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1E901047-6E72-4B99-8683-A5B64D755400}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E901047-6E72-4B99-8683-A5B64D755400}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

namespace Microsoft.Quantum.SparseSimulation
{
using QubitIdType = System.IntPtr;
using SimulatorIdType = System.UInt32;

public partial class SparseSimulator : QuantumProcessorDispatcher, IDisposable
{
// // Converts a big integer into a string label
Expand Down Expand Up @@ -217,8 +220,9 @@ public partial class SparseSimulatorProcessor : QuantumProcessorBase {
public delegate void StringCallback(string label, double real, double img);

private delegate void DumpCallback(StringBuilder label, double real, double img);

[DllImport(simulator_dll)]
private static extern void Dump_cpp(uint sim, uint max_qubits, DumpCallback callback);
private static extern void Dump_cpp(SimulatorIdType sim, QubitIdType max_qubits, DumpCallback callback);

// This gets called by the base class
public bool Dump(StringCallback callback, int max_id, IQArray<Qubit> qubits = null)
Expand All @@ -232,20 +236,20 @@ public bool Dump(StringCallback callback, int max_id, IQArray<Qubit> qubits = n
// so if we just want the full state, it calls a different function
if (qubits == null)
{
Dump_cpp(Id, (uint)max_id, _callback);
Dump_cpp(Id, (QubitIdType)max_id, _callback);
return true;
} else
{
return DumpQubits_cpp(Id, qubits.Count(), qubits.Select(x => x.Id).ToArray(), _callback) ;
return DumpQubits_cpp(Id, qubits.Count(), qubits.Select(x => (QubitIdType)x.Id).ToArray(), _callback) ;
}
}

[DllImport(simulator_dll)]
[return: MarshalAs(UnmanagedType.I1)] // necessary because C++ and C# represent bools differently
private static extern bool DumpQubits_cpp(uint sim, int length, int[] qubit_ids, DumpCallback callback);
private static extern bool DumpQubits_cpp(SimulatorIdType sim, int length, QubitIdType[] qubit_ids, DumpCallback callback);

[DllImport(simulator_dll)]
private static extern uint num_qubits_cpp(uint sim);
private static extern QubitIdType num_qubits_cpp(SimulatorIdType sim);
}

}
Loading