Exemplo n.º 1
0
 /// <summary>
 /// Given the body of an operation, auto-generates the (content of the) adjoint specialization,
 /// under the assumption that operation calls may only ever occur within expression statements,
 /// and while-loops cannot occur within operations.
 /// </summary>
 public static QsScope GenerateAdjoint(this QsScope scope)
 {
     // Since we are pulling purely classical statements up, we are potentially changing the order of declarations.
     // We therefore need to generate unique variable names before reordering the statements.
     scope = new UniqueVariableNames().Transform(scope);
     scope = ApplyFunctorToOperationCalls.ApplyAdjoint(scope);
     scope = new ReverseOrderOfOperationCalls().Transform(scope);
     return(StripLocationInformation.Apply(scope));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Given the body of an operation, auto-generates the (content of the) controlled specialization
 /// using the default name for control qubits.
 /// </summary>
 public static QsScope GenerateControlled(this QsScope scope)
 {
     scope = ApplyFunctorToOperationCalls.ApplyControlled(scope);
     return(StripLocationInformation.Apply(scope));
 }
 /// <summary>
 /// Given the body of an operation, auto-generates the (content of the) adjoint specialization,
 /// under the assumption that operation calls may only ever occur within expression statements,
 /// and while-loops cannot occur within operations.
 /// </summary>
 public static QsScope DistributeAdjointFunctorAndReverse(this QsScope scope)
 {
     scope = new ApplyFunctorToOperationCalls(QsFunctor.Adjoint).Transform(scope);
     scope = new ReverseOrderOfOperationCalls().Transform(scope);
     return(new StripLocationInformation().Transform(scope));
 }
        // utils for syntax tree transformations (i.e. methods that take a QsScope and return a QsScope)

        /// <summary>
        /// Given the body of an operation, auto-generates the (content of the) controlled specialization
        /// using the default name for control qubits.
        /// </summary>
        public static QsScope DistributeControlledFunctor(this QsScope scope)
        {
            scope = new ApplyFunctorToOperationCalls(QsFunctor.Controlled).Transform(scope);
            return(new StripLocationInformation().Transform(scope));
        }