Abstract
In the domain of quantum computing, two widely employed techniques for encoding a normalized vector of length N, denoted as \(\{ \alpha _i \}\), are one-hot encoding and binary encoding. The one-hot encoding state is represented as \(\vert \psi _{OH}^{(N)} \rangle \) and can be expressed as: \(\vert \psi _{OH}^{(N)} \rangle =\sum _{i=0}^{N-1} \alpha _i \vert 0 \rangle ^{\otimes N-i-1} \vert 1 \rangle \vert 0 \rangle ^{\otimes i}\). On the other hand, the binary encoding state is symbolized as \(\vert \psi _{BI}^{(N)} \rangle \) and is defined as: \(\vert \psi _{BI}^{(N)} \rangle =\sum _{i=0}^{N-1} \alpha _i \vert b_i \rangle \), where \(b_i\) corresponds to the binary representation of i. In this paper, we introduce a method for converting between the one-hot encoding state and the binary encoding state, utilizing the Domain Wall state as an intermediary. The Domain Wall state, denoted as \(\vert \psi _{DW}^{(N)} \rangle \), is defined as: \(\vert \psi _{DW}^{(N)} \rangle =\sum _{i=0}^{N-1} \alpha _i \vert 0 \rangle ^{\otimes N-i-1} \vert 1 \rangle ^{\otimes i}\). Our proposed circuit achieves a depth of \(O(\log ^2 N)\) and a size of O(N).Kindly check and confirm that the corresponding author mail id is correctly identified.











