void CatStateTestCore <TCatState>(int powerOfTwo) where TCatState : AbstractCallable, ICallable <long, QVoid> { Debug.Assert(powerOfTwo > 0); double CXTime = 5; double HTime = 1; QCTraceSimulatorConfiguration traceSimCfg = new QCTraceSimulatorConfiguration(); traceSimCfg.UsePrimitiveOperationsCounter = true; traceSimCfg.UseDepthCounter = true; traceSimCfg.UseWidthCounter = true; traceSimCfg.TraceGateTimes[PrimitiveOperationsGroups.CNOT] = CXTime; traceSimCfg.TraceGateTimes[PrimitiveOperationsGroups.QubitClifford] = HTime; QCTraceSimulator traceSim = new QCTraceSimulator(traceSimCfg); output.WriteLine(string.Empty); output.WriteLine($"Starting cat state preparation on {1u << powerOfTwo} qubits"); var stopwatch = new Stopwatch(); stopwatch.Start(); traceSim.Run <TCatState, long, QVoid>(powerOfTwo).Wait(); stopwatch.Stop(); double cxCount = traceSim.GetMetric <TCatState>(PrimitiveOperationsGroupsNames.CNOT); Assert.Equal((1 << powerOfTwo) - 1, (long)cxCount); double depth = traceSim.GetMetric <TCatState>(DepthCounter.Metrics.Depth); Assert.Equal(HTime + powerOfTwo * CXTime, depth); void AssertEqualMetric(double value, string metric) { Assert.Equal(value, traceSim.GetMetric <TCatState>(metric)); } AssertEqualMetric(1u << powerOfTwo, WidthCounter.Metrics.ExtraWidth); AssertEqualMetric(0, WidthCounter.Metrics.BorrowedWith); AssertEqualMetric(0, WidthCounter.Metrics.InputWidth); AssertEqualMetric(0, WidthCounter.Metrics.ReturnWidth); output.WriteLine($"Calculation of metrics took: {stopwatch.ElapsedMilliseconds} ms"); output.WriteLine($"The depth is: {depth} given depth of CNOT was {CXTime} and depth of H was {HTime}"); output.WriteLine($"Number of CNOTs used is {cxCount}"); }