Skip to content

Commit

Permalink
Merge pull request #151 from OriginQ/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
shenzhi-git authored Jun 18, 2021
2 parents 5a6cd16 + 1c189aa commit d851612
Show file tree
Hide file tree
Showing 273 changed files with 42,002 additions and 11,002 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ __pycache__/
CMakeSettings.json
*.dat
/mingw-build
/CMakeLists.txt.user
20 changes: 11 additions & 9 deletions Applications/B_V_Algorithm/BernsteinVaziraniAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
#include "Core/Core.h"
#include "QPanda.h"
#include "Utilities/Tools/Utils.h"
#include "QAlg/B_V_Algorithm/BernsteinVaziraniAlgorithm.h"
#include <bitset>
Expand All @@ -40,10 +41,9 @@ BV_Oracle generate_bv_oracle(vector<bool> oracle_function) {

int main()
{

while (1)
{
auto qvm = initQuantumMachine();
auto qvm = initQuantumMachine();
cout << "Bernstein Vazirani Algorithm\n" << endl;
cout << "f(x)=a*x+b\n" << endl;
cout << "input a" << endl;
Expand All @@ -61,6 +61,7 @@ int main()
a.push_back(1);
}
}

cout << "input b" << endl;
bool b;
cin >> b;
Expand All @@ -71,13 +72,14 @@ int main()

auto oracle = generate_bv_oracle(a);
auto bvAlgorithm = bernsteinVaziraniAlgorithm(stra, b, qvm, oracle);
auto result = qvm->directlyRun(bvAlgorithm);
for(auto aiter : result)
{
std::cout << aiter.first<<" : "<<aiter.second << std::endl;
}
destroyQuantumMachine(qvm);
auto result = qvm->directlyRun(bvAlgorithm);

for (auto aiter : result)
{
std::cout << aiter.first << " : " << aiter.second << std::endl;
}
destroyQuantumMachine(qvm);
}

return 0;
}
4 changes: 2 additions & 2 deletions Applications/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ add_subdirectory(QuantumWalk)
add_subdirectory(SimonAlgorithm)
add_subdirectory(NodeSort)
add_subdirectory(QAOAExample)
add_subdirectory(OptimizerTest)
if(USE_CHEMIQ)
add_subdirectory(ChemiQCalc)
endif(USE_CHEMIQ)
add_subdirectory(QSpringRank)
endif(USE_CHEMIQ)
Loading

0 comments on commit d851612

Please sign in to comment.