public override Qubit CreateQubitObject(long id)
        {
            TraceableQubit q = new TraceableQubit((int)id, traceDataSize);

            for (int j = 0; j < traceDataSize; ++j)
            {
                q.TraceData[j] = qubitTraceDataInitializers[j](id);
            }
            return(q);
        }
Пример #2
0
 /// <summary>
 /// Extracts tracing data from array of qubit with index data_id
 /// </summary>
 public static T[] ExtractTracingData <T>(IReadOnlyList <Qubit> qubits, int data_id) where T : class
 {
     Debug.Assert(qubits != null);
     T[] res = new T[qubits.Count];
     for (int i = 0; i < qubits.Count; ++i)
     {
         TraceableQubit qt = qubits[i] as TraceableQubit;
         Debug.Assert(qt != null, "Qubits are expected to have super-type TraceableQubit");
         res[i] = qt.TraceData[data_id] as T;
         Debug.Assert(res[i] != null, $"Qubits does not have data of type {typeof(T).FullName} associated to it.");
     }
     return(res);
 }
Пример #3
0
 /// <summary>
 /// Extracts tracing data from array of qubit. Goes through all types attached to the qubits and tries to find
 /// a record of type <typeparamref name="T"/>.
 /// </summary>
 public static T[] ExtractTracingData <T>(Qubit[] qubits) where T : class
 {
     Debug.Assert(qubits != null);
     T[] res = new T[qubits.Length];
     for (int i = 0; i < qubits.Length; ++i)
     {
         TraceableQubit qt = qubits[i] as TraceableQubit;
         Debug.Assert(qt != null, "Qubits are expected to have super-type TraceableQubit");
         for (int j = 0; j < qt.TraceData.Length; ++j)
         {
             res[i] = qt.TraceData[j] as T;
             if (res[i] != null)
             {
                 break;
             }
         }
         Debug.Assert(res[i] != null, $"Qubits does not have data of type {typeof(T).FullName} associated to it.");
     }
     return(res);
 }
Пример #4
0
        /// <summary>
        /// Extracts arrays of data attached to array of qubits and performs the transpose.
        /// </summary>
        public static object[][] ExtractTracingDataBulk(IReadOnlyList <Qubit> qubits, int dataIdStart, int length)
        {
            Debug.Assert(qubits != null);
            object[][] res = new object[length][];

            for (int j = 0; j < length; ++j)
            {
                res[j] = new object[qubits.Count];
            }

            for (int i = 0; i < qubits.Count; ++i)
            {
                TraceableQubit qt = qubits[i] as TraceableQubit;
                Debug.Assert(qt != null, "Qubits are expected to have super-type TraceableQubit");
                for (int j = 0; j < length; ++j)
                {
                    res[j][i] = qt.TraceData[dataIdStart + j];
                }
            }
            return(res);
        }