IronPython.Runtime.PythonDictionary getTeleportDictionaryFromData(out string heightDimensions, double[,] imageData, double[,] imageData2, double mixture, double normalization = 0, bool useLog = false) { dynamic teleportationHelper = pythonFile.TeleportationHelper("TeleportationHelper"); bool normalizeManually = normalization > 0; teleportationHelper.SetHeights(imageData, imageData2, imageData.GetLength(0), imageData.GetLength(1)); teleportationHelper.ApplySwap(mixture, useLog, normalizeManually); dynamic circuit = teleportationHelper.GetCircuit(); int numberofQubits = circuit.num_qubits; heightDimensions = circuit.name; QuantumCircuit quantumCircuit = QuantumImageHelper.ParseCircuit(circuit.data, numberofQubits); MicroQiskitSimulator simulator = new MicroQiskitSimulator(); quantumCircuit.Normalize(); double[] doubleArray = new double[0]; string[] stringArray = new string[0]; double[] probs = simulator.GetProbabilities(quantumCircuit); QuantumImageHelper.GetProbabilityArrays(probs, numberofQubits, ref doubleArray, ref stringArray); IronPython.Runtime.PythonDictionary dictionary = pythonFile.CombinedHeightFromProbabilities(stringArray, doubleArray, doubleArray.Length, numberofQubits, heightDimensions, useLog, normalization); return(dictionary); }
/// <summary> /// Constructs a quantum circuit from a double array (most likely representing (a colorchannel of) an image). /// </summary> /// <param name="imageData">The data which should be represented as a quantum circuit</param> /// <param name="useLog">If logarithmic encoding should be used for the data</param> /// <returns></returns> public QuantumCircuit GetCircuit(double[,] imageData, bool useLog = false) { //dynamic pythonHelper = PythonFile.QuantumBlurHelper("Helper"); blurHelper.SetHeights(imageData, imageData.GetLength(0), imageData.GetLength(1), useLog); dynamic circuit = blurHelper.GetCircuit(); int numberofQubits = circuit.num_qubits; return(QuantumImageHelper.ParseCircuit(circuit.data, numberofQubits, circuit.name)); }
QuantumCircuit getBlurCircuitFromData(double[,] imageData, float rotation, bool useLog = false) { blurHelper.SetHeights(imageData, imageData.GetLength(0), imageData.GetLength(1), useLog); //Applying rotation blurHelper.ApplyPartialX(rotation); dynamic circuit = blurHelper.GetCircuit(); QuantumCircuit quantumCircuit = QuantumImageHelper.ParseCircuit(circuit.data, circuit.num_qubits, circuit.name); return(quantumCircuit); }
IronPython.Runtime.PythonDictionary getBlurDictionaryFromData(out string heightDimensions, double[,] imageData, float rotation, bool useLog = false) { //dynamic pythonHelper = PythonFile.QuantumBlurHelper("Helper"); blurHelper.SetHeights(imageData, imageData.GetLength(0), imageData.GetLength(1), useLog); blurHelper.ApplyPartialX(rotation); dynamic circuit = blurHelper.GetCircuit(); int numberofQubits = circuit.num_qubits; heightDimensions = circuit.name; QuantumCircuit quantumCircuit = QuantumImageHelper.ParseCircuit(circuit.data, numberofQubits); MicroQiskitSimulator simulator = new MicroQiskitSimulator(); double[] doubleArray = new double[0]; string[] stringArray = new string[0]; QuantumImageHelper.GetProbabilityArrays(simulator.GetProbabilities(quantumCircuit), numberofQubits, ref doubleArray, ref stringArray); IronPython.Runtime.PythonDictionary dictionary = pythonFile.HeightFromProbabilities(stringArray, doubleArray, doubleArray.Length, heightDimensions, useLog); return(dictionary); }