MCPcopy Create free account
hub / github.com/OriginQ/QPanda-2 / main

Function main

Applications/Grover_Algorithm/Grover_Algorithm.cpp:268–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268int main(int argc, char* argv[])
269{
270 const std::string parameter_descr_str = R"(
271 The legal parameter form is as follows:
272 Grover_Algorithm.exe [Option] [search-space-file] [search-data]
273 Option:
274 -g: run Grover-search-algorithm
275 -c: run classcial-search-algorithm
276 -r: run quantum-walk-search-algorithm
277 example:
278 To search for 2 in data.txt use Grover-search-algorithm, execute the following command:
279 Grover_Algorithm.exe -g data.txt 2
280 data.txt:
281 2,4,12,23,1,2,3,4,3,3,21,8,
282 )";
283#if 0
284 /* read param
285 */
286 int search_type = -1; /**< 0: classcial-search-algorithm; 1:Grover-search-algorithm; 2:quantum-walk-search-algorithm */
287 std::string data_file = "";
288 std::vector<uint32_t> search_data;
289 try
290 {
291 if (argc >= 4)
292 {
293 if (0 == strcmp(argv[1], "-c")){
294 search_type = 0;
295 }
296 else if (0 == strcmp(argv[1], "-g")) {
297 search_type = 1;
298 }
299 else if (0 == strcmp(argv[1], "-r")) {
300 search_type = 2;
301 }
302 else{
303 QCERR_AND_THROW(init_fail, "Error: parameter error.");
304 }
305
306 data_file = argv[2];
307 cout << "search-space-file: " << data_file << endl;
308
309 for (size_t i = 3; i < argc; ++i){
310 search_data.emplace_back(atol(argv[i]));
311 }
312 cout << "search-data: ";
313 for (const auto& _data : search_data){
314 cout << _data << " ";
315 }
316 cout << endl;
317 }
318 else{
319 QCERR_AND_THROW(init_fail, "Error: parameter error.");
320 }
321 }
322 catch (...)
323 {
324 cout << "Parameter error." << parameter_descr_str << endl;
325 return -1;

Callers

nothing calls this directly

Calls 6

read_search_space_fileFunction · 0.85
classcial_searchFunction · 0.85
quantum_grover_searchFunction · 0.85
quantum_walk_searchFunction · 0.85
emplace_backMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected