Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Build/check_indents.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def check_file(filename : str) -> bool:
found_spaces = False
found_tabs = False

with open(filename, 'r') as f:
with open(filename, 'r', encoding='utf-8') as f:
contents = list(f.readlines())

for line in contents:
Expand Down
Binary file removed Chemistry/Common/267DevDivSNKey2048.snk
Binary file not shown.
2 changes: 1 addition & 1 deletion Chemistry/Common/DelaySign.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Attributes for delay-signing
#if SIGNED
[assembly:AssemblyKeyFile("..\\..\\Common\\267DevDivSNKey2048.snk")]
[assembly:AssemblyKeyFile("..\\..\\..\\Build\\267DevDivSNKey2048.snk")]
[assembly:AssemblyDelaySign(true)]
#endif

Expand Down
2 changes: 1 addition & 1 deletion Chemistry/tests/DataModelTests/CSharpTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<ItemGroup>
<Compile Include="..\..\Common\DelaySign.cs" Link="Properties\DelaySign.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Runtime\Runtime.csproj" />
<ProjectReference Include="..\..\src\DataModel\DataModel.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions Chemistry/tests/SystemTests/SystemTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<None Include="..\BroombridgeExamples\hydrogen_0.1.yaml" Link="Molecules\MolecularHydrogen\hydrogen_0.1.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand All @@ -31,7 +31,7 @@
<ItemGroup>
<Compile Include="..\..\Common\DelaySign.cs" Link="Properties\DelaySign.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Standard\src\Standard.csproj" />
<ProjectReference Include="..\..\src\Runtime\Runtime.csproj" />
Expand Down
Binary file removed Standard/Common/267DevDivSNKey2048.snk
Binary file not shown.
2 changes: 1 addition & 1 deletion Standard/Common/DelaySign.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Attributes for delay-signing
#if SIGNED
[assembly:AssemblyKeyFile("..\\Common\\267DevDivSNKey2048.snk")]
[assembly:AssemblyKeyFile("..\\..\\Build\\267DevDivSNKey2048.snk")]
[assembly:AssemblyDelaySign(true)]
#endif

Expand Down
5 changes: 0 additions & 5 deletions Standard/src/AmplitudeAmplification/StandardAlgorithms.qs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ namespace Microsoft.Quantum.AmplitudeAmplification {
return ReflectionPhases(startPhases, targetPhases);
}

// We use the phases in "Fixed-Point Amplitude Amplification with an
// Optimal Number of Queires" [YoderLowChuang2014]
// See also "Methodology of composite quantum gates" [LowYoderChuang2016]
// for phases in the `RotationPhases` format

/// # Summary
/// Computes partial reflection phases for fixed-point amplitude
/// amplification.
Expand Down
132 changes: 85 additions & 47 deletions Standard/src/Arithmetic/ApplyDual.qs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ namespace Microsoft.Quantum.Arithmetic {
op(phaseLE);
Adjoint QFTLE(target);
}

adjoint invert;
}


/// # See Also
/// - @"microsoft.quantum.canon.applyphaseleoperationonle"
operation ApplyPhaseLEOperationOnLEC (op : (PhaseLittleEndian => Unit is Ctl), target : LittleEndian) : Unit
Expand All @@ -63,7 +63,7 @@ namespace Microsoft.Quantum.Arithmetic {
op(phaseLE);
Adjoint QFTLE(target);
}

controlled (controls, ...)
{
QFTLE(target);
Expand All @@ -72,8 +72,8 @@ namespace Microsoft.Quantum.Arithmetic {
Adjoint QFTLE(target);
}
}


/// # See Also
/// - @"microsoft.quantum.canon.applyphaseleoperationonle"
operation ApplyPhaseLEOperationOnLECA (op : (PhaseLittleEndian => Unit is Adj + Ctl), target : LittleEndian) : Unit
Expand All @@ -85,21 +85,21 @@ namespace Microsoft.Quantum.Arithmetic {
op(phaseLE);
Adjoint QFTLE(target);
}

adjoint invert;

controlled (controls, ...)
{
QFTLE(target);
let phaseLE = PhaseLittleEndian(target!);
Controlled op(controls, phaseLE);
Adjoint QFTLE(target);
}

controlled adjoint invert;
}


