/// <summary> /// A slightly faster version to construct a colored image from 3 quantumCircuits, 1 per channel, (which should represent a colored image). /// Used after image effect are applied to the image (the circuit) to get the modified picture /// This version should produce less garbage, however, it only makes a small difference, since the python part is the same (and the slow part) /// </summary> /// <param name="redCircuit">The circuit representing the red color channel of the (modified) image.</param> /// <param name="greenCircuit">The circuit representing the green color channel of the (modified) image</param> /// <param name="blueCircuit">The circuit representing the blue color channel of the (modified) image</param> /// <param name="useLog">If logarithmic decoding should be used to decode the image.</param> /// <returns></returns> public Texture2D GetColoreTextureFast(QuantumCircuit redCircuit, QuantumCircuit greenCircuit, QuantumCircuit blueCircuit, bool useLog = false) { MicroQiskitSimulator simulator = new MicroQiskitSimulator(); //Trying optimazations (less garbage). Negative side is we need the full arrays // TODO make circuit initialization better double[] probabilities = new double[MathHelper.IntegerPower(2, redCircuit.NumberOfQubits)]; ComplexNumber[] amplitudes = null; string[] stringArray = QuantumImageHelper.CalculateNameStrings(probabilities.Length, redCircuit.NumberOfQubits); simulator.CalculateProbabilities(redCircuit, ref probabilities, ref amplitudes); IronPython.Runtime.PythonDictionary redDictionary = pythonFile.HeightFromProbabilities(stringArray, probabilities, probabilities.Length, redCircuit.DimensionString, useLog); simulator.CalculateProbabilities(greenCircuit, ref probabilities, ref amplitudes); IronPython.Runtime.PythonDictionary greenDictionary = pythonFile.HeightFromProbabilities(stringArray, probabilities, probabilities.Length, greenCircuit.DimensionString, useLog); simulator.CalculateProbabilities(blueCircuit, ref probabilities, ref amplitudes); IronPython.Runtime.PythonDictionary blueDictionary = pythonFile.HeightFromProbabilities(stringArray, probabilities, probabilities.Length, blueCircuit.DimensionString, useLog); return(QuantumImageHelper.CalculateColorTexture(redDictionary, greenDictionary, blueDictionary, redCircuit.DimensionString)); }