Similar content being viewed by others
Explore related subjects
Discover the latest articles, news and stories from top researchers in related subjects.Data availability
Data sharing is not applicable to this article as no datasets were generated or analyzed during the current study.
Notes
All circuit depths in this paper are defined as the length of the longest path within the circuit, while circuit sizes denote the total count of gates after decomposing the circuit into CNOT gates and U3 gates.
Here, “odd” refers to the qubit number rather than the index i.
If \(N \ne 2^{2k}\) for some integer k, more ancillas would be needed.
A extra ancillary qubits should added to \(U_O^{(N+1)}\) if the one-hot encoding state is required.
References
Grover, L., Rudolph, T.: Creating superpositions that correspond to efficiently integrable probability distributions. arXiv:quant-ph/0208112. Accessed 31 Dec 2021
Möttönen, M., Vartiainen, J.J., Bergholm, V., Salomaa, M.M.: Transformation of quantum states using uniformly controlled rotations. 5(6), 467–473 (2004). https://doi.org/10.26421/QIC5.6-5
Iten, R., Colbeck, R., Kukuljan, I., Home, J., Christandl, M.: Quantum circuits for isometries. Phys. Rev. A 93(3), 032318 (2016). https://doi.org/10.1103/PhysRevA.93.032318. Accessed 31 Dec 2021
Plesch, M., Brukner, icv: Quantum-state preparation with universal gate decompositions. Phys. Rev. A 83, 032302 (2011). https://doi.org/10.1103/PhysRevA.83.032302
Mottonen, M., Vartiainen, J.J.: Decompositions of general quantum gates. arXiv:quant-ph/0504100 (2005)
Harrow, A.W., Hassidim, A., Lloyd, S.: Quantum algorithm for linear systems of equations. Phys. Rev. Lett. 103(15), 150502 (2009). https://doi.org/10.1103/PhysRevLett.103.150502. Accessed 31 Dec 2021
Cong, I., Duan, L.: Quantum discriminant analysis for dimensionality reduction and classification. New J, Phys. 18(7), 073011 (2016). https://doi.org/10.1088/1367-2630/18/7/073011. Accessed 31 Dec 2021
Kerenidis, I., Luongo, A.: Classification of the mnist data set with quantum slow feature analysis. Phys. Rev. A 101, 062327 (2020). https://doi.org/10.1103/PhysRevA.101.062327
Zhao, Z., Fitzsimons, J.K., Rebentrost, P., Dunjko, V., Fitzsimons, J.F.: Smooth input preparation for quantum and quantum-inspired machine learning. Quantum Mach. Intell. 3(1), 1–6 (2021)
Sun, X., Tian, G., Yang, S., Yuan, P., Zhang, S.: Asymptotically optimal circuit depth for quantum state preparation and general unitary synthesis. Confer. Name: IEEE Trans. Comput.-Aided Des. Integr. Circuits Syst. (2023). https://doi.org/10.1109/TCAD.2023.3244885
Johri, S., Debnath, S., Mocherla, A., Singk, A., Prakash, A., Kim, J., Kerenidis, I.: Nearest centroid classification on a trapped ion quantum computer. NPJ Quantum Inf. 7(1), 1–11 (2021)
Kitaev, A.Y.: Quantum measurements and the Abelian Stabilizer Problem. arXiv:quant-ph/9511026 (1995). Accessed 25 Sept 2023
Farhi, E., Goldstone, J., Gutmann, S.: A quantum approximate optimization algorithm arxiv:1411.4028. Accessed 31 Dec 2021
Hadfield, S., Wang, Z., O’Gorman, B., Rieffel, E.G., Venturelli, D., Biswas, R.: From the quantum approximate optimization algorithm to a quantum alternating operator ansatz. Algorithms 12(2), 34 (2019). https://doi.org/10.3390/a12020034. arxiv:1709.03489. Accessed 31 Dec 2021
Finnila, A.B., Gomez, M.A., Sebenik, C., Stenson, C., Doll, J.D.: Quantum annealing: a new method for minimizing multidimensional functions. Chem. Phys. Lett. 219(5), 343–348 (1994). https://doi.org/10.1016/0009-2614(94)00117-0
Johnson, M.W., Amin, M.H.S., Gildert, S., Lanting, T., Hamze, F., Dickson, N., Harris, R., Berkley, A.J., Johansson, J., Bunyk, P., Chapple, E.M., Enderud, C., Hilton, J.P., Karimi, K., Ladizinsky, E., Ladizinsky, N., Oh, T., Perminov, I., Rich, C., Thom, M.C., Tolkacheva, E., Truncik, C.J.S., Uchaikin, S., Wang, J., Wilson, B., Rose, G.: Quantum annealing with manufactured spins. Nature 473(7346), 194–198 (2011). https://doi.org/10.1038/nature10012. Number: 7346 Publisher: Nature Publishing Group. Accessed 06 Dec 2022
Shukla, A., Vedula, P.: An efficient quantum algorithm for preparation of uniform quantum superposition states. arXiv:2306.11747 [quant-ph] (2023). Accessed 2023-09-15
Cruz, D., Fournier, R., Gremion, F., Jeannerot, A., Komagata, K., Tosic, T., Thiesbrummel, J., Chan, C.L., Macris, N., Dupertuis, M., Javerzac-Galy, C.: Efficient quantum algorithms for GHZ and \$w\$ states, and implementation on the IBM quantum computer. Adv. Quantum Technol. 2(5), 1900015 (2019). https://doi.org/10.1002/qute.201900015. Accessed 09 Jan 2022
Sawaya, N.P.D., Menke, T., Kyaw, T.H., Johri, S., Aspuru-Guzik, A., Guerreschi, G.G.: Resource-efficient digital quantum simulation of d-level systems for photonic, vibrational, and spin-s hamiltonians. NPJ Quantum Inf. 6(1), 49. https://doi.org/10.1038/s41534-020-0278-0. Accessed 08 Dec 2022
Poulin, D., Kitaev, A., Steiger, D.S., Hastings, M.B., Troyer, M.: Quantum algorithm for spectral measurement with a lower gate count. Phys. Rev. Lett. 121, 010501 (2018). https://doi.org/10.1103/PhysRevLett.121.010501
Klimo, M., Lukáč, P., Tarábek, P.: Deep neural networks classification via binary error-detecting output codes. Appl. Sci. 11(8), 3563. https://doi.org/10.3390/app11083563. Accessed 11 Dec 2022
Khan, M., Faye, J.P.L., Mendes, U.C., Miranskyy, A.: EP-PQM: Efficient parametric probabilistic quantum memory with fewer qubits and gates. IEEE Trans. Quantum Eng. 3, 1–15. https://doi.org/10.1109/TQE.2022.3169987. Conference Name: IEEE Transactions on Quantum Engineering
Plesch, M., Bužek, V.: Efficient compression of quantum information. Phys. Rev. A 81(3), 032317 (2010). https://doi.org/10.1103/PhysRevA.81.032317. Publisher: American Physical Society. Accessed 20 Sept 2023
Bärtschi, A., Eidenbenz, S.J.: Deterministic preparation of Dicke states. In: Gasieniec, L.A., Jansson, J., Levcopoulos, C. (eds.) Fundamentals of Computation Theory—22nd International Symposium, FCT 2019, Copenhagen, Denmark, August 12–14, 2019, Proceedings. Lecture Notes in Computer Science, vol. 11651, pp. 126–139. Springer. https://doi.org/10.1007/978-3-030-25027-0_9. Accessed 31 Dec 2021
Rebentrost, P., Gupt, B., Bromley, T.R.: Quantum computational finance: Monte Carlo pricing of financial derivatives. Phys. Rev. A 98(2), 022321 (2018). https://doi.org/10.1103/PhysRevA.98.022321. Accessed 14 Dec 2021
Woerner, S., Egger, D.J.: Quantum risk analysis. NPJ Quantum Inf. 5(1), 15 (2019). https://doi.org/10.1038/s41534-019-0130-6. Accessed 31 Dec 2021
Chancellor, N.: Domain wall encoding of discrete variables for quantum annealing and QAOA, Quantum Sci. Technol. 4(4), 045004 (2019). arxiv:1903.05068 [quant-ph]. https://doi.org/10.1088/2058-9565/ab33c2. Accessed 08 Dec 2022
Draper, T.G., Kutin, S.A., Rains, E.M., Svore, K.M.: A logarithmic-depth quantum carry-lookahead adder. 6(4), 351–369 (2004). https://doi.org/10.26421/QIC6.4-5-4. Accessed 07 Jan 2022
Saeedi, M., Pedram, M.: Linear-depth quantum circuits for \(n\)-qubit Toffoli gates with no ancilla. Phys. Rev. A 87(6), 062318 (2013). https://doi.org/10.1103/PhysRevA.87.062318. Accessed 06 Jan 2022
Rattew, A.G., Sun, Y., Minssen, P., Pistoia, M.: The efficient preparation of normal distributions in quantum registers. Quantum 5, 609 (2021). https://doi.org/10.22331/q-2021-12-23-609. Accessed 27 Dec 2021
Funding
This work is sponsored by CCB Fintech Company Limited (No. PO3522083587, HP2300480) and by Chengdu Science and Technology Bureau (No. 2021-YF09-00114-GX).
Author information
Authors and Affiliations
Contributions
All authors contributed to the study conception and design. The first draft of the manuscript was written by Bingren Chen, and all authors commented on previous versions of the manuscript. All authors read and approved the final manuscript.
Corresponding author
Ethics declarations
Conflict of interest
The authors have no relevant financial or non-financial interests to disclose.
Ethical approval
This study does not include human or animal subjects.
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Appendices
The procedure in \(U_O^{(4)}\) and \(U_O^{(5)}\)
Here, we give the transformation of the quantum state in \(U_O^{(4)}\) and \(U_O^{(5)}\).
\(U_O^{(4)}\):
As for \(U_O^{(5)}\), first tensor \(\vert 1\rangle \) with the quantum state.
The procedure of \(U_B^{(7)}\)
Here, we give the transformation of the quantum state in \(U_B^{(7)}\)
\(U_B^{(7)}\):
The adder-plus-d gate
We can leverage the Fourier gate to construct the adder-plus-d gate, as depicted in Fig. 12.
An adder-plus-d gate, comprised of n qubits (where \(n=\lceil \log _2 \frac{N}{2} \rceil +1\) in our approach), is assembled using a sequence involving a quantum Fourier transformation (QFT) gate, n phase gates, and an inverse quantum Fourier transformation (IQFT) gate. When initiated with the state \(\vert b_j \rangle \), it evolves as follows:
after undergoing the QFT gate. Subsequently, the collective effect of phase gates \(\mathop \otimes _{k=0}^{n-1} U(2d\pi \frac{2^k}{2^n})\), where \(U(\lambda )\) is defined as
transforms the state into:
Ultimately, after the application of the IQFT gate, the state transitions to \(\vert b_{j+d} \rangle \).
The Fourier adder-plus-d gate exhibits a computational depth of O(n) and a size of \(O(n \log n)\). For those seeking reduced complexity, the quantum carry lookahead adder (QCLA) method [28] offers a viable alternative. By introducing approximately O(n) ancillary qubits, QCLA can implement the adder with a computational depth of \(O(\log n)\) and a size of O(n).
The recursion converter
In this section, we introduce the recursion converter as presented by Plesch et al. [23]. While Plesch et al. demonstrated that the circuit initially possesses a depth of \(O(N\log ^2 N)\) and a size of \(O(N\log ^2 N)\), it is noteworthy that the circuit depth can be optimized to \(O(N\log N)\) following a scheme proposed by Saeedi et al. This optimization stems from the decomposition of n-qubit Toffoli gates in linear depth.
In Plesch’s framework, the converter is initially designed to facilitate conversion between the one-hot encoding state and the binary encoding state. With a slight modification, the same circuit can be adapted to convert between the Domain Wall state and the binary state. A visual representation of the \(N=6\) qubit converter is presented in Fig. 13.
Assuming we have already prepared an \(N-2\) qubit converter, denoted as \(U_B^{(N-1)}\), and initialized the state \(\vert \psi _{DW}^{(N)} \rangle \), applying \(U_B^{(N-1)}\) to the last \(N-2\) qubits yields the quantum state:
Next, a bitwise XOR operation, denoted as \(c=c_1 \ldots c_{\lceil \log _2 N \rceil }=b_{N-1} \oplus b_{N-2}\), is computed. For all i satisfying \(c_i=1\), CNOT gates are applied between the first qubit and the \(N-\lceil \log _2 N \rceil +i\) th qubit. Subsequently, a multiple-qubit Toffoli gate is employed to flip the first qubit if the last \(\lceil \log _2 N \rceil \) qubits are in the state \(\vert b_{N-1}\rangle \). As a result, the final state is transformed into the binary state. Notably, in the original scheme by Plesch et al. [23], c can be replaced with \( b_{N-1}\) to prepare \(\vert \psi _{BI}^{(N-1)}\rangle \) from \(\vert \psi _{OH}^{(N-1)}\rangle \).
Generation of the binomial distribution state
As Fig. 6 shows, we first implement \(R_Y(\theta )^{\otimes N}\) on \(\vert 0\rangle ^{\otimes N}\), where \(\theta =2\arcsin \sqrt{p}\) and \(R_Y(\theta )=\begin{bmatrix} \cos \frac{\theta }{2} &{} -\sin \frac{\theta }{2}\\ \sin \frac{\theta }{2} &{} \cos \frac{\theta }{2}\end{bmatrix}\) and we will obtain
where \(\vert D_k^{N} \rangle =\left( {\begin{array}{c}N\\ k\end{array}}\right) ^{-\frac{1}{2}} \sum _{x \in \{0,1\}^N, wt(x)=k} \vert x \rangle \) is the Dicke state. Second, we implement the inverse gate of \(U_{N,N-1}\) presented in [24] and the state becomes
for each \(k \in \{0, 1, \ldots , N\}\), so \(U_{N,N-1}^{-1}\) satisfies that
\(U_{N,N-1}\) can be decomposed to Split & Cyclic Shift gate (\(SCS_{n,k}\)) that is in the form of
where \(SCS_{n,k}\) satisfies that
As proved in [24], \(SCS_{n,k}\) can be decomposed to 1 two-qubit gates and \(k-1\) three-qubit gates shown as in Figs. 14 and 15.
Finally, we apply \(U_B^{(N+1)}\) or \(U_O^{(N+1)}\) to transform the Domain Wall state to the one-hot encoding state or the binary encoding state,Footnote 4 which is denoted as
Proof in Sect. 2.4
1.1 F.1 The solution of Eq. (17)
We utilize the binary representation \(b_N=c_n c_{n-1}\cdots c_1\) to denote the number N. Referring to Eq. (17), we can express this as follows:
1.2 F.2 The solution of Eq. (18)
We utilize the binary representation \(b_N=c_n c_{n-1}\cdots c_1\) to denote the number N. Referring to Eq. (18), we can express this as follows:
1.3 F.3 The solution of Eq. (19)
When \(2^{m-1}+1 <N \le 2^m+1\) and \(O(\log N)=O(m)\), in expanding-to-\(2^k\), we have
1.4 F.4 The solution of Eq. (20)
Let’s note that \(M=N-1\), and \(d(x)=d_b(x+1)\). We represent M in binary as \(b_M=c_n c_{n-1}\cdots c_1\). Therefore, we have the following relationships:
Hence,
1.5 F.5 The solution of Eq. (21)
Let us note that \(M=N-1\), and \(s(x)=s_b(x+1)\). We represent M in binary as \(b_M=c_n c_{n-1}\cdots c_1\). Therefore, we have the following relationships:
Hence,
1.6 F.6 The solution of Eq. (22)
Let us note that \(M=N-1\), and \(d(x)=d_b(x+1)\). We represent M in binary as \(b_M=c_n c_{n-1}\cdots c_1\). Therefore, we have the following relationships:
Hence,
1.7 F.7 The solution of Eq. (23)
Let us note that \(M=N-1\), and we denote \(s(x)=s_b(x+1)\). We represent M in binary as \(b_M=c_n c_{n-1}\cdots c_1\). Therefore, we have the following relationships:
Hence,
Rights and permissions
Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.
About this article
Cite this article
Chen, B., Wu, H., Yuan, H. et al. A novel quantum algorithm for converting between one-hot and binary encodings. Quantum Inf Process 23, 203 (2024). https://doi.org/10.1007/s11128-024-04403-z
Received:
Accepted:
Published:
DOI: https://doi.org/10.1007/s11128-024-04403-z