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
7 changes: 2 additions & 5 deletions src/Simulation/Common/AbstractFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

using System;
using System.Collections.Generic;
using System.Linq;

using Microsoft.Quantum.Simulation.Core;

namespace Microsoft.Quantum.Simulation.Common
{
Expand All @@ -18,8 +15,8 @@ namespace Microsoft.Quantum.Simulation.Common
/// </summary>
public abstract class AbstractFactory<T>
{
private Dictionary<Type, Type> opsOverrides = new Dictionary<Type, Type>();
private Dictionary<Type, T> opsCache = new Dictionary<Type, T>();
protected Dictionary<Type, Type> opsOverrides = new Dictionary<Type, Type>();
protected Dictionary<Type, T> opsCache = new Dictionary<Type, T>();

/// <summary>
/// Register an override for the given operation.
Expand Down
51 changes: 7 additions & 44 deletions src/Simulation/Common/QuantumProcessorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// Licensed under the MIT License.

using System;
using System.Linq;
using Microsoft.Quantum.Simulation.Core;
using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace Microsoft.Quantum.Simulation.Common
{
Expand Down Expand Up @@ -179,37 +178,16 @@ public virtual void Reset(Qubit qubit)
throw new UnsupportedOperationException();
}

public virtual long StartConditionalStatement(IQArray<Result> measurementResults, IQArray<Result> resultsValues)
public virtual long StartConditionalStatement(IQArray<Result> results1, IQArray<Result> results2)
{
if (measurementResults == null) { return 1; };
if (resultsValues == null) { return 1; };
Debug.Assert(measurementResults.Count == resultsValues.Count);
if (measurementResults.Count != resultsValues.Count) { return 1; };

int equal = 1;

for (int i = 0; i < measurementResults.Count; i++)
{
if (measurementResults[i] != resultsValues[i])
{
equal = 0;
}
}

return equal;
if (results1 == null) { return results2 == null ? 1 : 0; };
if (results1.Count != results2?.Count) { return 0; };
return results1.Zip(results2, (r1, r2) => (r1, r2)).Any(pair => pair.r1 != pair.r2) ? 0 : 1;
}

public virtual long StartConditionalStatement(Result measurementResult, Result resultValue)
public virtual long StartConditionalStatement(Result result1, Result result2)
{

if (measurementResult == resultValue)
{
return 1;
}
else
{
return 0;
}
return result1 == result2 ? 1 : 0;
}

public virtual bool RunThenClause(long statement)
Expand All @@ -234,7 +212,6 @@ public virtual bool RepeatElseClause(long statement)

public virtual void EndConditionalStatement(long id)
{

}

public virtual void Assert(IQArray<Pauli> bases, IQArray<Qubit> qubits, Result result, string msg)
Expand Down Expand Up @@ -286,18 +263,4 @@ public virtual void OnMessage(string msg)
}

}

/// <summary>
/// A class that implements exception to be thrown when Operation is not supported by a QuantumProcessor.
/// </summary>
public class UnsupportedOperationException : PlatformNotSupportedException
{
public UnsupportedOperationException(string text = "",
[CallerFilePath] string file = "",
[CallerMemberName] string member = "",
[CallerLineNumber] int line = 0)
: base($"{file}::{line}::[{member}]:{text}")
{
}
}
}
Loading