QuantumLibraries/Standard/tests/IntegerTests.qs

263 строки
12 KiB
Plaintext
Исходник Обычный вид История

2019-03-19 19:48:49 +03:00
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
Release v0.6 to master. (#98) * Begin refactoring standard libraries (#39) * Began splitting up namespaces. * Began refactoring tests. * Updated chemistry src and tests for new namespaces. * Remove unused opens. * Began renaming operations and functions. * Separated out and updated ApplyReversed*. * Updated BE ↔ LE type conversions. * Added new transformed operation fns. * Whitespace fix * Eliminated some redundant code in applyreversed * Fixed deprecation comments. * Began working on refactoring With. * Refactored With further. * More renaming for consistency with LE/BE suffix convention. * Added Zip3, Zip4 * Added shorthand for MAJ and updated some type conv. * Fixed a typo in Zip4. * Separated out and updated arithmetic measurements. * Other minor maintenance changes. * Started separating out modular arithmetic. * Began refactoring ripple-carry comparators. * Refactored integer increment operations. * Fixed some See Also blocks. * Some minor progress. * Moved new arithmetic functionality into right folders. * Renamed integer arithmetic namespaces. * Split out qecc namespace. * Added documentation file for Microsoft.Quantum.ErrorCorrection. * Progress on renaming type conversion functions. * More progress on updating type conversion names. * Split out AA namespace. * Split out oracles namespace as well. * Renamed UDTs to remove "AmpAmp" prefix. This prefix is now implied by the Microsoft.Quantum.AmplitudeAmplification namespace. * Renamed some Qecc operations/fns * Moved more conversions into Convert.qs. * Updated some deprecated syntax. * Split out M.Q.Convert. * Added missing open stmt. * Started separating out classical math. * Began separating out QCVV. * Fixing namespaces in tests. * Update to use new docgen. * Began making arrays namespace. * Updated to use new arrays and diagnostics namespaces. * Updated names for claims * Started extracting measurements from Paulis.qs. * Updated namespaces in tests as well. * Updating chemistry for most recent changes. * Added ForEach, used to simplify measurements. * Updating deprecated Q# syntax. * Minor fix for XML error. * Fixed infinite recursion in deprecation stubs. * Started trying to reduce # of warnings. * Fixed some minor build errors. * Resolved a couple TODOs. * Removed BigEndian support. * Resolved warnings due to && and ||. * Update Standard/src/Arithmetic/Shorthand.qs Co-Authored-By: cgranade <cgranade@gmail.com> * Addressing feedback. * Claim → Fact * Moved MeasureInteger back to Microsoft.Quantum.Arithmetic. * Resolved more deprecated syntax. * Removed one more LE suffix. * Addressing feedback. * Cgranade/complete 0.6 move (#57) * Revert "Begin refactoring standard libraries (#39)" (#56) As Chris pointed out, reverting these breaking changes until we have a chance to change everything... * Complete move of standard library refactoring to release branch This reverts commit 058048983c4d0509e5d522888d3d47ae49cd300e. * Explicitly qualify all names in M.Q.Ext.Math. (#74) * Explicitly qualify all names in M.Q.Ext.Math. * Fixed two missing qualified names. * Removed more occurances of M.Q.Ext.Math. * Removed Microsoft.Quantum.Extensions.Math from tests as well. * Reverted slight change to QuantumROM. * New array functions (#75) * Added new IndexRange function to eliminate `-1` in for loops. * Added some missing open statements. * New Enumerated function. * Port library and test code to new 0.6 names to reduce warning count. (#72) * Updating to use new syntax, namespace names, etc. * More primitive → intrinsic. * Updated test project to use beta version. * Updated chemistry proiects to beta. * Finding a few more calls to deprecated fns. * Cleaned up some assert and qcvv tests. * Removed uses of deprecated IntArrayFromRange * Resolved some more deprecated functions and ops. * Minor maintenance in QubitizationTests. * Bumped versions to latest beta. * Some trivial change to retrigger build. * Resolved package downgrade. * Move Microsoft.Quantum.Math.Complex UDT and resolve Microsoft.Quantum.Diagnostics deprecation stubs. (#77) * More primitive → intrinsic. * Finding a few more calls to deprecated fns. * Resolved some more deprecated functions and ops. * Minor maintenance in QubitizationTests. * Bumped versions to latest beta. * Resolved package downgrade. * Use Complex UDT at its new name. * Adapted tests. * A few more test adaptations. * Updated name of AssertQubitState to 0.6 name. * Fixes to chemistry. * Getting updates from master (#80) * Revert "Begin refactoring standard libraries (#39)" (#56) As Chris pointed out, reverting these breaking changes until we have a chance to change everything... * Missing return statement when compiling more than one Q# snippet from Python. (#60) * Fixing bug * Adding tests * Change Assembly.Version to Python.Version. (#64) * Prevent loading Q# modules when Python client is busy. (#71) * Prevent loading Q# modules when Python client is busy. * Linux build failed with some unrelated problem. Committing. * modifying contructor calls for QArray in preparation for a simulation framework change (#78) * Revert "Revert "Begin refactoring standard libraries (#39)" (#56)" This reverts commit 058048983c4d0509e5d522888d3d47ae49cd300e. * Update to 0.6.1904.1302-beta. (#81) * Update to 0.6.1904.1302-beta. * Removed deprecation warnings for Microsoft.Quantum.Math. * Resolved a few more deprecations. * Resolved a few more deprecation warnings. * A few more deprecation resolutions. * Removed some duplicate namespace opens. * Slight code cleanup. * Addressed feedback from @bettinaheim. * Standard.sln builds again, Standard.sln builds (#84) * Gulow/v0.6 chemistry deprecation (#82) * Update to 0.6.1904.1302-beta. * Removed deprecation warnings for Microsoft.Quantum.Math. * Resolved a few more deprecations. * Resolved a few more deprecation warnings. * A few more deprecation resolutions. * Removed some duplicate namespace opens. * Slight code cleanup. * Update test * . * Remove deprecated operations from chemistry and dependencies. * Fix comments * Update to use 0.65 syntax from latest beta. (#87) * Ported stateprep.qs to 0.65 syntax. * Fixed deprecation in test. * Updated to latest beta. * Fix mutable array issue in chemistry data model. (#88) * Explicitly call new QArray. (#89) * do not rely on collections.immutable (#93) * Continue migrating libraries to Q# 0.6 (#91) * Continue migrating to 0.65 syntax and applying style guidance. * A bit more progress normalizing private names. * Resolved more deprecated syntax, updated a name. * Resolved some more syntax warnings. * Ported more syntax and updated more names. * Resolved all remaining compile-time warnings in Standard. * Addressed all Q#-level compile-time warnings in chem. * Migrated a bit more syntax and updated to newest beta. * Moved to using intrinsic warnings. * Fixed endianness of exact QFT. * Fixed Microsoft.Quantum.Warnings. * Addressing @bettinaheim's feedback. * Removed some warnings in unit tests. * Adding DocsOutDir for single doc output location across projects. (#94) * Adding DocsOutDir for single doc output location across projects. * Begin adding more classical math functions for BigInt. (#96) * Begin adding more classical math functions for BigInt. * Addressing @beheim's feedback. * Minor fixes. * Bump to latest beta. * Fixed two minor bugs. * Fixed the type of signs. * Bump version to released packages.
2019-05-04 01:44:41 +03:00
namespace Microsoft.Quantum.Arithmetic {
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Diagnostics;
open Microsoft.Quantum.Measurement;
2019-03-15 21:04:17 +03:00
internal operation IntegerAdderTestHelper( IntegerAdder : ( (LittleEndian, LittleEndian, Qubit) => Unit is Ctl), summand1 : Int, summand2 : Int, numberOfQubits : Int ) : Unit {
use register = Qubit[2*numberOfQubits + 1];
mutable actualCarry = 0;
mutable actual1 = 0;
mutable actual2 = 0;
mutable measured_carry = Zero;
let summand1LE = LittleEndian(register[0 .. numberOfQubits - 1]);
let summand2LE = LittleEndian(register[numberOfQubits .. 2*numberOfQubits - 1]);
let carry = register[2*numberOfQubits];
ApplyXorInPlace(summand1, summand1LE);
ApplyXorInPlace(summand2, summand2LE);
IntegerAdder(summand1LE, summand2LE, carry);
let sum = summand1 + summand2;
let expected = ModulusI(sum, 2^numberOfQubits);
set actual1 = MeasureInteger(summand1LE);
EqualityFactI(summand1, actual1, $"Expected {summand1}, got {actual1}");
set actual2 = MeasureInteger(summand2LE);
EqualityFactI(expected, actual2, $"Expected {expected}, got {actual2}");
let expected_carry = (sum / 2^numberOfQubits);
set measured_carry = MResetZ(carry);
if (measured_carry == One) {set actualCarry = 1;} else {set actualCarry = 0;}
EqualityFactI(expected_carry, actualCarry, $"Expected {expected_carry}, got {actualCarry}");
for numberOfControls in 1..2 {
use controls = Qubit[numberOfControls];
ApplyXorInPlace(summand1, summand1LE);
ApplyXorInPlace(summand2, summand2LE);
// controls are |0>, no addition is computed
(Controlled IntegerAdder) (controls, (summand1LE, summand2LE, carry));
set actual1 = MeasureInteger(summand1LE);
EqualityFactI(summand1, actual1, $"Expected {summand1}, got {actual1}");
set actual2 = MeasureInteger(summand2LE);
EqualityFactI(summand2, actual2, $"Expected {expected}, got {actual2}");
set measured_carry = MResetZ(carry);
if (measured_carry == One) {set actualCarry = 1;} else {set actualCarry = 0;}
EqualityFactI(0, actualCarry, $"Expected {0}, got {actualCarry}");
ApplyXorInPlace(summand1, summand1LE);
ApplyXorInPlace(summand2, summand2LE);
// now controls are set to |1>, addition is computed
ApplyToEach(X, controls);
(Controlled IntegerAdder) (controls, (summand1LE, summand2LE, carry));
set actual1 = MeasureInteger(summand1LE);
EqualityFactI(summand1, actual1, $"Expected {summand1}, got {actual1}");
set actual2 = MeasureInteger(summand2LE);
EqualityFactI(expected, actual2, $"Expected {expected}, got {actual2}");
set measured_carry = MResetZ(carry);
if (measured_carry == One) {set actualCarry = 1;} else {set actualCarry = 0;}
EqualityFactI(expected_carry, actualCarry, $"Expected {expected_carry}, got {actualCarry}");
ResetAll(controls);
2019-03-15 21:04:17 +03:00
}
}
Code quality improvements (#203) * Improve code quality with experimental linter. * Fixed a couple mistakes in previous cleanup. * More fixes to resolve linting issues. * Remove extraneous comment. * Applied feedback from #198. * Applying more documentation fixes suggested by linter. * Fix to deprecation stub. * Whitespace fix noted by @ScottCarda-MS. * Fixed minor mistake introduced with previous code quality fix. * Incorporated more feedback from @ScottCarda-MS. * Update Standard/src/Arrays/Map.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Addressing feedback, lots of indentation fixes. * Deprecate the stack data structure. * Slight improvements to phase est operations. * Add missing characteristics to CNOTChainTarget. * CCNOTChainTarget → ApplyCNOTChainWithTarget * Workaround for kata oracle counting. Co-authored-by: Alan Geller <alan.geller@microsoft.com>
2020-01-15 23:14:02 +03:00
internal operation IntegerAdderExhaustiveTestHelper (IntegerAdder : ( (LittleEndian, LittleEndian, Qubit) => Unit is Ctl), numberOfQubits : Int) : Unit {
for summand1 in 0 .. 2^numberOfQubits - 1 {
for summand2 in 0 .. 2^numberOfQubits - 1 {
2019-03-15 21:04:17 +03:00
IntegerAdderTestHelper(IntegerAdder, summand1, summand2, numberOfQubits);
}
}
}
@Test("ToffoliSimulator")
2019-03-15 21:04:17 +03:00
operation RippleCarryAdderDTest () : Unit {
let numberOfQubits = 7;
let summand1 = 127;
let summand2 = 17;
IntegerAdderTestHelper(RippleCarryAdderD, summand1, summand2, numberOfQubits);
}
@Test("ToffoliSimulator")
2019-03-15 21:04:17 +03:00
operation RippleCarryAdderDExhaustiveTestReversible () : Unit {
for numberOfQubits in [3, 6] {
2019-03-15 21:04:17 +03:00
IntegerAdderExhaustiveTestHelper (RippleCarryAdderD, numberOfQubits);
}
}
@Test("ToffoliSimulator")
2019-03-15 21:04:17 +03:00
operation RippleCarryAdderDTestReversible () : Unit {
let numberOfQubits = 20;
Code quality improvements (#203) * Improve code quality with experimental linter. * Fixed a couple mistakes in previous cleanup. * More fixes to resolve linting issues. * Remove extraneous comment. * Applied feedback from #198. * Applying more documentation fixes suggested by linter. * Fix to deprecation stub. * Whitespace fix noted by @ScottCarda-MS. * Fixed minor mistake introduced with previous code quality fix. * Incorporated more feedback from @ScottCarda-MS. * Update Standard/src/Arrays/Map.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Addressing feedback, lots of indentation fixes. * Deprecate the stack data structure. * Slight improvements to phase est operations. * Add missing characteristics to CNOTChainTarget. * CCNOTChainTarget → ApplyCNOTChainWithTarget * Workaround for kata oracle counting. Co-authored-by: Alan Geller <alan.geller@microsoft.com>
2020-01-15 23:14:02 +03:00
let summand1 = 823709;
let summand2 = 88487;
2019-03-15 21:04:17 +03:00
IntegerAdderTestHelper(RippleCarryAdderD, summand1, summand2, numberOfQubits);
}
@Test("ToffoliSimulator")
2019-03-15 21:04:17 +03:00
operation RippleCarryAdderCDKMTestReversible () : Unit {
let numberOfQubits = 20;
Code quality improvements (#203) * Improve code quality with experimental linter. * Fixed a couple mistakes in previous cleanup. * More fixes to resolve linting issues. * Remove extraneous comment. * Applied feedback from #198. * Applying more documentation fixes suggested by linter. * Fix to deprecation stub. * Whitespace fix noted by @ScottCarda-MS. * Fixed minor mistake introduced with previous code quality fix. * Incorporated more feedback from @ScottCarda-MS. * Update Standard/src/Arrays/Map.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Addressing feedback, lots of indentation fixes. * Deprecate the stack data structure. * Slight improvements to phase est operations. * Add missing characteristics to CNOTChainTarget. * CCNOTChainTarget → ApplyCNOTChainWithTarget * Workaround for kata oracle counting. Co-authored-by: Alan Geller <alan.geller@microsoft.com>
2020-01-15 23:14:02 +03:00
let summand1 = 823709;
let summand2 = 88487;
2019-03-15 21:04:17 +03:00
IntegerAdderTestHelper(RippleCarryAdderCDKM, summand1, summand2, numberOfQubits);
}
@Test("ToffoliSimulator")
2019-03-15 21:04:17 +03:00
operation RippleCarryAdderCDKMExhaustiveTestReversible () : Unit {
for numberOfQubits in [3, 6] {
Code quality improvements (#203) * Improve code quality with experimental linter. * Fixed a couple mistakes in previous cleanup. * More fixes to resolve linting issues. * Remove extraneous comment. * Applied feedback from #198. * Applying more documentation fixes suggested by linter. * Fix to deprecation stub. * Whitespace fix noted by @ScottCarda-MS. * Fixed minor mistake introduced with previous code quality fix. * Incorporated more feedback from @ScottCarda-MS. * Update Standard/src/Arrays/Map.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Addressing feedback, lots of indentation fixes. * Deprecate the stack data structure. * Slight improvements to phase est operations. * Add missing characteristics to CNOTChainTarget. * CCNOTChainTarget → ApplyCNOTChainWithTarget * Workaround for kata oracle counting. Co-authored-by: Alan Geller <alan.geller@microsoft.com>
2020-01-15 23:14:02 +03:00
IntegerAdderExhaustiveTestHelper (RippleCarryAdderCDKM, numberOfQubits);
2019-03-15 21:04:17 +03:00
}
}
@Test("ToffoliSimulator")
2019-03-15 21:04:17 +03:00
operation RippleCarryAdderTTKExhaustiveTest () : Unit {
let numberOfQubits = 4;
IntegerAdderExhaustiveTestHelper (RippleCarryAdderTTK, numberOfQubits);
}
@Test("ToffoliSimulator")
2019-03-15 21:04:17 +03:00
operation RippleCarryAdderTTKExhaustiveTestReversible () : Unit {
for numberOfQubits in [4, 6] {
2019-03-15 21:04:17 +03:00
IntegerAdderExhaustiveTestHelper (RippleCarryAdderTTK, numberOfQubits);
}
}
internal operation IntegerAdderNoCarryTestHelper( IntegerAdder : ( (LittleEndian, LittleEndian) => Unit is Ctl), summand1 : Int, summand2 : Int, numberOfQubits : Int ) : Unit {
use register = Qubit[2*numberOfQubits];
mutable actual1 = 0;
mutable actual2 = 0;
let summand1LE = LittleEndian(register[0 .. numberOfQubits - 1]);
let summand2LE = LittleEndian(register[numberOfQubits .. 2*numberOfQubits - 1]);
ApplyXorInPlace(summand1, summand1LE);
ApplyXorInPlace(summand2, summand2LE);
IntegerAdder(summand1LE, summand2LE);
let sum = summand1 + summand2;
let expected = ModulusI(sum, 2^numberOfQubits);
set actual1 = MeasureInteger(summand1LE);
EqualityFactI(summand1, actual1, $"Expected {summand1}, got {actual1}");
set actual2 = MeasureInteger(summand2LE);
EqualityFactI(expected, actual2, $"Expected {expected}, got {actual2}");
let expected_carry = (sum / 2^numberOfQubits);
for numberOfControls in 1..2 {
use controls = Qubit[numberOfControls];
ApplyXorInPlace(summand1, summand1LE);
ApplyXorInPlace(summand2, summand2LE);
// controls are |0>, no addition is computed
(Controlled IntegerAdder) (controls, (summand1LE, summand2LE));
set actual1 = MeasureInteger(summand1LE);
EqualityFactI(summand1, actual1, $"Expected {summand1}, got {actual1}");
set actual2 = MeasureInteger(summand2LE);
EqualityFactI(summand2, actual2, $"Expected {expected}, got {actual2}");
ApplyXorInPlace(summand1, summand1LE);
ApplyXorInPlace(summand2, summand2LE);
// now controls are set to |1>, addition is computed
ApplyToEach(X, controls);
(Controlled IntegerAdder) (controls, (summand1LE, summand2LE));
2019-03-15 21:04:17 +03:00
set actual1 = MeasureInteger(summand1LE);
Release v0.6 to master. (#98) * Begin refactoring standard libraries (#39) * Began splitting up namespaces. * Began refactoring tests. * Updated chemistry src and tests for new namespaces. * Remove unused opens. * Began renaming operations and functions. * Separated out and updated ApplyReversed*. * Updated BE ↔ LE type conversions. * Added new transformed operation fns. * Whitespace fix * Eliminated some redundant code in applyreversed * Fixed deprecation comments. * Began working on refactoring With. * Refactored With further. * More renaming for consistency with LE/BE suffix convention. * Added Zip3, Zip4 * Added shorthand for MAJ and updated some type conv. * Fixed a typo in Zip4. * Separated out and updated arithmetic measurements. * Other minor maintenance changes. * Started separating out modular arithmetic. * Began refactoring ripple-carry comparators. * Refactored integer increment operations. * Fixed some See Also blocks. * Some minor progress. * Moved new arithmetic functionality into right folders. * Renamed integer arithmetic namespaces. * Split out qecc namespace. * Added documentation file for Microsoft.Quantum.ErrorCorrection. * Progress on renaming type conversion functions. * More progress on updating type conversion names. * Split out AA namespace. * Split out oracles namespace as well. * Renamed UDTs to remove "AmpAmp" prefix. This prefix is now implied by the Microsoft.Quantum.AmplitudeAmplification namespace. * Renamed some Qecc operations/fns * Moved more conversions into Convert.qs. * Updated some deprecated syntax. * Split out M.Q.Convert. * Added missing open stmt. * Started separating out classical math. * Began separating out QCVV. * Fixing namespaces in tests. * Update to use new docgen. * Began making arrays namespace. * Updated to use new arrays and diagnostics namespaces. * Updated names for claims * Started extracting measurements from Paulis.qs. * Updated namespaces in tests as well. * Updating chemistry for most recent changes. * Added ForEach, used to simplify measurements. * Updating deprecated Q# syntax. * Minor fix for XML error. * Fixed infinite recursion in deprecation stubs. * Started trying to reduce # of warnings. * Fixed some minor build errors. * Resolved a couple TODOs. * Removed BigEndian support. * Resolved warnings due to && and ||. * Update Standard/src/Arithmetic/Shorthand.qs Co-Authored-By: cgranade <cgranade@gmail.com> * Addressing feedback. * Claim → Fact * Moved MeasureInteger back to Microsoft.Quantum.Arithmetic. * Resolved more deprecated syntax. * Removed one more LE suffix. * Addressing feedback. * Cgranade/complete 0.6 move (#57) * Revert "Begin refactoring standard libraries (#39)" (#56) As Chris pointed out, reverting these breaking changes until we have a chance to change everything... * Complete move of standard library refactoring to release branch This reverts commit 058048983c4d0509e5d522888d3d47ae49cd300e. * Explicitly qualify all names in M.Q.Ext.Math. (#74) * Explicitly qualify all names in M.Q.Ext.Math. * Fixed two missing qualified names. * Removed more occurances of M.Q.Ext.Math. * Removed Microsoft.Quantum.Extensions.Math from tests as well. * Reverted slight change to QuantumROM. * New array functions (#75) * Added new IndexRange function to eliminate `-1` in for loops. * Added some missing open statements. * New Enumerated function. * Port library and test code to new 0.6 names to reduce warning count. (#72) * Updating to use new syntax, namespace names, etc. * More primitive → intrinsic. * Updated test project to use beta version. * Updated chemistry proiects to beta. * Finding a few more calls to deprecated fns. * Cleaned up some assert and qcvv tests. * Removed uses of deprecated IntArrayFromRange * Resolved some more deprecated functions and ops. * Minor maintenance in QubitizationTests. * Bumped versions to latest beta. * Some trivial change to retrigger build. * Resolved package downgrade. * Move Microsoft.Quantum.Math.Complex UDT and resolve Microsoft.Quantum.Diagnostics deprecation stubs. (#77) * More primitive → intrinsic. * Finding a few more calls to deprecated fns. * Resolved some more deprecated functions and ops. * Minor maintenance in QubitizationTests. * Bumped versions to latest beta. * Resolved package downgrade. * Use Complex UDT at its new name. * Adapted tests. * A few more test adaptations. * Updated name of AssertQubitState to 0.6 name. * Fixes to chemistry. * Getting updates from master (#80) * Revert "Begin refactoring standard libraries (#39)" (#56) As Chris pointed out, reverting these breaking changes until we have a chance to change everything... * Missing return statement when compiling more than one Q# snippet from Python. (#60) * Fixing bug * Adding tests * Change Assembly.Version to Python.Version. (#64) * Prevent loading Q# modules when Python client is busy. (#71) * Prevent loading Q# modules when Python client is busy. * Linux build failed with some unrelated problem. Committing. * modifying contructor calls for QArray in preparation for a simulation framework change (#78) * Revert "Revert "Begin refactoring standard libraries (#39)" (#56)" This reverts commit 058048983c4d0509e5d522888d3d47ae49cd300e. * Update to 0.6.1904.1302-beta. (#81) * Update to 0.6.1904.1302-beta. * Removed deprecation warnings for Microsoft.Quantum.Math. * Resolved a few more deprecations. * Resolved a few more deprecation warnings. * A few more deprecation resolutions. * Removed some duplicate namespace opens. * Slight code cleanup. * Addressed feedback from @bettinaheim. * Standard.sln builds again, Standard.sln builds (#84) * Gulow/v0.6 chemistry deprecation (#82) * Update to 0.6.1904.1302-beta. * Removed deprecation warnings for Microsoft.Quantum.Math. * Resolved a few more deprecations. * Resolved a few more deprecation warnings. * A few more deprecation resolutions. * Removed some duplicate namespace opens. * Slight code cleanup. * Update test * . * Remove deprecated operations from chemistry and dependencies. * Fix comments * Update to use 0.65 syntax from latest beta. (#87) * Ported stateprep.qs to 0.65 syntax. * Fixed deprecation in test. * Updated to latest beta. * Fix mutable array issue in chemistry data model. (#88) * Explicitly call new QArray. (#89) * do not rely on collections.immutable (#93) * Continue migrating libraries to Q# 0.6 (#91) * Continue migrating to 0.65 syntax and applying style guidance. * A bit more progress normalizing private names. * Resolved more deprecated syntax, updated a name. * Resolved some more syntax warnings. * Ported more syntax and updated more names. * Resolved all remaining compile-time warnings in Standard. * Addressed all Q#-level compile-time warnings in chem. * Migrated a bit more syntax and updated to newest beta. * Moved to using intrinsic warnings. * Fixed endianness of exact QFT. * Fixed Microsoft.Quantum.Warnings. * Addressing @bettinaheim's feedback. * Removed some warnings in unit tests. * Adding DocsOutDir for single doc output location across projects. (#94) * Adding DocsOutDir for single doc output location across projects. * Begin adding more classical math functions for BigInt. (#96) * Begin adding more classical math functions for BigInt. * Addressing @beheim's feedback. * Minor fixes. * Bump to latest beta. * Fixed two minor bugs. * Fixed the type of signs. * Bump version to released packages.
2019-05-04 01:44:41 +03:00
EqualityFactI(summand1, actual1, $"Expected {summand1}, got {actual1}");
2019-03-15 21:04:17 +03:00
set actual2 = MeasureInteger(summand2LE);
Release v0.6 to master. (#98) * Begin refactoring standard libraries (#39) * Began splitting up namespaces. * Began refactoring tests. * Updated chemistry src and tests for new namespaces. * Remove unused opens. * Began renaming operations and functions. * Separated out and updated ApplyReversed*. * Updated BE ↔ LE type conversions. * Added new transformed operation fns. * Whitespace fix * Eliminated some redundant code in applyreversed * Fixed deprecation comments. * Began working on refactoring With. * Refactored With further. * More renaming for consistency with LE/BE suffix convention. * Added Zip3, Zip4 * Added shorthand for MAJ and updated some type conv. * Fixed a typo in Zip4. * Separated out and updated arithmetic measurements. * Other minor maintenance changes. * Started separating out modular arithmetic. * Began refactoring ripple-carry comparators. * Refactored integer increment operations. * Fixed some See Also blocks. * Some minor progress. * Moved new arithmetic functionality into right folders. * Renamed integer arithmetic namespaces. * Split out qecc namespace. * Added documentation file for Microsoft.Quantum.ErrorCorrection. * Progress on renaming type conversion functions. * More progress on updating type conversion names. * Split out AA namespace. * Split out oracles namespace as well. * Renamed UDTs to remove "AmpAmp" prefix. This prefix is now implied by the Microsoft.Quantum.AmplitudeAmplification namespace. * Renamed some Qecc operations/fns * Moved more conversions into Convert.qs. * Updated some deprecated syntax. * Split out M.Q.Convert. * Added missing open stmt. * Started separating out classical math. * Began separating out QCVV. * Fixing namespaces in tests. * Update to use new docgen. * Began making arrays namespace. * Updated to use new arrays and diagnostics namespaces. * Updated names for claims * Started extracting measurements from Paulis.qs. * Updated namespaces in tests as well. * Updating chemistry for most recent changes. * Added ForEach, used to simplify measurements. * Updating deprecated Q# syntax. * Minor fix for XML error. * Fixed infinite recursion in deprecation stubs. * Started trying to reduce # of warnings. * Fixed some minor build errors. * Resolved a couple TODOs. * Removed BigEndian support. * Resolved warnings due to && and ||. * Update Standard/src/Arithmetic/Shorthand.qs Co-Authored-By: cgranade <cgranade@gmail.com> * Addressing feedback. * Claim → Fact * Moved MeasureInteger back to Microsoft.Quantum.Arithmetic. * Resolved more deprecated syntax. * Removed one more LE suffix. * Addressing feedback. * Cgranade/complete 0.6 move (#57) * Revert "Begin refactoring standard libraries (#39)" (#56) As Chris pointed out, reverting these breaking changes until we have a chance to change everything... * Complete move of standard library refactoring to release branch This reverts commit 058048983c4d0509e5d522888d3d47ae49cd300e. * Explicitly qualify all names in M.Q.Ext.Math. (#74) * Explicitly qualify all names in M.Q.Ext.Math. * Fixed two missing qualified names. * Removed more occurances of M.Q.Ext.Math. * Removed Microsoft.Quantum.Extensions.Math from tests as well. * Reverted slight change to QuantumROM. * New array functions (#75) * Added new IndexRange function to eliminate `-1` in for loops. * Added some missing open statements. * New Enumerated function. * Port library and test code to new 0.6 names to reduce warning count. (#72) * Updating to use new syntax, namespace names, etc. * More primitive → intrinsic. * Updated test project to use beta version. * Updated chemistry proiects to beta. * Finding a few more calls to deprecated fns. * Cleaned up some assert and qcvv tests. * Removed uses of deprecated IntArrayFromRange * Resolved some more deprecated functions and ops. * Minor maintenance in QubitizationTests. * Bumped versions to latest beta. * Some trivial change to retrigger build. * Resolved package downgrade. * Move Microsoft.Quantum.Math.Complex UDT and resolve Microsoft.Quantum.Diagnostics deprecation stubs. (#77) * More primitive → intrinsic. * Finding a few more calls to deprecated fns. * Resolved some more deprecated functions and ops. * Minor maintenance in QubitizationTests. * Bumped versions to latest beta. * Resolved package downgrade. * Use Complex UDT at its new name. * Adapted tests. * A few more test adaptations. * Updated name of AssertQubitState to 0.6 name. * Fixes to chemistry. * Getting updates from master (#80) * Revert "Begin refactoring standard libraries (#39)" (#56) As Chris pointed out, reverting these breaking changes until we have a chance to change everything... * Missing return statement when compiling more than one Q# snippet from Python. (#60) * Fixing bug * Adding tests * Change Assembly.Version to Python.Version. (#64) * Prevent loading Q# modules when Python client is busy. (#71) * Prevent loading Q# modules when Python client is busy. * Linux build failed with some unrelated problem. Committing. * modifying contructor calls for QArray in preparation for a simulation framework change (#78) * Revert "Revert "Begin refactoring standard libraries (#39)" (#56)" This reverts commit 058048983c4d0509e5d522888d3d47ae49cd300e. * Update to 0.6.1904.1302-beta. (#81) * Update to 0.6.1904.1302-beta. * Removed deprecation warnings for Microsoft.Quantum.Math. * Resolved a few more deprecations. * Resolved a few more deprecation warnings. * A few more deprecation resolutions. * Removed some duplicate namespace opens. * Slight code cleanup. * Addressed feedback from @bettinaheim. * Standard.sln builds again, Standard.sln builds (#84) * Gulow/v0.6 chemistry deprecation (#82) * Update to 0.6.1904.1302-beta. * Removed deprecation warnings for Microsoft.Quantum.Math. * Resolved a few more deprecations. * Resolved a few more deprecation warnings. * A few more deprecation resolutions. * Removed some duplicate namespace opens. * Slight code cleanup. * Update test * . * Remove deprecated operations from chemistry and dependencies. * Fix comments * Update to use 0.65 syntax from latest beta. (#87) * Ported stateprep.qs to 0.65 syntax. * Fixed deprecation in test. * Updated to latest beta. * Fix mutable array issue in chemistry data model. (#88) * Explicitly call new QArray. (#89) * do not rely on collections.immutable (#93) * Continue migrating libraries to Q# 0.6 (#91) * Continue migrating to 0.65 syntax and applying style guidance. * A bit more progress normalizing private names. * Resolved more deprecated syntax, updated a name. * Resolved some more syntax warnings. * Ported more syntax and updated more names. * Resolved all remaining compile-time warnings in Standard. * Addressed all Q#-level compile-time warnings in chem. * Migrated a bit more syntax and updated to newest beta. * Moved to using intrinsic warnings. * Fixed endianness of exact QFT. * Fixed Microsoft.Quantum.Warnings. * Addressing @bettinaheim's feedback. * Removed some warnings in unit tests. * Adding DocsOutDir for single doc output location across projects. (#94) * Adding DocsOutDir for single doc output location across projects. * Begin adding more classical math functions for BigInt. (#96) * Begin adding more classical math functions for BigInt. * Addressing @beheim's feedback. * Minor fixes. * Bump to latest beta. * Fixed two minor bugs. * Fixed the type of signs. * Bump version to released packages.
2019-05-04 01:44:41 +03:00
EqualityFactI(expected, actual2, $"Expected {expected}, got {actual2}");
ResetAll(controls);
2019-03-15 21:04:17 +03:00
}
}
internal operation IntegerAdderNoCarryExhaustiveTestHelper (IntegerAdder : ( (LittleEndian, LittleEndian) => Unit is Ctl), numberOfQubits : Int) : Unit {
for summand1 in 0 .. 2^numberOfQubits - 1 {
for summand2 in 0 .. 2^numberOfQubits - 1 {
2019-03-15 21:04:17 +03:00
IntegerAdderNoCarryTestHelper(IntegerAdder, summand1, summand2, numberOfQubits);
}
}
}
@Test("ToffoliSimulator")
2019-03-15 21:04:17 +03:00
operation RippleCarryAdderNoCarryTTKTestReversible () : Unit {
let numberOfQubits = 10;
Code quality improvements (#203) * Improve code quality with experimental linter. * Fixed a couple mistakes in previous cleanup. * More fixes to resolve linting issues. * Remove extraneous comment. * Applied feedback from #198. * Applying more documentation fixes suggested by linter. * Fix to deprecation stub. * Whitespace fix noted by @ScottCarda-MS. * Fixed minor mistake introduced with previous code quality fix. * Incorporated more feedback from @ScottCarda-MS. * Update Standard/src/Arrays/Map.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Canon/Combinators/ApplyIf.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Update Standard/src/Arithmetic/Integer.qs Co-Authored-By: Alan Geller <alan.geller@microsoft.com> * Addressing feedback, lots of indentation fixes. * Deprecate the stack data structure. * Slight improvements to phase est operations. * Add missing characteristics to CNOTChainTarget. * CCNOTChainTarget → ApplyCNOTChainWithTarget * Workaround for kata oracle counting. Co-authored-by: Alan Geller <alan.geller@microsoft.com>
2020-01-15 23:14:02 +03:00
let summand1 = 1021;
let summand2 = 973;
2019-03-15 21:04:17 +03:00
IntegerAdderNoCarryTestHelper(RippleCarryAdderNoCarryTTK, summand1, summand2, numberOfQubits);
}
@Test("ToffoliSimulator")
2019-03-15 21:04:17 +03:00
operation RippleCarryAdderNoCarryTTKExhaustiveTest () : Unit {
let numberOfQubits = 4;
IntegerAdderNoCarryExhaustiveTestHelper (RippleCarryAdderNoCarryTTK, numberOfQubits);
}
@Test("ToffoliSimulator")
2019-03-15 21:04:17 +03:00
operation RippleCarryAdderNoCarryTTKExhaustiveTestReversible () : Unit {
for numberOfQubits in [1, 3, 6] {
2019-03-15 21:04:17 +03:00
IntegerAdderNoCarryExhaustiveTestHelper (RippleCarryAdderNoCarryTTK, numberOfQubits);
}
}
internal operation GreaterThanTestHelper( integer1 : Int, integer2 : Int, numberOfQubits : Int ) : Unit {
use register = Qubit[2*numberOfQubits+1];
mutable actual1 = 0;
mutable actual2 = 0;
mutable actualr = Zero;
mutable gt = Zero;
let integer1LE = LittleEndian(register[0 .. numberOfQubits - 1]);
let integer2LE = LittleEndian(register[numberOfQubits .. 2*numberOfQubits - 1]);
let result = register[2*numberOfQubits];
ApplyXorInPlace(integer1, integer1LE);
ApplyXorInPlace(integer2, integer2LE);
GreaterThan(integer1LE, integer2LE, result);
if (integer1 > integer2) {set gt = One;}
set actual1 = MeasureInteger(integer1LE);
EqualityFactI(integer1, actual1, $"Expected {integer1}, got {actual1}");
set actual2 = MeasureInteger(integer2LE);
EqualityFactI(integer2, actual2, $"Expected {integer2}, got {actual2}");
set actualr = M(result);
EqualityFactB((gt == actualr), true, $"Expected {gt}, got {actualr}");
Reset(result);
for numberOfControls in 1..2 {
use controls = Qubit[numberOfControls];
ApplyXorInPlace(integer1, integer1LE);
ApplyXorInPlace(integer2, integer2LE);
(Controlled GreaterThan) (controls, (integer1LE, integer2LE, result));
2019-03-15 21:04:17 +03:00
set actual1 = MeasureInteger(integer1LE);
EqualityFactI(integer1, actual1, $"Expected {integer1}, got {actual1}");
set actual2 = MeasureInteger(integer2LE);
EqualityFactI(integer2, actual2, $"Expected {integer2}, got {actual2}");
set actualr = M(result);
EqualityFactB((actualr == Zero), true, $"Expected Zero, got {actualr}");
ApplyToEach(X, controls);
ApplyXorInPlace(integer1, integer1LE);
ApplyXorInPlace(integer2, integer2LE);
(Controlled GreaterThan) (controls, (integer1LE, integer2LE, result));
2019-03-15 21:04:17 +03:00
set actual1 = MeasureInteger(integer1LE);
Release v0.6 to master. (#98) * Begin refactoring standard libraries (#39) * Began splitting up namespaces. * Began refactoring tests. * Updated chemistry src and tests for new namespaces. * Remove unused opens. * Began renaming operations and functions. * Separated out and updated ApplyReversed*. * Updated BE ↔ LE type conversions. * Added new transformed operation fns. * Whitespace fix * Eliminated some redundant code in applyreversed * Fixed deprecation comments. * Began working on refactoring With. * Refactored With further. * More renaming for consistency with LE/BE suffix convention. * Added Zip3, Zip4 * Added shorthand for MAJ and updated some type conv. * Fixed a typo in Zip4. * Separated out and updated arithmetic measurements. * Other minor maintenance changes. * Started separating out modular arithmetic. * Began refactoring ripple-carry comparators. * Refactored integer increment operations. * Fixed some See Also blocks. * Some minor progress. * Moved new arithmetic functionality into right folders. * Renamed integer arithmetic namespaces. * Split out qecc namespace. * Added documentation file for Microsoft.Quantum.ErrorCorrection. * Progress on renaming type conversion functions. * More progress on updating type conversion names. * Split out AA namespace. * Split out oracles namespace as well. * Renamed UDTs to remove "AmpAmp" prefix. This prefix is now implied by the Microsoft.Quantum.AmplitudeAmplification namespace. * Renamed some Qecc operations/fns * Moved more conversions into Convert.qs. * Updated some deprecated syntax. * Split out M.Q.Convert. * Added missing open stmt. * Started separating out classical math. * Began separating out QCVV. * Fixing namespaces in tests. * Update to use new docgen. * Began making arrays namespace. * Updated to use new arrays and diagnostics namespaces. * Updated names for claims * Started extracting measurements from Paulis.qs. * Updated namespaces in tests as well. * Updating chemistry for most recent changes. * Added ForEach, used to simplify measurements. * Updating deprecated Q# syntax. * Minor fix for XML error. * Fixed infinite recursion in deprecation stubs. * Started trying to reduce # of warnings. * Fixed some minor build errors. * Resolved a couple TODOs. * Removed BigEndian support. * Resolved warnings due to && and ||. * Update Standard/src/Arithmetic/Shorthand.qs Co-Authored-By: cgranade <cgranade@gmail.com> * Addressing feedback. * Claim → Fact * Moved MeasureInteger back to Microsoft.Quantum.Arithmetic. * Resolved more deprecated syntax. * Removed one more LE suffix. * Addressing feedback. * Cgranade/complete 0.6 move (#57) * Revert "Begin refactoring standard libraries (#39)" (#56) As Chris pointed out, reverting these breaking changes until we have a chance to change everything... * Complete move of standard library refactoring to release branch This reverts commit 058048983c4d0509e5d522888d3d47ae49cd300e. * Explicitly qualify all names in M.Q.Ext.Math. (#74) * Explicitly qualify all names in M.Q.Ext.Math. * Fixed two missing qualified names. * Removed more occurances of M.Q.Ext.Math. * Removed Microsoft.Quantum.Extensions.Math from tests as well. * Reverted slight change to QuantumROM. * New array functions (#75) * Added new IndexRange function to eliminate `-1` in for loops. * Added some missing open statements. * New Enumerated function. * Port library and test code to new 0.6 names to reduce warning count. (#72) * Updating to use new syntax, namespace names, etc. * More primitive → intrinsic. * Updated test project to use beta version. * Updated chemistry proiects to beta. * Finding a few more calls to deprecated fns. * Cleaned up some assert and qcvv tests. * Removed uses of deprecated IntArrayFromRange * Resolved some more deprecated functions and ops. * Minor maintenance in QubitizationTests. * Bumped versions to latest beta. * Some trivial change to retrigger build. * Resolved package downgrade. * Move Microsoft.Quantum.Math.Complex UDT and resolve Microsoft.Quantum.Diagnostics deprecation stubs. (#77) * More primitive → intrinsic. * Finding a few more calls to deprecated fns. * Resolved some more deprecated functions and ops. * Minor maintenance in QubitizationTests. * Bumped versions to latest beta. * Resolved package downgrade. * Use Complex UDT at its new name. * Adapted tests. * A few more test adaptations. * Updated name of AssertQubitState to 0.6 name. * Fixes to chemistry. * Getting updates from master (#80) * Revert "Begin refactoring standard libraries (#39)" (#56) As Chris pointed out, reverting these breaking changes until we have a chance to change everything... * Missing return statement when compiling more than one Q# snippet from Python. (#60) * Fixing bug * Adding tests * Change Assembly.Version to Python.Version. (#64) * Prevent loading Q# modules when Python client is busy. (#71) * Prevent loading Q# modules when Python client is busy. * Linux build failed with some unrelated problem. Committing. * modifying contructor calls for QArray in preparation for a simulation framework change (#78) * Revert "Revert "Begin refactoring standard libraries (#39)" (#56)" This reverts commit 058048983c4d0509e5d522888d3d47ae49cd300e. * Update to 0.6.1904.1302-beta. (#81) * Update to 0.6.1904.1302-beta. * Removed deprecation warnings for Microsoft.Quantum.Math. * Resolved a few more deprecations. * Resolved a few more deprecation warnings. * A few more deprecation resolutions. * Removed some duplicate namespace opens. * Slight code cleanup. * Addressed feedback from @bettinaheim. * Standard.sln builds again, Standard.sln builds (#84) * Gulow/v0.6 chemistry deprecation (#82) * Update to 0.6.1904.1302-beta. * Removed deprecation warnings for Microsoft.Quantum.Math. * Resolved a few more deprecations. * Resolved a few more deprecation warnings. * A few more deprecation resolutions. * Removed some duplicate namespace opens. * Slight code cleanup. * Update test * . * Remove deprecated operations from chemistry and dependencies. * Fix comments * Update to use 0.65 syntax from latest beta. (#87) * Ported stateprep.qs to 0.65 syntax. * Fixed deprecation in test. * Updated to latest beta. * Fix mutable array issue in chemistry data model. (#88) * Explicitly call new QArray. (#89) * do not rely on collections.immutable (#93) * Continue migrating libraries to Q# 0.6 (#91) * Continue migrating to 0.65 syntax and applying style guidance. * A bit more progress normalizing private names. * Resolved more deprecated syntax, updated a name. * Resolved some more syntax warnings. * Ported more syntax and updated more names. * Resolved all remaining compile-time warnings in Standard. * Addressed all Q#-level compile-time warnings in chem. * Migrated a bit more syntax and updated to newest beta. * Moved to using intrinsic warnings. * Fixed endianness of exact QFT. * Fixed Microsoft.Quantum.Warnings. * Addressing @bettinaheim's feedback. * Removed some warnings in unit tests. * Adding DocsOutDir for single doc output location across projects. (#94) * Adding DocsOutDir for single doc output location across projects. * Begin adding more classical math functions for BigInt. (#96) * Begin adding more classical math functions for BigInt. * Addressing @beheim's feedback. * Minor fixes. * Bump to latest beta. * Fixed two minor bugs. * Fixed the type of signs. * Bump version to released packages.
2019-05-04 01:44:41 +03:00
EqualityFactI(integer1, actual1, $"Expected {integer1}, got {actual1}");
2019-03-15 21:04:17 +03:00
set actual2 = MeasureInteger(integer2LE);
Release v0.6 to master. (#98) * Begin refactoring standard libraries (#39) * Began splitting up namespaces. * Began refactoring tests. * Updated chemistry src and tests for new namespaces. * Remove unused opens. * Began renaming operations and functions. * Separated out and updated ApplyReversed*. * Updated BE ↔ LE type conversions. * Added new transformed operation fns. * Whitespace fix * Eliminated some redundant code in applyreversed * Fixed deprecation comments. * Began working on refactoring With. * Refactored With further. * More renaming for consistency with LE/BE suffix convention. * Added Zip3, Zip4 * Added shorthand for MAJ and updated some type conv. * Fixed a typo in Zip4. * Separated out and updated arithmetic measurements. * Other minor maintenance changes. * Started separating out modular arithmetic. * Began refactoring ripple-carry comparators. * Refactored integer increment operations. * Fixed some See Also blocks. * Some minor progress. * Moved new arithmetic functionality into right folders. * Renamed integer arithmetic namespaces. * Split out qecc namespace. * Added documentation file for Microsoft.Quantum.ErrorCorrection. * Progress on renaming type conversion functions. * More progress on updating type conversion names. * Split out AA namespace. * Split out oracles namespace as well. * Renamed UDTs to remove "AmpAmp" prefix. This prefix is now implied by the Microsoft.Quantum.AmplitudeAmplification namespace. * Renamed some Qecc operations/fns * Moved more conversions into Convert.qs. * Updated some deprecated syntax. * Split out M.Q.Convert. * Added missing open stmt. * Started separating out classical math. * Began separating out QCVV. * Fixing namespaces in tests. * Update to use new docgen. * Began making arrays namespace. * Updated to use new arrays and diagnostics namespaces. * Updated names for claims * Started extracting measurements from Paulis.qs. * Updated namespaces in tests as well. * Updating chemistry for most recent changes. * Added ForEach, used to simplify measurements. * Updating deprecated Q# syntax. * Minor fix for XML error. * Fixed infinite recursion in deprecation stubs. * Started trying to reduce # of warnings. * Fixed some minor build errors. * Resolved a couple TODOs. * Removed BigEndian support. * Resolved warnings due to && and ||. * Update Standard/src/Arithmetic/Shorthand.qs Co-Authored-By: cgranade <cgranade@gmail.com> * Addressing feedback. * Claim → Fact * Moved MeasureInteger back to Microsoft.Quantum.Arithmetic. * Resolved more deprecated syntax. * Removed one more LE suffix. * Addressing feedback. * Cgranade/complete 0.6 move (#57) * Revert "Begin refactoring standard libraries (#39)" (#56) As Chris pointed out, reverting these breaking changes until we have a chance to change everything... * Complete move of standard library refactoring to release branch This reverts commit 058048983c4d0509e5d522888d3d47ae49cd300e. * Explicitly qualify all names in M.Q.Ext.Math. (#74) * Explicitly qualify all names in M.Q.Ext.Math. * Fixed two missing qualified names. * Removed more occurances of M.Q.Ext.Math. * Removed Microsoft.Quantum.Extensions.Math from tests as well. * Reverted slight change to QuantumROM. * New array functions (#75) * Added new IndexRange function to eliminate `-1` in for loops. * Added some missing open statements. * New Enumerated function. * Port library and test code to new 0.6 names to reduce warning count. (#72) * Updating to use new syntax, namespace names, etc. * More primitive → intrinsic. * Updated test project to use beta version. * Updated chemistry proiects to beta. * Finding a few more calls to deprecated fns. * Cleaned up some assert and qcvv tests. * Removed uses of deprecated IntArrayFromRange * Resolved some more deprecated functions and ops. * Minor maintenance in QubitizationTests. * Bumped versions to latest beta. * Some trivial change to retrigger build. * Resolved package downgrade. * Move Microsoft.Quantum.Math.Complex UDT and resolve Microsoft.Quantum.Diagnostics deprecation stubs. (#77) * More primitive → intrinsic. * Finding a few more calls to deprecated fns. * Resolved some more deprecated functions and ops. * Minor maintenance in QubitizationTests. * Bumped versions to latest beta. * Resolved package downgrade. * Use Complex UDT at its new name. * Adapted tests. * A few more test adaptations. * Updated name of AssertQubitState to 0.6 name. * Fixes to chemistry. * Getting updates from master (#80) * Revert "Begin refactoring standard libraries (#39)" (#56) As Chris pointed out, reverting these breaking changes until we have a chance to change everything... * Missing return statement when compiling more than one Q# snippet from Python. (#60) * Fixing bug * Adding tests * Change Assembly.Version to Python.Version. (#64) * Prevent loading Q# modules when Python client is busy. (#71) * Prevent loading Q# modules when Python client is busy. * Linux build failed with some unrelated problem. Committing. * modifying contructor calls for QArray in preparation for a simulation framework change (#78) * Revert "Revert "Begin refactoring standard libraries (#39)" (#56)" This reverts commit 058048983c4d0509e5d522888d3d47ae49cd300e. * Update to 0.6.1904.1302-beta. (#81) * Update to 0.6.1904.1302-beta. * Removed deprecation warnings for Microsoft.Quantum.Math. * Resolved a few more deprecations. * Resolved a few more deprecation warnings. * A few more deprecation resolutions. * Removed some duplicate namespace opens. * Slight code cleanup. * Addressed feedback from @bettinaheim. * Standard.sln builds again, Standard.sln builds (#84) * Gulow/v0.6 chemistry deprecation (#82) * Update to 0.6.1904.1302-beta. * Removed deprecation warnings for Microsoft.Quantum.Math. * Resolved a few more deprecations. * Resolved a few more deprecation warnings. * A few more deprecation resolutions. * Removed some duplicate namespace opens. * Slight code cleanup. * Update test * . * Remove deprecated operations from chemistry and dependencies. * Fix comments * Update to use 0.65 syntax from latest beta. (#87) * Ported stateprep.qs to 0.65 syntax. * Fixed deprecation in test. * Updated to latest beta. * Fix mutable array issue in chemistry data model. (#88) * Explicitly call new QArray. (#89) * do not rely on collections.immutable (#93) * Continue migrating libraries to Q# 0.6 (#91) * Continue migrating to 0.65 syntax and applying style guidance. * A bit more progress normalizing private names. * Resolved more deprecated syntax, updated a name. * Resolved some more syntax warnings. * Ported more syntax and updated more names. * Resolved all remaining compile-time warnings in Standard. * Addressed all Q#-level compile-time warnings in chem. * Migrated a bit more syntax and updated to newest beta. * Moved to using intrinsic warnings. * Fixed endianness of exact QFT. * Fixed Microsoft.Quantum.Warnings. * Addressing @bettinaheim's feedback. * Removed some warnings in unit tests. * Adding DocsOutDir for single doc output location across projects. (#94) * Adding DocsOutDir for single doc output location across projects. * Begin adding more classical math functions for BigInt. (#96) * Begin adding more classical math functions for BigInt. * Addressing @beheim's feedback. * Minor fixes. * Bump to latest beta. * Fixed two minor bugs. * Fixed the type of signs. * Bump version to released packages.
2019-05-04 01:44:41 +03:00
EqualityFactI(integer2, actual2, $"Expected {integer2}, got {actual2}");
2019-03-15 21:04:17 +03:00
set actualr = M(result);
Release v0.6 to master. (#98) * Begin refactoring standard libraries (#39) * Began splitting up namespaces. * Began refactoring tests. * Updated chemistry src and tests for new namespaces. * Remove unused opens. * Began renaming operations and functions. * Separated out and updated ApplyReversed*. * Updated BE ↔ LE type conversions. * Added new transformed operation fns. * Whitespace fix * Eliminated some redundant code in applyreversed * Fixed deprecation comments. * Began working on refactoring With. * Refactored With further. * More renaming for consistency with LE/BE suffix convention. * Added Zip3, Zip4 * Added shorthand for MAJ and updated some type conv. * Fixed a typo in Zip4. * Separated out and updated arithmetic measurements. * Other minor maintenance changes. * Started separating out modular arithmetic. * Began refactoring ripple-carry comparators. * Refactored integer increment operations. * Fixed some See Also blocks. * Some minor progress. * Moved new arithmetic functionality into right folders. * Renamed integer arithmetic namespaces. * Split out qecc namespace. * Added documentation file for Microsoft.Quantum.ErrorCorrection. * Progress on renaming type conversion functions. * More progress on updating type conversion names. * Split out AA namespace. * Split out oracles namespace as well. * Renamed UDTs to remove "AmpAmp" prefix. This prefix is now implied by the Microsoft.Quantum.AmplitudeAmplification namespace. * Renamed some Qecc operations/fns * Moved more conversions into Convert.qs. * Updated some deprecated syntax. * Split out M.Q.Convert. * Added missing open stmt. * Started separating out classical math. * Began separating out QCVV. * Fixing namespaces in tests. * Update to use new docgen. * Began making arrays namespace. * Updated to use new arrays and diagnostics namespaces. * Updated names for claims * Started extracting measurements from Paulis.qs. * Updated namespaces in tests as well. * Updating chemistry for most recent changes. * Added ForEach, used to simplify measurements. * Updating deprecated Q# syntax. * Minor fix for XML error. * Fixed infinite recursion in deprecation stubs. * Started trying to reduce # of warnings. * Fixed some minor build errors. * Resolved a couple TODOs. * Removed BigEndian support. * Resolved warnings due to && and ||. * Update Standard/src/Arithmetic/Shorthand.qs Co-Authored-By: cgranade <cgranade@gmail.com> * Addressing feedback. * Claim → Fact * Moved MeasureInteger back to Microsoft.Quantum.Arithmetic. * Resolved more deprecated syntax. * Removed one more LE suffix. * Addressing feedback. * Cgranade/complete 0.6 move (#57) * Revert "Begin refactoring standard libraries (#39)" (#56) As Chris pointed out, reverting these breaking changes until we have a chance to change everything... * Complete move of standard library refactoring to release branch This reverts commit 058048983c4d0509e5d522888d3d47ae49cd300e. * Explicitly qualify all names in M.Q.Ext.Math. (#74) * Explicitly qualify all names in M.Q.Ext.Math. * Fixed two missing qualified names. * Removed more occurances of M.Q.Ext.Math. * Removed Microsoft.Quantum.Extensions.Math from tests as well. * Reverted slight change to QuantumROM. * New array functions (#75) * Added new IndexRange function to eliminate `-1` in for loops. * Added some missing open statements. * New Enumerated function. * Port library and test code to new 0.6 names to reduce warning count. (#72) * Updating to use new syntax, namespace names, etc. * More primitive → intrinsic. * Updated test project to use beta version. * Updated chemistry proiects to beta. * Finding a few more calls to deprecated fns. * Cleaned up some assert and qcvv tests. * Removed uses of deprecated IntArrayFromRange * Resolved some more deprecated functions and ops. * Minor maintenance in QubitizationTests. * Bumped versions to latest beta. * Some trivial change to retrigger build. * Resolved package downgrade. * Move Microsoft.Quantum.Math.Complex UDT and resolve Microsoft.Quantum.Diagnostics deprecation stubs. (#77) * More primitive → intrinsic. * Finding a few more calls to deprecated fns. * Resolved some more deprecated functions and ops. * Minor maintenance in QubitizationTests. * Bumped versions to latest beta. * Resolved package downgrade. * Use Complex UDT at its new name. * Adapted tests. * A few more test adaptations. * Updated name of AssertQubitState to 0.6 name. * Fixes to chemistry. * Getting updates from master (#80) * Revert "Begin refactoring standard libraries (#39)" (#56) As Chris pointed out, reverting these breaking changes until we have a chance to change everything... * Missing return statement when compiling more than one Q# snippet from Python. (#60) * Fixing bug * Adding tests * Change Assembly.Version to Python.Version. (#64) * Prevent loading Q# modules when Python client is busy. (#71) * Prevent loading Q# modules when Python client is busy. * Linux build failed with some unrelated problem. Committing. * modifying contructor calls for QArray in preparation for a simulation framework change (#78) * Revert "Revert "Begin refactoring standard libraries (#39)" (#56)" This reverts commit 058048983c4d0509e5d522888d3d47ae49cd300e. * Update to 0.6.1904.1302-beta. (#81) * Update to 0.6.1904.1302-beta. * Removed deprecation warnings for Microsoft.Quantum.Math. * Resolved a few more deprecations. * Resolved a few more deprecation warnings. * A few more deprecation resolutions. * Removed some duplicate namespace opens. * Slight code cleanup. * Addressed feedback from @bettinaheim. * Standard.sln builds again, Standard.sln builds (#84) * Gulow/v0.6 chemistry deprecation (#82) * Update to 0.6.1904.1302-beta. * Removed deprecation warnings for Microsoft.Quantum.Math. * Resolved a few more deprecations. * Resolved a few more deprecation warnings. * A few more deprecation resolutions. * Removed some duplicate namespace opens. * Slight code cleanup. * Update test * . * Remove deprecated operations from chemistry and dependencies. * Fix comments * Update to use 0.65 syntax from latest beta. (#87) * Ported stateprep.qs to 0.65 syntax. * Fixed deprecation in test. * Updated to latest beta. * Fix mutable array issue in chemistry data model. (#88) * Explicitly call new QArray. (#89) * do not rely on collections.immutable (#93) * Continue migrating libraries to Q# 0.6 (#91) * Continue migrating to 0.65 syntax and applying style guidance. * A bit more progress normalizing private names. * Resolved more deprecated syntax, updated a name. * Resolved some more syntax warnings. * Ported more syntax and updated more names. * Resolved all remaining compile-time warnings in Standard. * Addressed all Q#-level compile-time warnings in chem. * Migrated a bit more syntax and updated to newest beta. * Moved to using intrinsic warnings. * Fixed endianness of exact QFT. * Fixed Microsoft.Quantum.Warnings. * Addressing @bettinaheim's feedback. * Removed some warnings in unit tests. * Adding DocsOutDir for single doc output location across projects. (#94) * Adding DocsOutDir for single doc output location across projects. * Begin adding more classical math functions for BigInt. (#96) * Begin adding more classical math functions for BigInt. * Addressing @beheim's feedback. * Minor fixes. * Bump to latest beta. * Fixed two minor bugs. * Fixed the type of signs. * Bump version to released packages.
2019-05-04 01:44:41 +03:00
EqualityFactB((gt == actualr), true, $"Expected {gt}, got {actualr}");
2019-03-15 21:04:17 +03:00
ResetAll(controls);
2019-03-15 21:04:17 +03:00
Reset(result);
}
}
@Test("ToffoliSimulator")
2019-03-15 21:04:17 +03:00
operation GreaterThanExhaustiveTestReversible () : Unit {
for numberOfQubits in 1..5 {
for integer1 in 0..2^numberOfQubits - 1 {
for integer2 in 0..2^numberOfQubits - 1 {
2019-03-15 21:04:17 +03:00
GreaterThanTestHelper(integer1, integer2, numberOfQubits);
}
}
}
}
}