Skip to content

Commit 32a2033

Browse files
committed
fixed a bug
1 parent 852a008 commit 32a2033

File tree

4 files changed

+34
-14
lines changed

4 files changed

+34
-14
lines changed

algorithms/hamiltonian_simulation/hamiltonian_simulation_with_block_encoding/hamiltonian_simulation_with_block_encoding.ipynb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,17 @@
473473
"\n",
474474
"\n",
475475
"@qfunc\n",
476+
"def my_reflect_about_zero(qba: QNum):\n",
477+
" control(qba == 0, lambda: phase(pi))\n",
478+
" phase(pi)\n",
479+
"\n",
480+
"\n",
481+
"@qfunc\n",
476482
"def walk_operator(\n",
477483
" be_qfunc: QCallable[BlockEncodedState], state: BlockEncodedState\n",
478484
") -> None:\n",
479485
" be_qfunc(state)\n",
480-
" control(state.block == 0, lambda: phase(pi))"
486+
" my_reflect_about_zero(state.block)"
481487
]
482488
},
483489
{

algorithms/quantum_phase_estimation/qpe_with_qubitization/qpe_for_molecule_with_qubitization.ipynb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,17 @@
359359
"\n",
360360
"\n",
361361
"@qfunc\n",
362+
"def my_reflect_about_zero(qba: QNum):\n",
363+
" control(qba == 0, lambda: phase(pi))\n",
364+
" phase(pi)\n",
365+
"\n",
366+
"\n",
367+
"@qfunc\n",
362368
"def walk_operator(\n",
363369
" be_qfunc: QCallable[BlockEncodedState], state: BlockEncodedState\n",
364370
") -> None:\n",
365371
" be_qfunc(state)\n",
366-
" control(state.block == 0, lambda: phase(pi))"
372+
" my_reflect_about_zero(state.block)"
367373
]
368374
},
369375
{

applications/cfd/qls_for_hybrid_solvers/qls_chebyshev_lcu.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
},
5151
{
5252
"cell_type": "code",
53-
"execution_count": 3,
53+
"execution_count": 4,
5454
"id": "3",
5555
"metadata": {},
5656
"outputs": [],
@@ -59,8 +59,9 @@
5959
"\n",
6060
"\n",
6161
"@qfunc\n",
62-
"def my_reflect_about_zero(qba: QArray):\n",
62+
"def my_reflect_about_zero(qba: QNum):\n",
6363
" control(qba == 0, lambda: phase(pi))\n",
64+
" phase(pi)\n",
6465
"\n",
6566
"\n",
6667
"@qfunc\n",

community/paper_implementation_project/quantum_state_preparation_without_coherent_arithmetic/stateprep_guassian_using_qsvt.ipynb

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"name": "stdout",
7979
"output_type": "stream",
8080
"text": [
81-
"0.98.0\n"
81+
"1.1.0\n"
8282
]
8383
}
8484
],
@@ -454,25 +454,32 @@
454454
},
455455
{
456456
"cell_type": "code",
457-
"execution_count": 10,
457+
"execution_count": 15,
458458
"id": "25",
459459
"metadata": {},
460460
"outputs": [],
461461
"source": [
462+
"from classiq.qmod.symbolic import pi\n",
463+
"\n",
464+
"\n",
462465
"@qfunc\n",
463466
"def state_prep(reg: MyQStruct):\n",
464467
" hadamard_transform(reg.x)\n",
465468
" u_f(reg)\n",
466469
"\n",
467470
"\n",
468471
"@qfunc\n",
472+
"def mark_zero_state(q: QNum):\n",
473+
" control(q == 0, lambda: phase(pi))\n",
474+
"\n",
475+
"\n",
476+
"@qfunc\n",
469477
"def u_amp(reg: MyQStruct):\n",
470478
" \"\"\"Amplitude amplification circuit for state preparation using QET (more generally, QSVT)\"\"\"\n",
471479
" exact_amplitude_amplification(\n",
472480
" amplitude=amp,\n",
473-
" oracle=lambda r: reflect_about_zero(\n",
474-
" r[reg.x.size : r.len]\n",
475-
" ), # Mark if the state is good state. Auxiliary qubits are |0> => good state\n",
481+
" # Mark if the state is good state. Auxiliary qubits are |0> => good state\n",
482+
" oracle=lambda r: mark_zero_state(r[reg.x.size : r.len]),\n",
476483
" space_transform=lambda _reg: state_prep(_reg),\n",
477484
" packed_qvars=[reg.x, reg.a1, reg.a2, reg.a3],\n",
478485
" )"
@@ -496,15 +503,15 @@
496503
},
497504
{
498505
"cell_type": "code",
499-
"execution_count": 11,
506+
"execution_count": 16,
500507
"id": "28",
501508
"metadata": {},
502509
"outputs": [
503510
{
504511
"name": "stdout",
505512
"output_type": "stream",
506513
"text": [
507-
"Quantum program link: https://platform.classiq.io/circuit/35YpmHOXeOGaZFnfA6v7HWDqmsS\n"
514+
"Quantum program link: https://platform.classiq.io/circuit/3A6ojZBlJr4z9V2zIN2pZCip4xE\n"
508515
]
509516
}
510517
],
@@ -540,7 +547,7 @@
540547
},
541548
{
542549
"cell_type": "code",
543-
"execution_count": 12,
550+
"execution_count": 17,
544551
"id": "29",
545552
"metadata": {},
546553
"outputs": [
@@ -558,8 +565,8 @@
558565
"name": "stdout",
559566
"output_type": "stream",
560567
"text": [
561-
"Mean Squared Error (MSE): 2.2611239359570596e-11\n",
562-
"{'depth': 7511, 'width': 14, 'cx_count': 4073}\n"
568+
"Mean Squared Error (MSE): 2.2611239362935673e-11\n",
569+
"{'depth': 8000, 'width': 12, 'cx_count': 4573}\n"
563570
]
564571
}
565572
],

0 commit comments

Comments
 (0)