/// # Summary
/// Applies an operation that takes a
/// <xref:microsoft.quantum.arithmetic.phaselittleendian> register as input
Expand All @@ -118,56 +118,94 @@ namespace Microsoft.Quantum.Arithmetic {
///
/// # See Also
/// - Microsoft.Quantum.Canon.ApplyLEOperationonPhaseLEA
/// - Microsoft.Quantum.Canon.ApplyLEOperationonPhaseLEA
/// - Microsoft.Quantum.Canon.ApplyLEOperationonPhaseLEC
/// - Microsoft.Quantum.Canon.ApplyLEOperationonPhaseLECA
operation ApplyLEOperationOnPhaseLE (op : (LittleEndian => Unit), target : PhaseLittleEndian) : Unit
{
let targetLE = LittleEndian(target!);
ApplyWith(Adjoint QFTLE, op, targetLE);
}





/// # Summary
/// Applies an operation that takes a
/// <xref:microsoft.quantum.arithmetic.phaselittleendian> register as input
/// on a target register of type <xref:microsoft.quantum.arithmetic.littleendian>.
///
/// # Input
/// ## op
/// The operation to be applied.
/// ## target
/// The register to which the operation is applied.
///
/// # Remarks
/// The register is transformed to `LittleEndian` by the use of
/// <xref:microsoft.quantum.canon.qftle> and is then returned to
/// its original representation after application of `op`.
///
/// # See Also
/// - Microsoft.Quantum.Canon.ApplyLEOperationonPhaseLE
operation ApplyLEOperationOnPhaseLEA (op : (LittleEndian => Unit is Adj), target : PhaseLittleEndian) : Unit
{
body (...)
{
let targetLE = LittleEndian(target!);
ApplyWithA(Adjoint QFTLE, op, targetLE);
}

adjoint invert;
/// - Microsoft.Quantum.Canon.ApplyLEOperationonPhaseLEC
/// - Microsoft.Quantum.Canon.ApplyLEOperationonPhaseLECA
operation ApplyLEOperationOnPhaseLEA (op : (LittleEndian => Unit is Adj), target : PhaseLittleEndian)
: Unit is Adj {
let targetLE = LittleEndian(target!);
ApplyWithA(Adjoint QFTLE, op, targetLE);
}




/// # Summary
/// Applies an operation that takes a
/// <xref:microsoft.quantum.arithmetic.phaselittleendian> register as input
/// on a target register of type <xref:microsoft.quantum.arithmetic.littleendian>.
///
/// # Input
/// ## op
/// The operation to be applied.
/// ## target
/// The register to which the operation is applied.
///
/// # Remarks
/// The register is transformed to `LittleEndian` by the use of
/// <xref:microsoft.quantum.canon.qftle> and is then returned to
/// its original representation after application of `op`.
///
/// # See Also
/// - Microsoft.Quantum.Canon.ApplyLEOperationonPhaseLE
operation ApplyLEOperationOnPhaseLEC (op : (LittleEndian => Unit is Ctl), target : PhaseLittleEndian) : Unit
{
body (...)
{
let targetLE = LittleEndian(target!);
ApplyWithC(Adjoint QFTLE, op, targetLE);
}

controlled distribute;
/// - Microsoft.Quantum.Canon.ApplyLEOperationonPhaseLEA
/// - Microsoft.Quantum.Canon.ApplyLEOperationonPhaseLECA
operation ApplyLEOperationOnPhaseLEC (op : (LittleEndian => Unit is Ctl), target : PhaseLittleEndian)
: Unit is Ctl {
let targetLE = LittleEndian(target!);
ApplyWithC(Adjoint QFTLE, op, targetLE);
}




/// # Summary
/// Applies an operation that takes a
/// <xref:microsoft.quantum.arithmetic.phaselittleendian> register as input
/// on a target register of type <xref:microsoft.quantum.arithmetic.littleendian>.
///
/// # Input
/// ## op
/// The operation to be applied.
/// ## target
/// The register to which the operation is applied.
///
/// # Remarks
/// The register is transformed to `LittleEndian` by the use of
/// <xref:microsoft.quantum.canon.qftle> and is then returned to
/// its original representation after application of `op`.
///
/// # See Also
/// - Microsoft.Quantum.Canon.ApplyLEOperationonPhaseLE
operation ApplyLEOperationOnPhaseLECA (op : (LittleEndian => Unit is Adj + Ctl), target : PhaseLittleEndian) : Unit
{
body (...)
{
let targetLE = LittleEndian(target!);
ApplyWithCA(Adjoint QFTLE, op, targetLE);
}

adjoint invert;
controlled distribute;
controlled adjoint distribute;
/// - Microsoft.Quantum.Canon.ApplyLEOperationonPhaseLEA
/// - Microsoft.Quantum.Canon.ApplyLEOperationonPhaseLEC
operation ApplyLEOperationOnPhaseLECA(op : (LittleEndian => Unit is Adj + Ctl), target : PhaseLittleEndian)
: Unit is Adj + Ctl {
let targetLE = LittleEndian(target!);
ApplyWithCA(Adjoint QFTLE, op, targetLE);
}

}
46 changes: 23 additions & 23 deletions Standard/src/Arithmetic/Arithmetic.qs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ namespace Microsoft.Quantum.Arithmetic {
open Microsoft.Quantum.Arrays;

/// # Summary
/// Applies `X` operations to qubits in a little-endian register based on 1 bits in an integer.
/// Applies a bitwise-XOR operation between a classical integer and an
/// integer represented by a register of qubits.
///
/// # Description
/// Applies `X` operations to qubits in a little-endian register based on
/// 1 bits in an integer.
///
/// Let us denote `value` by a and let y be an unsigned integer encoded in `target`,
/// then `InPlaceXorLE` performs an operation given by the following map:
Expand All @@ -19,21 +24,20 @@ namespace Microsoft.Quantum.Arithmetic {
/// An integer which is assumed to be non-negative.
/// ## target
/// A quantum register which is used to store `value` in little-endian encoding.
operation ApplyXorInPlace(value : Int, target : LittleEndian) : Unit {
body (...) {
ApplyToEachCA(
CControlledCA(X),
Zip(IntAsBoolArray(value, Length(target!)), target!)
);
}

adjoint auto;
controlled auto;
controlled adjoint auto;
operation ApplyXorInPlace(value : Int, target : LittleEndian)
: Unit is Adj + Ctl {
ApplyToEachCA(
CControlledCA(X),
Zip(IntAsBoolArray(value, Length(target!)), target!)
);
}

/// # Summary
/// This computes the Majority function in-place on 3 qubits.
/// Applies the three-qubit majority operation in-place on a register of
/// qubits.
///
/// # Description
/// This operation computes the majority function in-place on 3 qubits.
///
/// If we denote output qubit as $z$ and input qubits as $x$ and $y$,
/// the operation performs the following transformation:
Expand All @@ -45,17 +49,13 @@ namespace Microsoft.Quantum.Arithmetic {
/// and stored in this qubit.
/// ## input
/// Second and third input qubits.
operation InPlaceMajority(output: Qubit, input: Qubit[]) : Unit {
body (...) {
if (Length(input) == 2) {
MAJ(input[0], input[1], output);
} else {
fail $"The in-place majority operation on {Length(input)} is qubits not yet implemented.";
}
operation ApplyMajorityInPlace(output: Qubit, input: Qubit[])
: Unit is Adj + Ctl {
if (Length(input) == 2) {
MAJ(input[0], input[1], output);
} else {
fail $"The in-place majority operation on {Length(input)} is qubits not yet implemented.";
}
adjoint auto;
controlled auto;
adjoint controlled auto;
}

/// # Summary
Expand Down
7 changes: 4 additions & 3 deletions Standard/src/Arithmetic/Asserts.qs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ namespace Microsoft.Quantum.Arithmetic {
open Microsoft.Quantum.Diagnostics;

/// # Summary
/// Asserts that the probability of a specific state of a quantum register has the
/// expected value.
///
/// Asserts that the probability of a specific state of a quantum register has the
/// expected value.
///
/// # Description
/// Given an $n$-qubit quantum state $\ket{\psi}=\sum^{2^n-1}_{j=0}\alpha_j \ket{j}$,
/// asserts that the probability $|\alpha_j|^2$ of the state $\ket{j}$ indexed by $j$
/// has the expected value.
Expand Down
16 changes: 10 additions & 6 deletions Standard/src/Arithmetic/Comparators.qs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ namespace Microsoft.Quantum.Arithmetic {
open Microsoft.Quantum.Arrays;

/// # Summary
/// This unitary tests if two integers `x` and `y` stored in equal-size qubit registers
/// satisfy `x > y`. If true, 1 is XORed into an output
/// qubit. Otherwise, 0 is XORed into an output qubit.
/// This operation tests if an integer represented by a register of qubits
/// is greater than another integer, applying an XOR of the result onto an
/// output qubit.
///
/// In other words, this unitary $U$ satisfies:
/// # Description
/// Given two integers `x` and `y` stored in equal-size qubit registers,
/// this operation checks if they satisfy `x > y`. If true, 1 is
/// XORed into an output qubit. Otherwise, 0 is XORed into an output qubit.
/// In other words, this operation can be represented by the unitary
/// $$
/// \begin{align}
/// U\ket{x}\ket{y}\ket{z}=\ket{x}\ket{y}\ket{z\oplus (x>y)}.
/// U\ket{x}\ket{y}\ket{z} = \ket{x}\ket{y}\ket{z\oplus (x>y)}.
/// \end{align}
/// $$.
/// $$
///
/// # Input
/// ## x
Expand Down
17 changes: 16 additions & 1 deletion Standard/src/Arithmetic/Deprecated.qs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace Microsoft.Quantum.Canon {
operation ApplyReversedOpBigEndianA(op : (BigEndian => Unit is Adj), register : LittleEndian) : Unit is Adj {
ApplyReversedOpBEA(op, register);
}

/// # Deprecated
/// Please use @"Microsoft.Quantum.Arithmetic.ApplyReversedOpBEC".
@Deprecated("Microsoft.Quantum.Arithmetic.ApplyReversedOpBEC")
Expand Down Expand Up @@ -193,4 +193,19 @@ namespace Microsoft.Quantum.Canon {
CopyMostSignificantBit(from, target);
}

/// # Deprecated
/// Please use @"microsoft.quantum.canon.applycnotchain".
@Deprecated("Microsoft.Quantum.Canon.ApplyCNOTChain")
operation CascadeCNOT (register : Qubit[]) : Unit is Adj + Ctl {
Microsoft.Quantum.Canon.ApplyCNOTChain(register);
}

/// # Deprecated
/// Please use @"microsoft.quantum.arithmetic.applymajorityinplace".
@Deprecated("Microsoft.Quantum.Arithmetic.ApplyMajorityInPlace")
operation InPlaceMajority(output: Qubit, input: Qubit[])
: Unit is Adj + Ctl {
ApplyMajorityInPlace(output, input);
}

}
Loading