void CCNOTGateCountExample() { var config = new QCTraceSimulatorConfiguration(); config.UsePrimitiveOperationsCounter = true; QCTraceSimulator sim = new QCTraceSimulator(config); QVoid res; res = CCNOTDriver.Run(sim).Result; res = CCNOTDriver.Run(sim).Result; double tCount = sim.GetMetric <Intrinsic.CCNOT, CCNOTDriver>(PrimitiveOperationsGroupsNames.T); double tCountAll = sim.GetMetric <CCNOTDriver>(PrimitiveOperationsGroupsNames.T); double cxCount = sim.GetMetric <Intrinsic.CCNOT, CCNOTDriver>(PrimitiveOperationsGroupsNames.CNOT); string csvSummary = sim.ToCSV()[MetricsCountersNames.primitiveOperationsCounter]; // above code is an example used in the documentation Assert.Equal(7.0, sim.GetMetricStatistic <Intrinsic.CCNOT, CCNOTDriver>(PrimitiveOperationsGroupsNames.T, MomentsStatistic.Statistics.Average)); Assert.Equal(7.0, tCount); Assert.Equal(8.0, sim.GetMetricStatistic <CCNOTDriver>(PrimitiveOperationsGroupsNames.T, MomentsStatistic.Statistics.Average)); Assert.Equal(0.0, sim.GetMetricStatistic <CCNOTDriver>(PrimitiveOperationsGroupsNames.T, MomentsStatistic.Statistics.Variance)); Assert.Equal(8.0, tCountAll); Assert.Equal(10.0, cxCount); Debug.WriteLine(csvSummary); output.WriteLine(csvSummary); }
void CCNOTDepthCountExample() { var config = new QCTraceSimulatorConfiguration(); config.UseDepthCounter = true; config.CallStackDepthLimit = 2; QCTraceSimulator sim = new QCTraceSimulator(config); var res = CCNOTDriver.Run(sim).Result; double tDepth = sim.GetMetric <Intrinsic.CCNOT, CCNOTDriver>(MetricsNames.DepthCounter.Depth); double tDepthAll = sim.GetMetric <CCNOTDriver>(MetricsNames.DepthCounter.Depth); string csvSummary = sim.ToCSV()[MetricsCountersNames.depthCounter]; // above code is an example used in the documentation Assert.Equal(5.0, tDepth); Assert.Equal(6.0, tDepthAll); Debug.WriteLine(csvSummary); output.WriteLine(csvSummary); }