Gate
public struct Gate
extension Gate: QuantumOperatorConvertible
extension Gate: SimplifiedQuantumOperatorConvertible
extension Gate: SimplifiedGateConvertible
extension Gate: Hashable
A generic quantum gate
-
Declaration
Swift
public var quantumOperator: QuantumOperator { get }
-
Declaration
Swift
public var simplifiedQuantumOperator: SimplifiedQuantumOperator { get }
-
Returns a generic quantum
gatecontrolled withcontrolsDeclaration
Swift
public static func controlled(gate: Gate, controls: [Int]) -> Gate -
Returns a controlled not gate with 2 inputs:
target&controlDeclaration
Swift
public static func controlledNot(target: Int, control: Int) -> Gate -
Returns a hadamard gate with 1 input:
targetDeclaration
Swift
public static func hadamard(target: Int) -> Gate -
Errors throwed by
See moreGate.makeInversionAboutMean(inputs:)Declaration
Swift
public enum MakeInversionAboutMeanError : Error -
Buils a
Gate.matrix(matrix:inputs:)gate that produces an inversion about the mean on the giveninputsDeclaration
Swift
public static func makeInversionAboutMean(inputs: [Int]) -> Result<Gate, MakeInversionAboutMeanError> -
Returns a generic quantum gate built with a
matrix(it is expected to be unitary) and any number ofinputs(as many inputs asmatrixis able to handle)Declaration
Swift
public static func matrix(matrix: Matrix, inputs: [Int]) -> Gate -
Errors throwed by
See moreGate.makeModularExponentiation(base:modulus:exponent:inputs:)Declaration
Swift
public enum MakeModularExponentiationError : Error -
Implements with
Gateinstances a modular exponentiation performed overmoduluswithbaseraised toexponent. Whilebase&modulusare constant integers,exponentis a list of qubits and, therefore, its actual value can vary. The extrainputsare used to pass the result from one gate to the next and they HAVE TO be set to |1>.Declaration
Swift
public static func makeModularExponentiation(base: Int, modulus: Int, exponent: [Int], inputs: [Int]) -> Result<[Gate], MakeModularExponentiationError>Parameters
baseBase of the modular exponentiation, a positive integer bigger than zero.
modulusModulus of the modular exponentiation, a positive integer bigger than zero..
exponentList of qubits that defines the exponent of the modular exponentiation. For example, if
exponentis equal to [2, 1, 0] and qubit[2]=1, qubit[1]=1 & qubit[0]=0, the actual value of the exponent is ‘110’=6. Notice that Ifexponentwas reveresed (i.e. [0, 1, 2]), the actual of the exponent would be ‘011’=3.inputsList of qubits used to pass the result from one gate to the next. Notice that, because this is a modulo, you have to provide at least enough input qubits to code
modulusvalues (from 0 tomodulus- 1). Also, in order to get the expected result at the end of the list ofGateinstances, the input qubits have to be set to |1>. For example, ifinputsare equal to [2, 1, 0], qubit[2] and qubit[1] have to be 0 and qubit[0] has to be 1. On the other hand, ifinputswere [0, 1, 2], qubit[0] and qubit[1] should be 0 and qubit[2] should be 1.Return Value
List of
Gateinstances that code a modular exponentiation. OrMakeModularExponentiationErrorerror. -
Returns a not gate with 1 input:
targetDeclaration
Swift
public static func not(target: Int) -> Gate -
Returns an oracle gate composed of a
truthtablethat specifies whichcontrolsactivate agateDeclaration
Swift
public static func oracle(truthTable: [String], controls: [Int], gate: Gate) -> Gate -
Produces a
Gate.oracle(truthTable:controls:gate:)with aGate.not(target:)in target.Declaration
Swift
public static func oracle(truthTable: [String], controls: [Int], target: Int) -> GateParameters
truthTableOracle truthtable.
controlsControl qubits.
targetTarget of
Gate.not(target:).Return Value
A
Gate.oracle(truthTable:controls:gate:)instance. -
Returns a quantum gate that shifts phase of the quantum state in
targetbyradiansDeclaration
Swift
public static func phaseShift(radians: Double, target: Int) -> Gate -
Errors throwed by
See moreGate.makeQuantumFourierTransform(inputs:inverse:)Declaration
Swift
public enum MakeQuantumFourierTransformError : Error -
Buils a
Gate.matrix(matrix:inputs:)gate that performs a Quantum Fourier Transform overinputsifinverseisfalseor an inverse Quantum Fourier Transform otherwiseDeclaration
Swift
public static func makeQuantumFourierTransform(inputs: [Int], inverse: Bool = false) -> Result<Gate, MakeQuantumFourierTransformError>
-
Returns a quantum gate that defines a rotation of
radiansaroundaxisof the quantum state intargetDeclaration
Swift
public static func rotation(axis: Axis, radians: Double, target: Int) -> Gate
-
Declaration
Swift
public var simplifiedGate: SimplifiedGate { get }
-
Builds a
Gate.matrix(matrix:inputs:)gate that produces an inversion about the mean onDeclaration
Swift
public static func makeInversionAboutMean(inputs: Range<Int>) -> Result<Gate, MakeInversionAboutMeanError> -
Builds a
Gate.matrix(matrix:inputs:)gate that produces an inversion about the mean onDeclaration
Swift
public static func makeInversionAboutMean(inputs: ClosedRange<Int>) -> Result<Gate, MakeInversionAboutMeanError> -
Implements with
Gateinstances a modular exponentiation performed overmoduluswithbaseraised toexponentDeclaration
Swift
public static func makeModularExponentiation(base: Int, modulus: Int, exponent: Range<Int>, inputs: [Int]) -> Result<[Gate], MakeModularExponentiationError> -
Implements with
Gateinstances a modular exponentiation performed overmoduluswithbaseraised toexponentDeclaration
Swift
public static func makeModularExponentiation(base: Int, modulus: Int, exponent: ClosedRange<Int>, inputs: [Int]) -> Result<[Gate], MakeModularExponentiationError> -
Implements with
Gateinstances a modular exponentiation performed overmoduluswithbaseraised toexponentDeclaration
Swift
public static func makeModularExponentiation(base: Int, modulus: Int, exponent: [Int], inputs: Range<Int>) -> Result<[Gate], MakeModularExponentiationError> -
Implements with
Gateinstances a modular exponentiation performed overmoduluswithbaseraised toexponentDeclaration
Swift
public static func makeModularExponentiation(base: Int, modulus: Int, exponent: [Int], inputs: ClosedRange<Int>) -> Result<[Gate], MakeModularExponentiationError> -
Implements with
Gateinstances a modular exponentiation performed overmoduluswithbaseraised toexponentDeclaration
Swift
public static func makeModularExponentiation(base: Int, modulus: Int, exponent: Range<Int>, inputs: Range<Int>) -> Result<[Gate], MakeModularExponentiationError> -
Implements with
Gateinstances a modular exponentiation performed overmoduluswithbaseraised toexponentDeclaration
Swift
public static func makeModularExponentiation(base: Int, modulus: Int, exponent: Range<Int>, inputs: ClosedRange<Int>) -> Result<[Gate], MakeModularExponentiationError> -
Implements with
Gateinstances a modular exponentiation performed overmoduluswithbaseraised toexponentDeclaration
Swift
public static func makeModularExponentiation(base: Int, modulus: Int, exponent: ClosedRange<Int>, inputs: Range<Int>) -> Result<[Gate], MakeModularExponentiationError> -
Implements with
Gateinstances a modular exponentiation performed overmoduluswithbaseraised toexponentDeclaration
Swift
public static func makeModularExponentiation(base: Int, modulus: Int, exponent: ClosedRange<Int>, inputs: ClosedRange<Int>) -> Result<[Gate], MakeModularExponentiationError> -
Produces an oracle gate
Declaration
Swift
public static func oracle(truthTable: [String], controls: Range<Int>, gate: Gate) -> Gate -
Produces an oracle gate
Declaration
Swift
public static func oracle(truthTable: [String], controls: ClosedRange<Int>, gate: Gate) -> Gate -
Produces an oracle gate
Declaration
Swift
public static func oracle(truthTable: [String], controls: Range<Int>, target: Int) -> Gate -
Produces an oracle gate
Declaration
Swift
public static func oracle(truthTable: [String], controls: ClosedRange<Int>, target: Int) -> Gate -
Produces a list of oracle gates
Declaration
Swift
public static func oracle(truthTable: [ExtendedTruth], controls: [Int], targets: Range<Int>) -> [Gate] -
Produces a list of oracle gates
Declaration
Swift
public static func oracle(truthTable: [ExtendedTruth], controls: Range<Int>, targets: Range<Int>) -> [Gate] -
Produces a list of oracle gates
Declaration
Swift
public static func oracle(truthTable: [ExtendedTruth], controls: ClosedRange<Int>, targets: Range<Int>) -> [Gate] -
Produces a list of oracle gates
Declaration
Swift
public static func oracle(truthTable: [ExtendedTruth], controls: [Int], targets: ClosedRange<Int>) -> [Gate] -
Produces a list of oracle gates
Declaration
Swift
public static func oracle(truthTable: [ExtendedTruth], controls: Range<Int>, targets: ClosedRange<Int>) -> [Gate] -
Produces a list of oracle gates
Declaration
Swift
public static func oracle(truthTable: [ExtendedTruth], controls: ClosedRange<Int>, targets: ClosedRange<Int>) -> [Gate] -
Produces a list of
Gate.hadamard(target:), each gate on one of thetargetsDeclaration
Swift
public static func hadamard(targets: Range<Int>) -> [Gate] -
Produces a list of
Gate.hadamard(target:), each gate on one of thetargetsDeclaration
Swift
public static func hadamard(targets: ClosedRange<Int>) -> [Gate] -
Produces a list of
Gate.hadamard(target:), each gate on one of thetargetsDeclaration
Swift
public static func hadamard(targets: Int...) -> [Gate] -
Produces a list of
Gate.not(target:), each gate on one of thetargetsDeclaration
Swift
public static func not(targets: Range<Int>) -> [Gate] -
Produces a list of
Gate.not(target:), each gate on one of thetargetsDeclaration
Swift
public static func not(targets: ClosedRange<Int>) -> [Gate] -
Produces a list of
Gate.not(target:), each gate on one of thetargetsDeclaration
Swift
public static func not(targets: Int...) -> [Gate]
-
Represents the
activation(or bits) produded by a function after inputting a giventruthDeclaration
Swift
public typealias ExtendedTruth = (truth: String, activation: String)
-
Produces a list of
Gate.oracle(truthTable:controls:gate:). AGate.not(target:)is produced for each target intargetsif at least oneactivationintruthTablehas the bit correspoding to the target activated.Declaration
Swift
public static func oracle(truthTable: [ExtendedTruth], controls: [Int], targets: [Int]) -> [Gate]Parameters
truthTableList of
Gate.ExtendedTruthinstances.controlsControl qubits for each oracle in the list.
targetsTargets for each oracle in the list.
Return Value
-
Produces a list of
Gate.hadamard(target:), each gate on one of thetargetsDeclaration
Swift
public static func hadamard(targets: [Int]) -> [Gate] -
Produces a list of
Gate.not(target:), each gate on one of thetargetsDeclaration
Swift
public static func not(targets: [Int]) -> [Gate]
-
Declaration
Swift
public static func == (lhs: `Self`, rhs: `Self`) -> Bool -
Declaration
Swift
public func hash(into hasher: inout Hasher)
Gate Structure Reference