From bd92c0260efb88067de8ca70bb7afa4020662764 Mon Sep 17 00:00:00 2001 From: sezna Date: Tue, 8 Oct 2024 13:09:47 -0700 Subject: [PATCH 1/4] Fix stdlib readmes --- library/std/src/Std/Arrays.qs | 45 +++++++++++ library/std/src/Std/Canon.qs | 18 +++++ library/std/src/Std/Convert.qs | 14 ++++ library/std/src/Std/Diagnostics.qs | 13 ++++ library/std/src/Std/Intrinsic.qs | 30 ++++++++ library/std/src/Std/Logical.qs | 1 + library/std/src/Std/Math.qs | 93 +++++++++++++++++++++++ library/std/src/Std/Measurement.qs | 7 ++ library/std/src/Std/Random.qs | 3 + library/std/src/Std/Range.qs | 5 ++ library/std/src/Std/ResourceEstimation.qs | 14 ++++ 11 files changed, 243 insertions(+) diff --git a/library/std/src/Std/Arrays.qs b/library/std/src/Std/Arrays.qs index bd099bda12..a9fdca098a 100644 --- a/library/std/src/Std/Arrays.qs +++ b/library/std/src/Std/Arrays.qs @@ -4,6 +4,7 @@ import Std.Diagnostics.*; import Std.Math.*; +/// # Summary /// # Summary /// Given an array and a predicate that is defined /// for the elements of the array, and checks if all elements of the @@ -37,6 +38,7 @@ function All<'T>(predicate : ('T -> Bool), array : 'T[]) : Bool { true } +/// # Summary /// Given an array and a predicate that is defined /// for the elements of the array, checks if at least one element of /// the array satisfies the predicate. @@ -68,6 +70,7 @@ function Any<'T>(predicate : ('T -> Bool), array : 'T[]) : Bool { false } +/// # Summary /// Splits an array into multiple parts of equal length. /// /// # Input @@ -95,6 +98,7 @@ function Chunks<'T>(chunkSize : Int, array : 'T[]) : 'T[][] { output } +/// # Summary /// Shift an array circularly left or right by a specific step size. /// /// # Type Parameters @@ -142,6 +146,7 @@ function CircularlyShifted<'T>(stepCount : Int, array : 'T[]) : 'T[] { rightPart + leftPart } +/// # Summary /// Extracts a column from a matrix. /// /// # Description @@ -178,6 +183,7 @@ function ColumnAt<'T>(column : Int, matrix : 'T[][]) : 'T[] { columnValues } +/// # Summary /// Given an array and a predicate that is defined /// for the elements of the array, returns the number of elements /// an array that consists of those elements that satisfy the predicate. @@ -210,6 +216,7 @@ function Count<'T>(predicate : ('T -> Bool), array : 'T[]) : Int { count } +/// # Summary /// Returns an array of diagonal elements of a 2-dimensional array /// /// # Description @@ -246,6 +253,7 @@ function Diagonal<'T>(matrix : 'T[][]) : 'T[] { diagonal } +/// # Summary /// Repeats an operation for a given number of samples, collecting its outputs /// in an array. /// @@ -277,6 +285,7 @@ operation DrawMany<'TInput, 'TOutput>(op : ('TInput => 'TOutput), nSamples : Int outputs } +/// # Summary /// Given an array, returns a new array containing elements of the original /// array along with the indices of each element. /// @@ -305,6 +314,7 @@ function Enumerated<'TElement>(array : 'TElement[]) : (Int, 'TElement)[] { MappedByIndex((index, element) -> (index, element), array) } +/// # Summary /// Returns an array containing the elements of another array, /// excluding elements at a given list of indices. /// @@ -346,6 +356,7 @@ function Excluding<'T>(remove : Int[], array : 'T[]) : 'T[] { output } +/// # Summary /// Given an array and a predicate that is defined /// for the elements of the array, returns an array that consists of /// those elements that satisfy the predicate. @@ -378,6 +389,7 @@ function Filtered<'T>(predicate : ('T -> Bool), array : 'T[]) : 'T[] { filtered } +/// # Summary /// Given an array and a function that maps an array element to some output /// array, returns the concatenated output arrays for each array element. /// @@ -411,6 +423,7 @@ function FlatMapped<'TInput, 'TOutput>(mapper : ('TInput -> 'TOutput[]), array : output } +/// # Summary /// Given an array of arrays, returns the concatenation of all arrays. /// /// # Type Parameters @@ -437,6 +450,7 @@ function Flattened<'T>(arrays : 'T[][]) : 'T[] { output } +/// # Summary /// Iterates a function `f` through an array `array`, returning /// `f(...f(f(initialState, array[0]), array[1]), ...)`. /// @@ -471,6 +485,7 @@ function Fold<'State, 'T>(folder : (('State, 'T) -> 'State), state : 'State, arr current } +/// # Summary /// Given an array and an operation that is defined /// for the elements of the array, returns a new array that consists /// of the images of the original array under the operation. @@ -500,6 +515,7 @@ operation ForEach<'T, 'U>(action : ('T => 'U), array : 'T[]) : 'U[] { output } +/// # Summary /// Returns the first element of the array. /// /// # Type Parameters @@ -517,6 +533,7 @@ function Head<'A>(array : 'A[]) : 'A { array[0] } +/// # Summary /// Returns a tuple of first and all remaining elements of the array. /// /// # Type Parameters @@ -533,6 +550,7 @@ function HeadAndRest<'A>(array : 'A[]) : ('A, 'A[]) { (Head(array), Rest(array)) } +/// # Summary /// Returns the first index of the first element in an array that satisfies /// a given predicate. If no such element exists, returns -1. /// @@ -561,6 +579,7 @@ function IndexOf<'T>(predicate : ('T -> Bool), array : 'T[]) : Int { -1 } +/// # Summary /// Given an array, returns a range over the indices of that array, suitable /// for use in a for loop. /// @@ -585,6 +604,7 @@ function IndexRange<'TElement>(array : 'TElement[]) : Range { 0..Length(array) - 1 } +/// # Summary /// Interleaves two arrays of (almost) same size. /// /// # Description @@ -632,6 +652,7 @@ function Interleaved<'T>(first : 'T[], second : 'T[]) : 'T[] { interleaved } +/// # Summary /// Returns true if and only if an array is empty. /// /// # Input @@ -644,6 +665,7 @@ function IsEmpty<'T>(array : 'T[]) : Bool { Length(array) == 0 } +/// # Summary /// Returns whether a 2-dimensional array has a rectangular shape /// /// # Type Parameters @@ -679,6 +701,7 @@ function IsRectangularArray<'T>(array : 'T[][]) : Bool { true } +/// # Summary /// Given an array, returns whether that array is sorted as defined by /// a given comparison function. /// @@ -710,6 +733,7 @@ function IsSorted<'T>(comparison : (('T, 'T) -> Bool), array : 'T[]) : Bool { true } +/// # Summary /// Returns whether a 2-dimensional array has a square shape /// /// # Type Parameters @@ -745,6 +769,7 @@ function IsSquareArray<'T>(array : 'T[][]) : Bool { true } +/// # Summary /// Given an array and a function that is defined /// for the elements of the array, returns a new array that consists /// of the images of the original array under the function. @@ -774,6 +799,7 @@ function Mapped<'T, 'U>(mapper : ('T -> 'U), array : 'T[]) : 'U[] { mapped } +/// # Summary /// Given an array and a function that is defined /// for the indexed elements of the array, returns a new array that consists /// of the images of the original array under the function. @@ -814,6 +840,7 @@ function MappedByIndex<'T, 'U>(mapper : ((Int, 'T) -> 'U), array : 'T[]) : 'U[] mapped } +/// # Summary /// Given a range and a function that takes an integer as input, /// returns a new array that consists /// of the images of the range values under the function. @@ -848,6 +875,7 @@ function MappedOverRange<'T>(mapper : (Int -> 'T), range : Range) : 'T[] { output } +/// # Summary /// Creates an array that is equal to an input array except that the last array /// element is dropped. /// @@ -865,6 +893,7 @@ function Most<'T>(array : 'T[]) : 'T[] { array[...Length(array) - 2] } +/// # Summary /// Returns a tuple of all but one and the last element of the array. /// /// # Type Parameters @@ -881,6 +910,7 @@ function MostAndTail<'A>(array : 'A[]) : ('A[], 'A) { (Most(array), Tail(array)) } +/// # Summary /// Returns an array padded at with specified values up to a /// specified length. /// @@ -925,6 +955,7 @@ function Padded<'T>(paddedLength : Int, defaultElement : 'T, inputArray : 'T[]) } } +/// # Summary /// Splits an array into multiple parts. /// /// # Input @@ -964,6 +995,7 @@ function Partitioned<'T>(partitionSizes : Int[], array : 'T[]) : 'T[][] { output } +/// # Summary /// Creates an array that is equal to an input array except that the first array /// element is dropped. /// @@ -981,6 +1013,7 @@ function Rest<'T>(array : 'T[]) : 'T[] { array[1...] } +/// # Summary /// Create an array that contains the same elements as an input array but in reversed /// order. /// @@ -998,6 +1031,7 @@ function Reversed<'T>(array : 'T[]) : 'T[] { array[...-1...] } +/// # Summary /// Get an array of integers in a given interval. /// /// # Input @@ -1028,6 +1062,7 @@ function SequenceI(from : Int, to : Int) : Int[] { array } +/// # Summary /// Get an array of integers in a given interval. /// /// # Input @@ -1061,6 +1096,7 @@ function SequenceL(from : BigInt, to : BigInt) : BigInt[] { array } +/// # Summary /// Given an array, returns the elements of that array sorted by a given /// comparison function. /// @@ -1110,6 +1146,7 @@ function Sorted<'T>(comparison : (('T, 'T) -> Bool), array : 'T[]) : 'T[] { ) } +/// # Summary /// Given two sorted arrays, returns a single array containing the /// elements of both in sorted order. Used internally by `Sorted`. internal function SortedMerged<'T>(comparison : (('T, 'T) -> Bool), left : 'T[], right : 'T[]) : 'T[] { @@ -1131,6 +1168,7 @@ internal function SortedMerged<'T>(comparison : (('T, 'T) -> Bool), left : 'T[], output + remainingLeft + remainingRight } +/// # Summary /// Takes an array and a list of locations and /// produces a new array formed from the elements of the original /// array that match the given locations. @@ -1168,6 +1206,7 @@ function Subarray<'T>(locations : Int[], array : 'T[]) : 'T[] { subarray } +/// # Summary /// Applies a swap of two elements in an array. /// /// # Input @@ -1194,6 +1233,7 @@ function Swapped<'T>(firstIndex : Int, secondIndex : Int, array : 'T[]) : 'T[] { w/ secondIndex <- array[firstIndex] } +/// # Summary /// Returns the transpose of a matrix represented as an array /// of arrays. /// @@ -1237,6 +1277,7 @@ function Transposed<'T>(matrix : 'T[][]) : 'T[][] { transposed } +/// # Summary /// Returns the last element of the array. /// /// # Type Parameters @@ -1255,6 +1296,7 @@ function Tail<'A>(array : 'A[]) : 'A { array[size - 1] } +/// # Summary /// Given an array of 2-tuples, returns a tuple of two arrays, each containing /// the elements of the tuples of the input array. /// @@ -1291,6 +1333,7 @@ function Unzipped<'T, 'U>(array : ('T, 'U)[]) : ('T[], 'U[]) { return (first, second); } +/// # Summary /// Given a predicate and an array, returns the indices of that /// array where the predicate is true. /// @@ -1316,6 +1359,7 @@ function Where<'T>(predicate : ('T -> Bool), array : 'T[]) : Int[] { indexes } +/// # Summary /// Returns all consecutive subarrays of length `size`. /// /// # Description @@ -1357,6 +1401,7 @@ function Windows<'T>(size : Int, array : 'T[]) : 'T[][] { windows } +/// # Summary /// Given two arrays, returns a new array of pairs such that each pair /// contains an element from each original array. /// diff --git a/library/std/src/Std/Canon.qs b/library/std/src/Std/Canon.qs index 5206adb18e..9e60ba7550 100644 --- a/library/std/src/Std/Canon.qs +++ b/library/std/src/Std/Canon.qs @@ -7,6 +7,7 @@ import Std.Intrinsic.*; import Std.Diagnostics.*; import Std.Math.*; +/// # Summary /// # Summary /// Applies an operation to each element in a register. /// @@ -32,6 +33,7 @@ operation ApplyToEach<'T>(singleElementOperation : ('T => Unit), register : 'T[] } } +/// # Summary /// # Summary /// Applies an operation to each element in a register. /// The modifier `A` indicates that the single-element operation is adjointable. @@ -61,6 +63,7 @@ operation ApplyToEachA<'T>(singleElementOperation : ('T => Unit is Adj), registe } } +/// # Summary /// # Summary /// Applies an operation to each element in a register. /// The modifier `C` indicates that the single-element operation is controllable. @@ -90,6 +93,7 @@ operation ApplyToEachC<'T>(singleElementOperation : ('T => Unit is Ctl), registe } } +/// # Summary /// # Summary /// Applies an operation to each element in a register. /// The modifier `CA` indicates that the single-element operation is controllable and adjointable. @@ -119,6 +123,7 @@ operation ApplyToEachCA<'T>(singleElementOperation : ('T => Unit is Adj + Ctl), } } +/// # Summary /// # Summary /// Applies the controlled-X (CX) gate to a pair of qubits. /// @@ -160,6 +165,7 @@ operation CX(control : Qubit, target : Qubit) : Unit is Adj + Ctl { adjoint self; } +/// # Summary /// # Summary /// Applies the controlled-Y (CY) gate to a pair of qubits. /// @@ -197,6 +203,7 @@ operation CY(control : Qubit, target : Qubit) : Unit is Adj + Ctl { adjoint self; } +/// # Summary /// # Summary /// Applies the controlled-Z (CZ) gate to a pair of qubits. /// @@ -246,6 +253,7 @@ function Snd<'T, 'U>(pair : ('T, 'U)) : 'U { return snd; } +/// # Summary /// # Summary /// Computes the parity of a register of qubits in-place. /// @@ -268,6 +276,7 @@ operation ApplyCNOTChain(qubits : Qubit[]) : Unit is Adj + Ctl { } } +/// # Summary /// # Summary /// Given a single-qubit Pauli operator, applies the corresponding operation /// to a single qubit. @@ -291,6 +300,7 @@ operation ApplyP(pauli : Pauli, target : Qubit) : Unit is Adj + Ctl { if pauli == PauliX { X(target); } elif pauli == PauliY { Y(target); } elif pauli == PauliZ { Z(target); } } +/// # Summary /// # Summary /// Given a multi-qubit Pauli operator, applies the corresponding operation /// to a quantum register. @@ -319,6 +329,7 @@ operation ApplyPauli(pauli : Pauli[], target : Qubit[]) : Unit is Adj + Ctl { } } +/// # Summary /// # Summary /// Applies a Pauli operator on each qubit in an array if the corresponding /// bit of a Boolean array matches a given input. @@ -356,6 +367,7 @@ operation ApplyPauliFromBitString(pauli : Pauli, bitApply : Bool, bits : Bool[], } } +/// # Summary /// # Summary /// Applies a Pauli operator on each qubit in an array if the corresponding /// bit of a Little-endian integer matches a given input. @@ -400,6 +412,7 @@ operation ApplyPauliFromInt( } } +/// # Summary /// # Summary /// Applies a unitary operation on the target if the control /// register state corresponds to a specified nonnegative integer. @@ -435,6 +448,7 @@ operation ApplyControlledOnInt<'T>( } } +/// # Summary /// # Summary /// Applies `oracle` on `target` when `controlRegister` /// is in the state specified by `bits`. @@ -488,6 +502,7 @@ operation ApplyControlledOnBitString<'T>( } } +/// # Summary /// # Summary /// Applies the rotations of Quantum Fourier Transform (QFT) to a little-endian quantum register. /// @@ -519,6 +534,7 @@ operation ApplyQFT(qs : Qubit[]) : Unit is Adj + Ctl { } } +/// # Summary /// # Summary /// Uses SWAP gates to reverse the order of the qubits in a register. /// @@ -532,6 +548,7 @@ operation SwapReverseRegister(register : Qubit[]) : Unit is Adj + Ctl { } } +/// # Summary /// # Summary /// Applies a bitwise-XOR operation between a classical integer and an /// integer represented by a register of qubits. @@ -558,6 +575,7 @@ operation ApplyXorInPlace(value : Int, target : Qubit[]) : Unit is Adj + Ctl { adjoint self; } +/// # Summary /// # Summary /// Applies a bitwise-XOR operation between a classical integer and an /// integer represented by a register of qubits. diff --git a/library/std/src/Std/Convert.qs b/library/std/src/Std/Convert.qs index 08d2a1568e..ec272e5aea 100644 --- a/library/std/src/Std/Convert.qs +++ b/library/std/src/Std/Convert.qs @@ -1,6 +1,7 @@ import Std.Diagnostics.*; import Std.Math.*; +/// # Summary /// # Summary /// Converts a given integer `number` to an equivalent /// double-precision floating-point number. @@ -21,11 +22,13 @@ function IntAsDouble(number : Int) : Double { body intrinsic; } +/// # Summary /// Converts a given integer `number` to an equivalent big integer. function IntAsBigInt(number : Int) : BigInt { body intrinsic; } +/// # Summary /// Converts a `Result` type to a `Bool` type, where `One` is mapped to /// `true` and `Zero` is mapped to `false`. /// @@ -39,6 +42,7 @@ function ResultAsBool(input : Result) : Bool { input == One } +/// # Summary /// Converts a `Bool` type to a `Result` type, where `true` is mapped to /// `One` and `false` is mapped to `Zero`. /// @@ -52,6 +56,7 @@ function BoolAsResult(input : Bool) : Result { if input { One } else { Zero } } +/// # Summary /// Produces a non-negative integer from a string of bits in little-endian format. /// `bits[0]` represents the least significant bit. /// @@ -72,6 +77,7 @@ function BoolArrayAsInt(bits : Bool[]) : Int { number } +/// # Summary /// Produces a binary representation of a non-negative integer, using the /// little-endian representation for the returned array. /// @@ -101,6 +107,7 @@ function IntAsBoolArray(number : Int, bits : Int) : Bool[] { result } +/// # Summary /// Converts an array of Boolean values into a non-negative BigInt, interpreting the /// array as a binary representation in little-endian format. /// @@ -126,6 +133,7 @@ function BoolArrayAsBigInt(boolArray : Bool[]) : BigInt { result } +/// # Summary /// Produces a binary representation of a non-negative BigInt, using the /// little-endian representation for the returned array. /// @@ -155,6 +163,7 @@ function BigIntAsBoolArray(number : BigInt, bits : Int) : Bool[] { result } +/// # Summary /// Produces a non-negative integer from a string of Results in little-endian format. /// /// # Input @@ -183,6 +192,7 @@ function ResultArrayAsInt(results : Result[]) : Int { number } +/// # Summary /// Converts a `Result[]` type to a `Bool[]` type, where `One` /// is mapped to `true` and `Zero` is mapped to `false`. /// @@ -201,6 +211,7 @@ function ResultArrayAsBoolArray(input : Result[]) : Bool[] { output } +/// # Summary /// Converts a `Bool[]` type to a `Result[]` type, where `true` /// is mapped to `One` and `false` is mapped to `Zero`. /// @@ -219,6 +230,7 @@ function BoolArrayAsResultArray(input : Bool[]) : Result[] { output } +/// # Summary /// Converts a complex number of type `Complex` to a complex /// number of type `ComplexPolar`. /// @@ -232,6 +244,7 @@ function ComplexAsComplexPolar(input : Complex) : ComplexPolar { return ComplexPolar(AbsComplex(input), ArgComplex(input)); } +/// # Summary /// Converts a complex number of type `ComplexPolar` to a complex /// number of type `Complex`. /// @@ -248,6 +261,7 @@ function ComplexPolarAsComplex(input : ComplexPolar) : Complex { ); } +/// # Summary /// Converts a given double-precision floating-point number to a string representation with desired precision, rounding if required. /// /// # Input diff --git a/library/std/src/Std/Diagnostics.qs b/library/std/src/Std/Diagnostics.qs index d71e87fe62..d91888552c 100644 --- a/library/std/src/Std/Diagnostics.qs +++ b/library/std/src/Std/Diagnostics.qs @@ -1,5 +1,6 @@ open QIR.Intrinsic; +/// # Summary /// # Summary /// Dumps the current target machine's status. /// @@ -29,6 +30,7 @@ function DumpMachine() : Unit { body intrinsic; } +/// # Summary /// Dumps the current target machine's status associated with the given qubits. /// /// # Input @@ -64,6 +66,7 @@ function DumpRegister(register : Qubit[]) : Unit { body intrinsic; } +/// # Summary /// # Summary /// Given an operation, dumps the matrix representation of the operation action on the given /// number of qubits. @@ -104,6 +107,7 @@ function DumpMatrix(qs : Qubit[]) : Unit { body intrinsic; } +/// # Summary /// Checks whether a qubit is in the |0⟩ state, returning true if it is. /// /// # Description @@ -125,6 +129,7 @@ operation CheckZero(qubit : Qubit) : Bool { body intrinsic; } +/// # Summary /// Checks whether all qubits in the provided array are in the |0⟩ state. Returns true if they are. /// /// # Description @@ -152,6 +157,7 @@ operation CheckAllZero(qubits : Qubit[]) : Bool { return true; } +/// # Summary /// Checks whether a given condition is true, failing with a message if it is not. /// /// # Description @@ -169,6 +175,7 @@ function Fact(actual : Bool, message : String) : Unit { } } +/// # Summary /// Given two operations, checks that they act identically for all input states. /// /// # Description @@ -225,6 +232,7 @@ operation CheckOperationsAreEqual( areEqual } +/// # Summary /// Starts counting the number of times the given operation is called. Fails if the operation is already being counted. /// /// # Description @@ -261,6 +269,7 @@ operation StartCountingOperation<'In, 'Out>(callable : 'In => 'Out) : Unit { body intrinsic; } +/// # Summary /// Stops counting the number of times the given operation is called and returns the count. Fails /// if the operation was not being counted. /// @@ -278,6 +287,7 @@ operation StopCountingOperation<'In, 'Out>(callable : 'In => 'Out) : Int { body intrinsic; } +/// # Summary /// Starts counting the number of times the given function is called. Fails if the function is already being counted. /// /// # Description @@ -305,6 +315,7 @@ operation StartCountingFunction<'In, 'Out>(callable : 'In -> 'Out) : Unit { body intrinsic; } +/// # Summary /// Stops counting the number of times the given function is called and returns the count. Fails /// if the function was not being counted. /// @@ -322,6 +333,7 @@ operation StopCountingFunction<'In, 'Out>(callable : 'In -> 'Out) : Int { body intrinsic; } +/// # Summary /// Starts counting the number of qubits allocated. Fails if qubits are already being counted. /// /// # Description @@ -344,6 +356,7 @@ operation StartCountingQubits() : Unit { body intrinsic; } +/// # Summary /// Stops counting the number of qubits allocated and returns the count. Fails if the qubits were not being counted. /// /// # Description diff --git a/library/std/src/Std/Intrinsic.qs b/library/std/src/Std/Intrinsic.qs index 03f5524ff9..d4b4727d8d 100644 --- a/library/std/src/Std/Intrinsic.qs +++ b/library/std/src/Std/Intrinsic.qs @@ -9,6 +9,7 @@ import Std.Math.*; open QIR.Intrinsic; import Std.InternalHelpers.*; +/// # Summary /// # Summary /// Applies the AND gate that is more efficient for use with decomposition of multi-controlled operations. /// Note that target qubit must be in |0⟩ state. @@ -36,6 +37,7 @@ operation AND(control1 : Qubit, control2 : Qubit, target : Qubit) : Unit is Adj } } +/// # Summary /// Applies the AND gate that is more efficient for use with decomposition of multi-controlled operations. /// Note that target qubit must be in |0⟩ state. /// @@ -54,6 +56,7 @@ operation AND(control1 : Qubit, control2 : Qubit, target : Qubit) : Unit is Adj PhaseCCX(control1, control2, target); } +/// # Summary /// Applies the doubly controlled–NOT (CCNOT) gate to three qubits. /// /// # Input @@ -79,6 +82,7 @@ operation CCNOT(control1 : Qubit, control2 : Qubit, target : Qubit) : Unit is Ad adjoint self; } +/// # Summary /// Applies the controlled-NOT (CNOT) gate to a pair of qubits. /// /// # Input @@ -116,6 +120,7 @@ operation CNOT(control : Qubit, target : Qubit) : Unit is Adj + Ctl { adjoint self; } +/// # Summary /// Applies the exponential of a multi-qubit Pauli operator. /// /// # Input @@ -179,6 +184,7 @@ operation Exp(paulis : Pauli[], theta : Double, qubits : Qubit[]) : Unit is Adj } } +/// # Summary /// Applies the Hadamard transformation to a single qubit. /// /// # Input @@ -223,6 +229,7 @@ operation H(qubit : Qubit) : Unit is Adj + Ctl { adjoint self; } +/// # Summary /// Performs the identity operation (no-op) on a single qubit. /// /// # Remarks @@ -233,6 +240,7 @@ operation I(target : Qubit) : Unit is Adj + Ctl { adjoint self; } +/// # Summary /// Performs a measurement of a single qubit in the /// Pauli _Z_ basis. /// @@ -263,6 +271,7 @@ operation M(qubit : Qubit) : Result { __quantum__qis__m__body(qubit) } +/// # Summary /// Performs a measurement of a single qubit in the /// Pauli _Z_ basis. /// @@ -293,6 +302,7 @@ operation M(qubit : Qubit) : Result { Measure([PauliZ], [qubit]) } +/// # Summary /// Performs a joint measurement of one or more qubits in the /// specified Pauli bases. /// @@ -341,6 +351,7 @@ operation Measure(bases : Pauli[], qubits : Qubit[]) : Result { } } +/// # Summary /// Performs a joint measurement of one or more qubits in the /// specified Pauli bases. /// @@ -384,6 +395,7 @@ operation Measure(bases : Pauli[], qubits : Qubit[]) : Result { __quantum__qis__mresetz__body(aux) } +/// # Summary /// Applies a rotation about the given Pauli axis. /// /// # Input @@ -419,6 +431,7 @@ operation R(pauli : Pauli, theta : Double, qubit : Qubit) : Unit is Adj + Ctl { } } +/// # Summary /// Applies a rotation about the |1⟩ state by a given angle. /// /// # Input @@ -445,6 +458,7 @@ operation R1(theta : Double, qubit : Qubit) : Unit is Adj + Ctl { R(PauliI, -theta, qubit); } +/// # Summary /// Applies a rotation about the |1⟩ state by an angle specified /// as a dyadic fraction. /// @@ -480,6 +494,7 @@ operation R1Frac(numerator : Int, power : Int, qubit : Qubit) : Unit is Adj + Ct RFrac(PauliI, numerator, power + 1, qubit); } +/// # Summary /// Given a single qubit, measures it and ensures it is in the |0⟩ state /// such that it can be safely released. /// @@ -490,6 +505,7 @@ operation Reset(qubit : Qubit) : Unit { __quantum__qis__reset__body(qubit); } +/// # Summary /// Given an array of qubits, measure them and ensure they are in the |0⟩ state /// such that they can be safely released. /// @@ -502,6 +518,7 @@ operation ResetAll(qubits : Qubit[]) : Unit { } } +/// # Summary /// Applies a rotation about the given Pauli axis by an angle specified /// as a dyadic fraction. /// @@ -542,6 +559,7 @@ operation RFrac(pauli : Pauli, numerator : Int, power : Int, qubit : Qubit) : Un R(pauli, angle, qubit); } +/// # Summary /// Applies a rotation about the _x_-axis by a given angle. /// /// # Input @@ -586,6 +604,7 @@ operation Rx(theta : Double, qubit : Qubit) : Unit is Adj + Ctl { } } +/// # Summary /// Applies the two qubit Ising _XX_ rotation gate. /// /// # Input @@ -632,6 +651,7 @@ operation Rxx(theta : Double, qubit0 : Qubit, qubit1 : Qubit) : Unit is Adj + Ct } } +/// # Summary /// Applies a rotation about the _y_-axis by a given angle. /// /// # Input @@ -676,6 +696,7 @@ operation Ry(theta : Double, qubit : Qubit) : Unit is Adj + Ctl { } } +/// # Summary /// Applies the two qubit Ising _YY_ rotation gate. /// /// # Input @@ -722,6 +743,7 @@ operation Ryy(theta : Double, qubit0 : Qubit, qubit1 : Qubit) : Unit is Adj + Ct } } +/// # Summary /// Applies a rotation about the _z_-axis by a given angle. /// /// # Input @@ -770,6 +792,7 @@ operation Rz(theta : Double, qubit : Qubit) : Unit is Adj + Ctl { } } +/// # Summary /// Applies the two qubit Ising _ZZ_ rotation gate. /// /// # Input @@ -816,6 +839,7 @@ operation Rzz(theta : Double, qubit0 : Qubit, qubit1 : Qubit) : Unit is Adj + Ct } } +/// # Summary /// Applies the π/4 phase gate to a single qubit. /// /// # Input @@ -881,6 +905,7 @@ operation S(qubit : Qubit) : Unit is Adj + Ctl { } } +/// # Summary /// Applies the SWAP gate to a pair of qubits. /// /// # Input @@ -928,6 +953,7 @@ operation SWAP(qubit1 : Qubit, qubit2 : Qubit) : Unit is Adj + Ctl { } } +/// # Summary /// Applies the π/8 gate to a single qubit. /// /// # Input @@ -983,6 +1009,7 @@ operation T(qubit : Qubit) : Unit is Adj + Ctl { } } +/// # Summary /// Applies the Pauli _X_ gate. /// /// # Input @@ -1026,6 +1053,7 @@ operation X(qubit : Qubit) : Unit is Adj + Ctl { adjoint self; } +/// # Summary /// Applies the Pauli _Y_ gate. /// /// # Input @@ -1069,6 +1097,7 @@ operation Y(qubit : Qubit) : Unit is Adj + Ctl { adjoint self; } +/// # Summary /// Applies the Pauli _Z_ gate. /// /// # Input @@ -1112,6 +1141,7 @@ operation Z(qubit : Qubit) : Unit is Adj + Ctl { adjoint self; } +/// # Summary /// Logs a message. /// /// # Input diff --git a/library/std/src/Std/Logical.qs b/library/std/src/Std/Logical.qs index 97050651cb..d1c94652ba 100644 --- a/library/std/src/Std/Logical.qs +++ b/library/std/src/Std/Logical.qs @@ -2,6 +2,7 @@ // Licensed under the MIT License. +/// # Summary /// # Summary /// Returns the boolean exclusive disjunction (eXclusive OR, XOR) /// of two input boolean values. diff --git a/library/std/src/Std/Math.qs b/library/std/src/Std/Math.qs index 9022c04e6b..6c40230f88 100644 --- a/library/std/src/Std/Math.qs +++ b/library/std/src/Std/Math.qs @@ -9,6 +9,7 @@ import Std.Diagnostics.*; // Constants PI, E, LogOf2. // +/// # Summary /// # Summary /// Returns a double-precision approximation of the /// matematical constant 𝝅 ≈ 3.14159265358979323846 @@ -27,6 +28,7 @@ function PI() : Double { 3.14159265358979323846 } +/// # Summary /// Returns a double-precision approximation of the /// mathematical constant 𝒆 ≈ 2.7182818284590452354 /// @@ -43,6 +45,7 @@ function E() : Double { 2.7182818284590452354 } +/// # Summary /// Returns a double-precision approximation of the constant /// ㏑2 ≈ 0.6931471805599453 /// @@ -59,6 +62,7 @@ function LogOf2() : Double { // Special numbers in IEEE floating-point representation // +/// # Summary /// # Summary /// Returns whether a given floating-point value is not a number (i.e. is /// NaN). @@ -73,6 +77,7 @@ function IsNaN(d : Double) : Bool { return d != d; } +/// # Summary /// Returns whether a given floating-point value is either positive or /// negative infinity. /// @@ -109,6 +114,7 @@ function IsInfinite(d : Double) : Bool { // Sign, Abs, Min, Max, etc. // +/// # Summary /// # Summary /// Returns -1, 0 or +1 that indicates the sign of a number. function SignI(a : Int) : Int { @@ -121,6 +127,7 @@ function SignI(a : Int) : Int { } } +/// # Summary /// Returns -1, 0 or +1 that indicates the sign of a number. function SignD(a : Double) : Int { if (a < 0.0) { @@ -132,6 +139,7 @@ function SignD(a : Double) : Int { } } +/// # Summary /// Returns -1, 0 or +1 that indicates the sign of a number. function SignL(a : BigInt) : Int { if (a < 0L) { @@ -143,11 +151,13 @@ function SignL(a : BigInt) : Int { } } +/// # Summary /// Returns the absolute value of an integer. function AbsI(a : Int) : Int { a < 0 ? -a | a } +/// # Summary /// Returns the absolute value of a double-precision floating-point number. function AbsD(a : Double) : Double { a < 0.0 ? -a | a @@ -157,36 +167,43 @@ function AbsL(a : BigInt) : BigInt { a < 0L ? -a | a } +/// # Summary /// Returns the larger of two specified numbers. function MaxI(a : Int, b : Int) : Int { a > b ? a | b } +/// # Summary /// Returns the larger of two specified numbers. function MaxD(a : Double, b : Double) : Double { a > b ? a | b } +/// # Summary /// Returns the larger of two specified numbers. function MaxL(a : BigInt, b : BigInt) : BigInt { a > b ? a | b } +/// # Summary /// Returns the smaller of two specified numbers. function MinI(a : Int, b : Int) : Int { a < b ? a | b } +/// # Summary /// Returns the smaller of two specified numbers. function MinD(a : Double, b : Double) : Double { a < b ? a | b } +/// # Summary /// Returns the smaller of two specified numbers. function MinL(a : BigInt, b : BigInt) : BigInt { a < b ? a | b } +/// # Summary /// Given an array of integers, returns the largest element. /// /// # Input @@ -207,6 +224,7 @@ function Max(values : Int[]) : Int { max } +/// # Summary /// Given an array of integers, returns the smallest element. /// /// # Input @@ -231,68 +249,81 @@ function Min(values : Int[]) : Int { // Trigonometric functions // +/// # Summary /// # Summary /// Returns the angle whose cosine is the specified number. function ArcCos(x : Double) : Double { body intrinsic; } +/// # Summary /// Returns the angle whose sine is the specified number. function ArcSin(y : Double) : Double { body intrinsic; } +/// # Summary /// Returns the angle whose tangent is the specified number. function ArcTan(d : Double) : Double { body intrinsic; } +/// # Summary /// Returns the angle whose tangent is the quotient of two specified numbers. function ArcTan2(y : Double, x : Double) : Double { body intrinsic; } +/// # Summary /// Returns the cosine of the specified angle. function Cos(theta : Double) : Double { body intrinsic; } +/// # Summary /// Returns the hyperbolic cosine of the specified angle. function Cosh(d : Double) : Double { body intrinsic; } +/// # Summary /// Returns the sine of the specified angle. function Sin(theta : Double) : Double { body intrinsic; } +/// # Summary /// Returns the hyperbolic sine of the specified angle. function Sinh(d : Double) : Double { body intrinsic; } +/// # Summary /// Returns the tangent of the specified angle. function Tan(d : Double) : Double { body intrinsic; } +/// # Summary /// Returns the hyperbolic tangent of the specified angle. function Tanh(d : Double) : Double { body intrinsic; } +/// # Summary /// Computes the inverse hyperbolic cosine of a number. function ArcCosh(x : Double) : Double { Log(x + Sqrt(x * x - 1.0)) } +/// # Summary /// Computes the inverse hyperbolic sine of a number. function ArcSinh(x : Double) : Double { Log(x + Sqrt(x * x + 1.0)) } +/// # Summary /// Computes the inverse hyperbolic tangent of a number. function ArcTanh(x : Double) : Double { Log((1.0 + x) / (1.0 - x)) * 0.5 @@ -302,22 +333,26 @@ function ArcTanh(x : Double) : Double { // Sqrt, Log, exp, etc. // +/// # Summary /// # Summary /// Returns the square root of a specified number. function Sqrt(d : Double) : Double { body intrinsic; } +/// # Summary /// Returns the natural (base _e_) logarithm of a specified number. function Log(input : Double) : Double { body intrinsic; } +/// # Summary /// Returns the base-10 logarithm of a specified number. function Log10(input : Double) : Double { Log(input) / Log(10.0) } +/// # Summary /// Computes the base-2 logarithm of a number. function Lg(input : Double) : Double { Log(input) / Log(2.0) @@ -327,6 +362,7 @@ function Lg(input : Double) : Double { // Truncation and Rounding // +/// # Summary /// # Summary /// Returns the integral part of a number. /// For example: Truncate(3.7) = 3; Truncate(-3.7) = -3 @@ -339,6 +375,7 @@ internal function ExtendedTruncation(value : Double) : (Int, Double, Bool) { (truncated, IntAsDouble(truncated) - value, value >= 0.0) } +/// # Summary /// Returns the smallest integer greater than or equal to the specified number. /// For example: Ceiling(3.1) = 4; Ceiling(-3.7) = -3 function Ceiling(value : Double) : Int { @@ -350,6 +387,7 @@ function Ceiling(value : Double) : Int { } } +/// # Summary /// Returns the largest integer less than or equal to the specified number. /// For example: Floor(3.7) = 3; Floor(-3.1) = -4 function Floor(value : Double) : Int { @@ -361,6 +399,7 @@ function Floor(value : Double) : Int { } } +/// # Summary /// Returns the nearest integer to the specified number. /// For example: Round(3.7) = 4; Round(-3.7) = -4 function Round(value : Double) : Int { @@ -377,17 +416,20 @@ function Round(value : Double) : Int { // Modular arithmetic // +/// # Summary /// # Summary /// Divides one Integer value by another, returns the result and the remainder as a tuple. function DivRemI(dividend : Int, divisor : Int) : (Int, Int) { (dividend / divisor, dividend % divisor) } +/// # Summary /// Divides one BigInteger value by another, returns the result and the remainder as a tuple. function DivRemL(dividend : BigInt, divisor : BigInt) : (BigInt, BigInt) { (dividend / divisor, dividend % divisor) } +/// # Summary /// Computes the canonical residue of `value` modulo `modulus`. /// The result is always in the range 0..modulus-1 even for negative numbers. function ModulusI(value : Int, modulus : Int) : Int { @@ -396,6 +438,7 @@ function ModulusI(value : Int, modulus : Int) : Int { (r < 0) ? (r + modulus) | r } +/// # Summary /// Computes the canonical residue of `value` modulo `modulus`. /// The result is always in the range 0..modulus-1 even for negative numbers. function ModulusL(value : BigInt, modulus : BigInt) : BigInt { @@ -404,6 +447,7 @@ function ModulusL(value : BigInt, modulus : BigInt) : BigInt { (r < 0L) ? (r + modulus) | r } +/// # Summary /// Returns an integer raised to a given power, with respect to a given /// modulus. I.e. (expBase^power) % modulus. function ExpModI(expBase : Int, power : Int, modulus : Int) : Int { @@ -434,6 +478,7 @@ function ExpModI(expBase : Int, power : Int, modulus : Int) : Int { res } +/// # Summary /// Returns an integer raised to a given power, with respect to a given /// modulus. I.e. (expBase^power) % modulus. function ExpModL(expBase : BigInt, power : BigInt, modulus : BigInt) : BigInt { @@ -464,6 +509,7 @@ function ExpModL(expBase : BigInt, power : BigInt, modulus : BigInt) : BigInt { res } +/// # Summary /// Returns the multiplicative inverse of a modular integer. /// /// # Description @@ -476,6 +522,7 @@ function InverseModI(a : Int, modulus : Int) : Int { ModulusI(u, modulus) } +/// # Summary /// Returns the multiplicative inverse of a modular integer. /// /// # Description @@ -492,6 +539,7 @@ function InverseModL(a : BigInt, modulus : BigInt) : BigInt { // GCD, etc. // +/// # Summary /// # Summary /// Computes the greatest common divisor of two integers. /// Note: GCD is always positive except that GCD(0,0)=0. @@ -506,6 +554,7 @@ function GreatestCommonDivisorI(a : Int, b : Int) : Int { aa } +/// # Summary /// Computes the greatest common divisor of two integers. /// Note: GCD is always positive except that GCD(0,0)=0. function GreatestCommonDivisorL(a : BigInt, b : BigInt) : BigInt { @@ -519,6 +568,7 @@ function GreatestCommonDivisorL(a : BigInt, b : BigInt) : BigInt { aa } +/// # Summary /// Returns a tuple (u,v) such that u*a+v*b=GCD(a,b) /// Note: GCD is always positive except that GCD(0,0)=0. function ExtendedGreatestCommonDivisorI(a : Int, b : Int) : (Int, Int) { @@ -538,6 +588,7 @@ function ExtendedGreatestCommonDivisorI(a : Int, b : Int) : (Int, Int) { (s1 * signA, t1 * signB) } +/// # Summary /// Returns a tuple (u,v) such that u*a+v*b=GCD(a,b) /// Note: GCD is always positive except that GCD(0,0)=0. function ExtendedGreatestCommonDivisorL(a : BigInt, b : BigInt) : (BigInt, BigInt) { @@ -557,6 +608,7 @@ function ExtendedGreatestCommonDivisorL(a : BigInt, b : BigInt) : (BigInt, BigIn (s1 * signA, t1 * signB) } +/// # Summary /// Returns if two integers are co-prime. /// /// # Description @@ -575,6 +627,7 @@ function IsCoprimeI(a : Int, b : Int) : Bool { GreatestCommonDivisorI(a, b) == 1 } +/// # Summary /// Returns if two integers are co-prime. /// /// # Description @@ -593,6 +646,7 @@ function IsCoprimeL(a : BigInt, b : BigInt) : Bool { GreatestCommonDivisorL(a, b) == 1L } +/// # Summary /// Finds the continued fraction convergent closest to `fraction` /// with the denominator less or equal to `denominatorBound` /// Using process similar to this: https://nrich.maths.org/1397 @@ -623,6 +677,7 @@ function ContinuedFractionConvergentI( } } +/// # Summary /// Finds the continued fraction convergent closest to `fraction` /// with the denominator less or equal to `denominatorBound` /// Using process similar to this: https://nrich.maths.org/1397 @@ -653,6 +708,7 @@ function ContinuedFractionConvergentL( } } +/// # Summary /// Computes the modulus between two real numbers. /// /// # Input @@ -681,6 +737,7 @@ function RealMod(value : Double, modulo : Double, minValue : Double) : Double { // Binary, bits, etc. // +/// # Summary /// # Summary /// For a non-negative integer `a`, returns the number of bits required to represent `a`. /// NOTE: This function returns the smallest n such that a < 2^n. @@ -696,6 +753,7 @@ function BitSizeI(a : Int) : Int { size } +/// # Summary /// For a non-negative integer `a`, returns the number of bits required to represent `a`. /// NOTE: This function returns the smallest n such that a < 2^n. function BitSizeL(a : BigInt) : Int { @@ -710,6 +768,7 @@ function BitSizeL(a : BigInt) : Int { size } +/// # Summary /// For a non-zero integer `a`, returns the number of trailing zero bits /// in the binary representation of `a`. function TrailingZeroCountI(a : Int) : Int { @@ -725,6 +784,7 @@ function TrailingZeroCountI(a : Int) : Int { count } +/// # Summary /// For a non-zero integer `a`, returns the number of trailing zero bits /// in the binary representation of `a`. function TrailingZeroCountL(a : BigInt) : Int { @@ -740,6 +800,7 @@ function TrailingZeroCountL(a : BigInt) : Int { count } +/// # Summary /// Returns the number of 1 bits in the binary representation of integer `n`. function HammingWeightI(n : Int) : Int { let i1 = n - ((n >>> 1) &&& 0x5555555555555555); @@ -752,6 +813,7 @@ function HammingWeightI(n : Int) : Int { // Combinatorics // +/// # Summary /// # Summary /// Returns the factorial of a given number. /// @@ -800,6 +862,7 @@ function FactorialI(n : Int) : Int { ][n] } +/// # Summary /// Returns the factorial of a given number. /// /// # Input @@ -822,6 +885,7 @@ function FactorialL(n : Int) : BigInt { result } +/// # Summary /// Returns an approximate factorial of a given number. /// /// # Description @@ -859,6 +923,7 @@ function ApproximateFactorial(n : Int) : Double { a * b * c } +/// # Summary /// Returns the natural logarithm of the gamma function (aka the log-gamma /// function). /// @@ -910,6 +975,7 @@ function LogGammaD(x : Double) : Double { Log(2.506628274631000 * acc / x) + ((x + 0.5) * Log(tmp) - tmp) } +/// # Summary /// Returns the approximate natural logarithm of the factorial of a given /// integer. /// @@ -928,6 +994,7 @@ function LogFactorialD(n : Int) : Double { LogGammaD(IntAsDouble(n) + 1.0) } +/// # Summary /// Returns the approximate binomial coefficient of two integers. /// /// # Description @@ -955,6 +1022,7 @@ function Binom(n : Int, k : Int) : Int { // Norms // +/// # Summary /// # Summary /// Returns the squared 2-norm of a vector. /// @@ -977,6 +1045,7 @@ function SquaredNorm(array : Double[]) : Double { sum } +/// # Summary /// Returns the `L(p)` norm of a vector of `Double`s. /// /// That is, given an array x of type `Double[]`, this returns the p-norm @@ -1001,6 +1070,7 @@ function PNorm(p : Double, array : Double[]) : Double { sum^(1.0 / p) } +/// # Summary /// Normalizes a vector of `Double`s in the `L(p)` norm. /// /// That is, given an array x of type `Double[]`, this returns an array where @@ -1034,6 +1104,7 @@ function PNormalized(p : Double, array : Double[]) : Double[] { // Complex numbers // +/// # Summary /// # Summary /// Represents a complex number by its real and imaginary components. /// The first element of the tuple is the real component, @@ -1046,6 +1117,7 @@ function PNormalized(p : Double, array : Double[]) : Double[] { /// ``` struct Complex { Real : Double, Imag : Double } +/// # Summary /// Represents a complex number in polar form. /// The polar representation of a complex number is c = r⋅𝑒^(t𝑖). /// @@ -1056,6 +1128,7 @@ struct Complex { Real : Double, Imag : Double } /// The phase t ∈ ℝ of c. struct ComplexPolar { Magnitude : Double, Argument : Double } +/// # Summary /// Returns the squared absolute value of a complex number of type /// `Complex`. /// @@ -1069,6 +1142,7 @@ function AbsSquaredComplex(input : Complex) : Double { input.Real * input.Real + input.Imag * input.Imag } +/// # Summary /// Returns the absolute value of a complex number of type /// `Complex`. /// @@ -1082,6 +1156,7 @@ function AbsComplex(input : Complex) : Double { Sqrt(AbsSquaredComplex(input)) } +/// # Summary /// Returns the phase of a complex number of type /// `Complex`. /// @@ -1095,6 +1170,7 @@ function ArgComplex(input : Complex) : Double { ArcTan2(input.Imag, input.Real) } +/// # Summary /// Returns the squared absolute value of a complex number of type /// `ComplexPolar`. /// @@ -1108,6 +1184,7 @@ function AbsSquaredComplexPolar(input : ComplexPolar) : Double { input.Magnitude * input.Magnitude } +/// # Summary /// Returns the absolute value of a complex number of type /// `ComplexPolar`. /// @@ -1119,6 +1196,7 @@ function AbsSquaredComplexPolar(input : ComplexPolar) : Double { /// Absolute value |c| = r. function AbsComplexPolar(input : ComplexPolar) : Double { input.Magnitude } +/// # Summary /// Returns the phase of a complex number of type `ComplexPolar`. /// /// # Input @@ -1129,6 +1207,7 @@ function AbsComplexPolar(input : ComplexPolar) : Double { input.Magnitude } /// Phase Arg(c) = t. function ArgComplexPolar(input : ComplexPolar) : Double { input.Argument } +/// # Summary /// Returns the unary negation of an input of type `Complex`. /// /// # Input @@ -1141,6 +1220,7 @@ function NegationC(input : Complex) : Complex { Complex(-input.Real, -input.Imag) } +/// # Summary /// Returns the unary negation of an input of type `ComplexPolar` /// /// # Input @@ -1153,6 +1233,7 @@ function NegationCP(input : ComplexPolar) : ComplexPolar { ComplexPolar(input.Magnitude, input.Argument + PI()) } +/// # Summary /// Returns the sum of two inputs of type `Complex`. /// /// # Input @@ -1167,6 +1248,7 @@ function PlusC(a : Complex, b : Complex) : Complex { Complex(a.Real + b.Real, a.Imag + b.Imag) } +/// # Summary /// Returns the sum of two inputs of type `ComplexPolar`. /// /// # Input @@ -1186,6 +1268,7 @@ function PlusCP(a : ComplexPolar, b : ComplexPolar) : ComplexPolar { ) } +/// # Summary /// Returns the difference between two inputs of type `Complex`. /// /// # Input @@ -1200,6 +1283,7 @@ function MinusC(a : Complex, b : Complex) : Complex { Complex(a.Real - b.Real, a.Imag - b.Imag) } +/// # Summary /// Returns the difference between two inputs of type `ComplexPolar`. /// /// # Input @@ -1214,6 +1298,7 @@ function MinusCP(a : ComplexPolar, b : ComplexPolar) : ComplexPolar { PlusCP(a, NegationCP(b)) } +/// # Summary /// Returns the product of two inputs of type `Complex`. /// /// # Input @@ -1231,6 +1316,7 @@ function TimesC(a : Complex, b : Complex) : Complex { ) } +/// # Summary /// Returns the product of two inputs of type `ComplexPolar`. /// /// # Input @@ -1248,6 +1334,7 @@ function TimesCP(a : ComplexPolar, b : ComplexPolar) : ComplexPolar { ) } +/// # Summary /// Internal. Since it is easiest to define the power of two complex numbers /// in Cartesian form as returning in polar form, we define that here, then /// convert as needed. @@ -1274,6 +1361,7 @@ internal function PowCAsCP(base : Complex, power : Complex) : ComplexPolar { ComplexPolar(magnitude, angle) } +/// # Summary /// Returns a number raised to a given power of type `Complex`. /// Note that this is a multi-valued function, but only one value is returned. /// @@ -1289,6 +1377,7 @@ function PowC(a : Complex, power : Complex) : Complex { ComplexPolarAsComplex(PowCAsCP(a, power)) } +/// # Summary /// Returns a number raised to a given power of type `ComplexPolar`. /// Note that this is a multi-valued function, but only one value is returned. /// @@ -1304,6 +1393,7 @@ function PowCP(a : ComplexPolar, power : ComplexPolar) : ComplexPolar { PowCAsCP(ComplexPolarAsComplex(a), ComplexPolarAsComplex(power)) } +/// # Summary /// Returns the quotient of two inputs of type `Complex`. /// /// # Input @@ -1322,6 +1412,7 @@ function DividedByC(a : Complex, b : Complex) : Complex { ) } +/// # Summary /// Returns the quotient of two inputs of type `ComplexPolar`. /// /// # Input @@ -1340,6 +1431,7 @@ function DividedByCP(a : ComplexPolar, b : ComplexPolar) : ComplexPolar { // Fixed point // +/// # Summary /// # Summary /// Returns the smallest representable number for specific fixed point dimensions. /// @@ -1355,6 +1447,7 @@ function SmallestFixedPoint(integerBits : Int, fractionalBits : Int) : Double { -(2.0^IntAsDouble(integerBits - 1)) } +/// # Summary /// Returns the largest representable number for specific fixed point dimensions. /// /// # Input diff --git a/library/std/src/Std/Measurement.qs b/library/std/src/Std/Measurement.qs index 2b538d8554..9a05add623 100644 --- a/library/std/src/Std/Measurement.qs +++ b/library/std/src/Std/Measurement.qs @@ -7,6 +7,7 @@ import Std.Intrinsic.*; import Std.Diagnostics.*; open QIR.Intrinsic; +/// # Summary /// # Summary /// Jointly measures a register of qubits in the Pauli Z basis. /// @@ -29,6 +30,7 @@ operation MeasureAllZ(register : Qubit[]) : Result { Measure(Repeated(PauliZ, Length(register)), register) } +/// # Summary /// Measures each qubit in a given array in the standard basis. /// /// # Description @@ -63,6 +65,7 @@ operation MeasureEachZ(register : Qubit[]) : Result[] { results } +/// # Summary /// Measures each qubit in a given array in the Z basis /// and resets them to a fixed initial state. /// @@ -83,6 +86,7 @@ operation MResetEachZ(register : Qubit[]) : Result[] { results } +/// # Summary /// Measures a single qubit in the X basis, /// and resets it to a fixed initial state /// following the measurement. @@ -105,6 +109,7 @@ operation MResetX(target : Qubit) : Result { MResetZ(target) } +/// # Summary /// Measures a single qubit in the Y basis, /// and resets it to a fixed initial state /// following the measurement. @@ -129,6 +134,7 @@ operation MResetY(target : Qubit) : Result { MResetZ(target) } +/// # Summary /// Measures a single qubit in the Z basis, /// and resets it to a fixed initial state /// following the measurement. @@ -148,6 +154,7 @@ operation MResetZ(target : Qubit) : Result { __quantum__qis__mresetz__body(target) } +/// # Summary /// Measures the content of a quantum register and converts /// it to an integer. The measurement is performed with respect /// to the standard computational basis, i.e., the eigenbasis of `PauliZ`. diff --git a/library/std/src/Std/Random.qs b/library/std/src/Std/Random.qs index e1007dbe5d..835fff69f8 100644 --- a/library/std/src/Std/Random.qs +++ b/library/std/src/Std/Random.qs @@ -3,6 +3,7 @@ +/// # Summary /// # Summary /// Draws a random integer from a uniform distribution /// in a given inclusive range. Fails if `max < min`. @@ -27,6 +28,7 @@ operation DrawRandomInt(min : Int, max : Int) : Int { body intrinsic; } +/// # Summary /// Draws a random real number from a uniform distribution /// in a given inclusive interval. Fails if `max < min`. /// @@ -50,6 +52,7 @@ operation DrawRandomDouble(min : Double, max : Double) : Double { body intrinsic; } +/// # Summary /// Given a success probability, returns a single Bernoulli trial /// that is true with the given probability. /// diff --git a/library/std/src/Std/Range.qs b/library/std/src/Std/Range.qs index efd98518ce..96918438b8 100644 --- a/library/std/src/Std/Range.qs +++ b/library/std/src/Std/Range.qs @@ -2,6 +2,7 @@ // Licensed under the MIT License. +/// # Summary /// # Summary /// Returns the defined start value of the given range. /// @@ -26,6 +27,7 @@ /// ``` function RangeStart(r : Range) : Int { r.Start } +/// # Summary /// # Summary /// Returns the defined end value of the given range, /// which is not necessarily the last element in the sequence. @@ -47,6 +49,7 @@ function RangeStart(r : Range) : Int { r.Start } function RangeEnd(r : Range) : Int { r.End } +/// # Summary /// # Summary /// Returns the integer that specifies how the next value of a range is calculated. /// @@ -63,6 +66,7 @@ function RangeEnd(r : Range) : Int { r.End } /// until `end` is passed. function RangeStep(r : Range) : Int { r.Step } +/// # Summary /// # Summary /// Returns a new range which is the reverse of the input range. /// @@ -81,6 +85,7 @@ function RangeReverse(r : Range) : Range { start..-r.Step..r.Start } +/// # Summary /// # Summary /// Returns true if and only if the input range is empty. /// diff --git a/library/std/src/Std/ResourceEstimation.qs b/library/std/src/Std/ResourceEstimation.qs index f0da84c88e..600f484425 100644 --- a/library/std/src/Std/ResourceEstimation.qs +++ b/library/std/src/Std/ResourceEstimation.qs @@ -8,6 +8,7 @@ // is only available when using resource estimator execution target. `BeginCostCaching` // and `EndCostCaching` are not defined for other execution targets. +/// # Summary /// # Summary /// Used to specify that there's only one execution variant in `BeginEstimateCaching` /// function @@ -15,6 +16,7 @@ function SingleVariant() : Int { return 0; } +/// # Summary /// Informs the resource estimator of the start of the code fragment /// for which estimates caching can be done. This function /// is only available when using resource estimator execution target. @@ -36,6 +38,7 @@ function BeginEstimateCaching(name : String, variant : Int) : Bool { body intrinsic; } +/// # Summary /// Instructs the resource estimator to stop estimates caching /// because the code fragment in consideration is over. This function /// is only available when using resource estimator execution target. @@ -49,6 +52,7 @@ function EndEstimateCaching() : Unit { // This functionality is only available when using resource estimator execution target. // `AccountForEstimates' is not defined for other execution targets. +/// # Summary /// # Summary /// Returns a tuple that can be passed to the `AccountForEstimates` operation /// to specify that the number of auxiliary qubits is equal to the `amount`. @@ -56,36 +60,42 @@ function AuxQubitCount(amount : Int) : (Int, Int) { return (0, amount); } +/// # Summary /// Returns a tuple that can be passed to the `AccountForEstimates` operation /// to specify that the number of the T gates is equal to the `amount`. function TCount(amount : Int) : (Int, Int) { return (1, amount); } +/// # Summary /// Returns a tuple that can be passed to the `AccountForEstimates` operation /// to specify that the number of rotations is equal to the `amount`. function RotationCount(amount : Int) : (Int, Int) { return (2, amount); } +/// # Summary /// Returns a tuple that can be passed to the `AccountForEstimates` operation /// to specify that the rotation depth is equal to the `amount`. function RotationDepth(amount : Int) : (Int, Int) { return (3, amount); } +/// # Summary /// Returns a tuple that can be passed to the `AccountForEstimates` operation /// to specify that the number of the CCZ gates is equal to the `amount`. function CczCount(amount : Int) : (Int, Int) { return (4, amount); } +/// # Summary /// Returns a tuple that can be passed to the `AccountForEstimates` operation /// to specify that the number Measurements is equal to the `amount`. function MeasurementCount(amount : Int) : (Int, Int) { return (5, amount); } +/// # Summary /// Pass the value returned by the function to the `AccountForEstimates` operation /// to indicate Parallel Synthesis Sequential Pauli Computation (PSSPC) layout. /// See https://arxiv.org/pdf/2211.07629.pdf for details. @@ -93,6 +103,7 @@ function PSSPCLayout() : Int { return 1; } +/// # Summary /// Account for the resource estimates of an unimplemented operation, /// which were obtained separately. This operation is only available /// when using resource estimator execution target. @@ -117,6 +128,7 @@ internal operation AccountForEstimatesInternal(estimates : (Int, Int)[], layout body intrinsic; } +/// # Summary /// Instructs the resource estimator to assume that the resources from the /// call of this operation until a call to `EndRepeatEstimates` are /// accounted for `count` times, without the need to execute the code that many @@ -138,6 +150,7 @@ internal operation BeginRepeatEstimatesInternal(count : Int) : Unit { body intrinsic; } +/// # Summary /// Companion operation to `BeginRepeatEstimates`. operation EndRepeatEstimates() : Unit { body ... { @@ -150,6 +163,7 @@ internal operation EndRepeatEstimatesInternal() : Unit { body intrinsic; } +/// # Summary /// Instructs the resource estimator to assume that the resources from the /// call of this operation until a call to `Adjoint RepeatEstimates` are /// accounted for `count` times, without the need to execute the code that many From 67dba5ea76ec919cbbf69b586e2890d2a59fcd96 Mon Sep 17 00:00:00 2001 From: sezna Date: Tue, 8 Oct 2024 13:33:48 -0700 Subject: [PATCH 2/4] update expects --- compiler/qsc_partial_eval/src/tests/misc.rs | 2 +- vscode/test/suites/debugger/debugger.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/qsc_partial_eval/src/tests/misc.rs b/compiler/qsc_partial_eval/src/tests/misc.rs index 3fdb33df0a..2d50a45edf 100644 --- a/compiler/qsc_partial_eval/src/tests/misc.rs +++ b/compiler/qsc_partial_eval/src/tests/misc.rs @@ -602,5 +602,5 @@ fn evaluation_error_within_stdlib_yield_correct_package_span() { } "#, }); - assert_error(&error, &expect!["UnexpectedDynamicValue(PackageSpan { package: PackageId(1), span: Span { lo: 13654, hi: 13669 } })"]); + assert_error(&error, &expect!["UnexpectedDynamicValue(PackageSpan { package: PackageId(1), span: Span { lo: 13864, hi: 13879 } })"]); } diff --git a/vscode/test/suites/debugger/debugger.test.ts b/vscode/test/suites/debugger/debugger.test.ts index f88bb0b87a..3c70235134 100644 --- a/vscode/test/suites/debugger/debugger.test.ts +++ b/vscode/test/suites/debugger/debugger.test.ts @@ -375,10 +375,10 @@ suite("Q# Debugger Tests", function suite() { sourceReference: 0, adapterData: "qsharp-adapter-data", }, - line: 201, + line: 207, column: 9, name: "H ", - endLine: 201, + endLine: 207, endColumn: 40, }, { From 69b55ecdcc783fcb9540843cbc78070ed45de204 Mon Sep 17 00:00:00 2001 From: sezna Date: Tue, 8 Oct 2024 13:41:15 -0700 Subject: [PATCH 3/4] remove doubled up summaries --- library/std/src/Std/Arrays.qs | 1 - library/std/src/Std/Canon.qs | 18 ------------------ library/std/src/Std/Convert.qs | 1 - library/std/src/Std/Diagnostics.qs | 2 -- library/std/src/Std/Intrinsic.qs | 1 - library/std/src/Std/Logical.qs | 1 - library/std/src/Std/Math.qs | 13 ------------- library/std/src/Std/Measurement.qs | 1 - library/std/src/Std/Random.qs | 1 - library/std/src/Std/Range.qs | 5 ----- library/std/src/Std/ResourceEstimation.qs | 2 -- 11 files changed, 46 deletions(-) diff --git a/library/std/src/Std/Arrays.qs b/library/std/src/Std/Arrays.qs index a9fdca098a..ff577e0ff3 100644 --- a/library/std/src/Std/Arrays.qs +++ b/library/std/src/Std/Arrays.qs @@ -4,7 +4,6 @@ import Std.Diagnostics.*; import Std.Math.*; -/// # Summary /// # Summary /// Given an array and a predicate that is defined /// for the elements of the array, and checks if all elements of the diff --git a/library/std/src/Std/Canon.qs b/library/std/src/Std/Canon.qs index 9e60ba7550..5206adb18e 100644 --- a/library/std/src/Std/Canon.qs +++ b/library/std/src/Std/Canon.qs @@ -7,7 +7,6 @@ import Std.Intrinsic.*; import Std.Diagnostics.*; import Std.Math.*; -/// # Summary /// # Summary /// Applies an operation to each element in a register. /// @@ -33,7 +32,6 @@ operation ApplyToEach<'T>(singleElementOperation : ('T => Unit), register : 'T[] } } -/// # Summary /// # Summary /// Applies an operation to each element in a register. /// The modifier `A` indicates that the single-element operation is adjointable. @@ -63,7 +61,6 @@ operation ApplyToEachA<'T>(singleElementOperation : ('T => Unit is Adj), registe } } -/// # Summary /// # Summary /// Applies an operation to each element in a register. /// The modifier `C` indicates that the single-element operation is controllable. @@ -93,7 +90,6 @@ operation ApplyToEachC<'T>(singleElementOperation : ('T => Unit is Ctl), registe } } -/// # Summary /// # Summary /// Applies an operation to each element in a register. /// The modifier `CA` indicates that the single-element operation is controllable and adjointable. @@ -123,7 +119,6 @@ operation ApplyToEachCA<'T>(singleElementOperation : ('T => Unit is Adj + Ctl), } } -/// # Summary /// # Summary /// Applies the controlled-X (CX) gate to a pair of qubits. /// @@ -165,7 +160,6 @@ operation CX(control : Qubit, target : Qubit) : Unit is Adj + Ctl { adjoint self; } -/// # Summary /// # Summary /// Applies the controlled-Y (CY) gate to a pair of qubits. /// @@ -203,7 +197,6 @@ operation CY(control : Qubit, target : Qubit) : Unit is Adj + Ctl { adjoint self; } -/// # Summary /// # Summary /// Applies the controlled-Z (CZ) gate to a pair of qubits. /// @@ -253,7 +246,6 @@ function Snd<'T, 'U>(pair : ('T, 'U)) : 'U { return snd; } -/// # Summary /// # Summary /// Computes the parity of a register of qubits in-place. /// @@ -276,7 +268,6 @@ operation ApplyCNOTChain(qubits : Qubit[]) : Unit is Adj + Ctl { } } -/// # Summary /// # Summary /// Given a single-qubit Pauli operator, applies the corresponding operation /// to a single qubit. @@ -300,7 +291,6 @@ operation ApplyP(pauli : Pauli, target : Qubit) : Unit is Adj + Ctl { if pauli == PauliX { X(target); } elif pauli == PauliY { Y(target); } elif pauli == PauliZ { Z(target); } } -/// # Summary /// # Summary /// Given a multi-qubit Pauli operator, applies the corresponding operation /// to a quantum register. @@ -329,7 +319,6 @@ operation ApplyPauli(pauli : Pauli[], target : Qubit[]) : Unit is Adj + Ctl { } } -/// # Summary /// # Summary /// Applies a Pauli operator on each qubit in an array if the corresponding /// bit of a Boolean array matches a given input. @@ -367,7 +356,6 @@ operation ApplyPauliFromBitString(pauli : Pauli, bitApply : Bool, bits : Bool[], } } -/// # Summary /// # Summary /// Applies a Pauli operator on each qubit in an array if the corresponding /// bit of a Little-endian integer matches a given input. @@ -412,7 +400,6 @@ operation ApplyPauliFromInt( } } -/// # Summary /// # Summary /// Applies a unitary operation on the target if the control /// register state corresponds to a specified nonnegative integer. @@ -448,7 +435,6 @@ operation ApplyControlledOnInt<'T>( } } -/// # Summary /// # Summary /// Applies `oracle` on `target` when `controlRegister` /// is in the state specified by `bits`. @@ -502,7 +488,6 @@ operation ApplyControlledOnBitString<'T>( } } -/// # Summary /// # Summary /// Applies the rotations of Quantum Fourier Transform (QFT) to a little-endian quantum register. /// @@ -534,7 +519,6 @@ operation ApplyQFT(qs : Qubit[]) : Unit is Adj + Ctl { } } -/// # Summary /// # Summary /// Uses SWAP gates to reverse the order of the qubits in a register. /// @@ -548,7 +532,6 @@ operation SwapReverseRegister(register : Qubit[]) : Unit is Adj + Ctl { } } -/// # Summary /// # Summary /// Applies a bitwise-XOR operation between a classical integer and an /// integer represented by a register of qubits. @@ -575,7 +558,6 @@ operation ApplyXorInPlace(value : Int, target : Qubit[]) : Unit is Adj + Ctl { adjoint self; } -/// # Summary /// # Summary /// Applies a bitwise-XOR operation between a classical integer and an /// integer represented by a register of qubits. diff --git a/library/std/src/Std/Convert.qs b/library/std/src/Std/Convert.qs index ec272e5aea..58d8953f9f 100644 --- a/library/std/src/Std/Convert.qs +++ b/library/std/src/Std/Convert.qs @@ -1,7 +1,6 @@ import Std.Diagnostics.*; import Std.Math.*; -/// # Summary /// # Summary /// Converts a given integer `number` to an equivalent /// double-precision floating-point number. diff --git a/library/std/src/Std/Diagnostics.qs b/library/std/src/Std/Diagnostics.qs index d91888552c..5f7d4894fa 100644 --- a/library/std/src/Std/Diagnostics.qs +++ b/library/std/src/Std/Diagnostics.qs @@ -1,6 +1,5 @@ open QIR.Intrinsic; -/// # Summary /// # Summary /// Dumps the current target machine's status. /// @@ -66,7 +65,6 @@ function DumpRegister(register : Qubit[]) : Unit { body intrinsic; } -/// # Summary /// # Summary /// Given an operation, dumps the matrix representation of the operation action on the given /// number of qubits. diff --git a/library/std/src/Std/Intrinsic.qs b/library/std/src/Std/Intrinsic.qs index d4b4727d8d..1cc3e1f1d6 100644 --- a/library/std/src/Std/Intrinsic.qs +++ b/library/std/src/Std/Intrinsic.qs @@ -9,7 +9,6 @@ import Std.Math.*; open QIR.Intrinsic; import Std.InternalHelpers.*; -/// # Summary /// # Summary /// Applies the AND gate that is more efficient for use with decomposition of multi-controlled operations. /// Note that target qubit must be in |0⟩ state. diff --git a/library/std/src/Std/Logical.qs b/library/std/src/Std/Logical.qs index d1c94652ba..97050651cb 100644 --- a/library/std/src/Std/Logical.qs +++ b/library/std/src/Std/Logical.qs @@ -2,7 +2,6 @@ // Licensed under the MIT License. -/// # Summary /// # Summary /// Returns the boolean exclusive disjunction (eXclusive OR, XOR) /// of two input boolean values. diff --git a/library/std/src/Std/Math.qs b/library/std/src/Std/Math.qs index 6c40230f88..c149ae0aa9 100644 --- a/library/std/src/Std/Math.qs +++ b/library/std/src/Std/Math.qs @@ -9,7 +9,6 @@ import Std.Diagnostics.*; // Constants PI, E, LogOf2. // -/// # Summary /// # Summary /// Returns a double-precision approximation of the /// matematical constant 𝝅 ≈ 3.14159265358979323846 @@ -62,7 +61,6 @@ function LogOf2() : Double { // Special numbers in IEEE floating-point representation // -/// # Summary /// # Summary /// Returns whether a given floating-point value is not a number (i.e. is /// NaN). @@ -114,7 +112,6 @@ function IsInfinite(d : Double) : Bool { // Sign, Abs, Min, Max, etc. // -/// # Summary /// # Summary /// Returns -1, 0 or +1 that indicates the sign of a number. function SignI(a : Int) : Int { @@ -249,7 +246,6 @@ function Min(values : Int[]) : Int { // Trigonometric functions // -/// # Summary /// # Summary /// Returns the angle whose cosine is the specified number. function ArcCos(x : Double) : Double { @@ -333,7 +329,6 @@ function ArcTanh(x : Double) : Double { // Sqrt, Log, exp, etc. // -/// # Summary /// # Summary /// Returns the square root of a specified number. function Sqrt(d : Double) : Double { @@ -362,7 +357,6 @@ function Lg(input : Double) : Double { // Truncation and Rounding // -/// # Summary /// # Summary /// Returns the integral part of a number. /// For example: Truncate(3.7) = 3; Truncate(-3.7) = -3 @@ -416,7 +410,6 @@ function Round(value : Double) : Int { // Modular arithmetic // -/// # Summary /// # Summary /// Divides one Integer value by another, returns the result and the remainder as a tuple. function DivRemI(dividend : Int, divisor : Int) : (Int, Int) { @@ -539,7 +532,6 @@ function InverseModL(a : BigInt, modulus : BigInt) : BigInt { // GCD, etc. // -/// # Summary /// # Summary /// Computes the greatest common divisor of two integers. /// Note: GCD is always positive except that GCD(0,0)=0. @@ -737,7 +729,6 @@ function RealMod(value : Double, modulo : Double, minValue : Double) : Double { // Binary, bits, etc. // -/// # Summary /// # Summary /// For a non-negative integer `a`, returns the number of bits required to represent `a`. /// NOTE: This function returns the smallest n such that a < 2^n. @@ -813,7 +804,6 @@ function HammingWeightI(n : Int) : Int { // Combinatorics // -/// # Summary /// # Summary /// Returns the factorial of a given number. /// @@ -1022,7 +1012,6 @@ function Binom(n : Int, k : Int) : Int { // Norms // -/// # Summary /// # Summary /// Returns the squared 2-norm of a vector. /// @@ -1104,7 +1093,6 @@ function PNormalized(p : Double, array : Double[]) : Double[] { // Complex numbers // -/// # Summary /// # Summary /// Represents a complex number by its real and imaginary components. /// The first element of the tuple is the real component, @@ -1431,7 +1419,6 @@ function DividedByCP(a : ComplexPolar, b : ComplexPolar) : ComplexPolar { // Fixed point // -/// # Summary /// # Summary /// Returns the smallest representable number for specific fixed point dimensions. /// diff --git a/library/std/src/Std/Measurement.qs b/library/std/src/Std/Measurement.qs index 9a05add623..8639b947c4 100644 --- a/library/std/src/Std/Measurement.qs +++ b/library/std/src/Std/Measurement.qs @@ -7,7 +7,6 @@ import Std.Intrinsic.*; import Std.Diagnostics.*; open QIR.Intrinsic; -/// # Summary /// # Summary /// Jointly measures a register of qubits in the Pauli Z basis. /// diff --git a/library/std/src/Std/Random.qs b/library/std/src/Std/Random.qs index 835fff69f8..40a80eb512 100644 --- a/library/std/src/Std/Random.qs +++ b/library/std/src/Std/Random.qs @@ -3,7 +3,6 @@ -/// # Summary /// # Summary /// Draws a random integer from a uniform distribution /// in a given inclusive range. Fails if `max < min`. diff --git a/library/std/src/Std/Range.qs b/library/std/src/Std/Range.qs index 96918438b8..efd98518ce 100644 --- a/library/std/src/Std/Range.qs +++ b/library/std/src/Std/Range.qs @@ -2,7 +2,6 @@ // Licensed under the MIT License. -/// # Summary /// # Summary /// Returns the defined start value of the given range. /// @@ -27,7 +26,6 @@ /// ``` function RangeStart(r : Range) : Int { r.Start } -/// # Summary /// # Summary /// Returns the defined end value of the given range, /// which is not necessarily the last element in the sequence. @@ -49,7 +47,6 @@ function RangeStart(r : Range) : Int { r.Start } function RangeEnd(r : Range) : Int { r.End } -/// # Summary /// # Summary /// Returns the integer that specifies how the next value of a range is calculated. /// @@ -66,7 +63,6 @@ function RangeEnd(r : Range) : Int { r.End } /// until `end` is passed. function RangeStep(r : Range) : Int { r.Step } -/// # Summary /// # Summary /// Returns a new range which is the reverse of the input range. /// @@ -85,7 +81,6 @@ function RangeReverse(r : Range) : Range { start..-r.Step..r.Start } -/// # Summary /// # Summary /// Returns true if and only if the input range is empty. /// diff --git a/library/std/src/Std/ResourceEstimation.qs b/library/std/src/Std/ResourceEstimation.qs index 600f484425..17c7371b95 100644 --- a/library/std/src/Std/ResourceEstimation.qs +++ b/library/std/src/Std/ResourceEstimation.qs @@ -8,7 +8,6 @@ // is only available when using resource estimator execution target. `BeginCostCaching` // and `EndCostCaching` are not defined for other execution targets. -/// # Summary /// # Summary /// Used to specify that there's only one execution variant in `BeginEstimateCaching` /// function @@ -52,7 +51,6 @@ function EndEstimateCaching() : Unit { // This functionality is only available when using resource estimator execution target. // `AccountForEstimates' is not defined for other execution targets. -/// # Summary /// # Summary /// Returns a tuple that can be passed to the `AccountForEstimates` operation /// to specify that the number of auxiliary qubits is equal to the `amount`. From a575e36c4189aad0748825fa32aecc56a130d362 Mon Sep 17 00:00:00 2001 From: sezna Date: Tue, 8 Oct 2024 14:26:11 -0700 Subject: [PATCH 4/4] update expects --- compiler/qsc_partial_eval/src/tests/misc.rs | 2 +- vscode/test/suites/debugger/debugger.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/qsc_partial_eval/src/tests/misc.rs b/compiler/qsc_partial_eval/src/tests/misc.rs index 2d50a45edf..49dd390953 100644 --- a/compiler/qsc_partial_eval/src/tests/misc.rs +++ b/compiler/qsc_partial_eval/src/tests/misc.rs @@ -602,5 +602,5 @@ fn evaluation_error_within_stdlib_yield_correct_package_span() { } "#, }); - assert_error(&error, &expect!["UnexpectedDynamicValue(PackageSpan { package: PackageId(1), span: Span { lo: 13864, hi: 13879 } })"]); + assert_error(&error, &expect!["UnexpectedDynamicValue(PackageSpan { package: PackageId(1), span: Span { lo: 13850, hi: 13865 } })"]); } diff --git a/vscode/test/suites/debugger/debugger.test.ts b/vscode/test/suites/debugger/debugger.test.ts index 3c70235134..90447ef074 100644 --- a/vscode/test/suites/debugger/debugger.test.ts +++ b/vscode/test/suites/debugger/debugger.test.ts @@ -375,10 +375,10 @@ suite("Q# Debugger Tests", function suite() { sourceReference: 0, adapterData: "qsharp-adapter-data", }, - line: 207, + line: 206, column: 9, name: "H ", - endLine: 207, + endLine: 206, endColumn: 40, }, {