Page 41 - MSDN Magazine, September 2019
P. 41

References
• “Statements and Other Constructs,” retrieved on July 5, 2019, from bit.ly/2Ofx1Ld
• Yanofsky, N., & Mannucci, M. (2008) “Quantum Computing for Computer Scientists,” Cambridge University Press
• Nielsen, M. & Chuang, I., (2010) “Quantum Computation and Quantum Information,” 10th edition, Cambridge University Press, Cambridge UK
• Watrous, J., (2006) “Lecture 3: Superdense coding, quantum circuits, and partial measurements,” retrieved on July 5, 2019, from bit.ly/2XTPEDN
qubits wrapped in a BobQubitMessage, they’re placed in the queue. BobViewModel also implements IMessageSubscriber<Decode- QubitsMessage>. When Alice sends a message to Bob, it comes wrapped in a DecodeQubitsMessage object and is handled in the ReceiveMessageAsync(DecodeQubitsMessage) method (see Figure 11). The method dequeues an equal number of qubits from its queue. The QOperations DecodeQubits method is used to con- vert each pair of qubits from Alice and Bob into 2 bits of data. Each byte in the message consists of four 2-bit pairs (8 bits), hence the
loop increments for i and j.
Each byte is constructed by left-shifting bits according to the val-
ues of the decoded bits. The decoded bytes are turned back into a string using the Encoding.ASCII.GetString method and appended to the Message property that’s displayed on the page.
Once the qubits have been decoded, they’re released by publishing a ReleaseQubitsMessage, which is received by the CharlieView- Model. QOperations is then used to release the qubits:
async Task IMessageSubscriber<ReleaseQubitsMessage>.ReceiveMessageAsync( ReleaseQubitsMessage message)
{
await QOperations.ReleaseQubitsAsync(message.Qubits);
}
Wrapping Up
In this article I implemented a quantum algorithm for superdense coding in Q#, the new Microsoft quantum programming language. I explained how to entangle qubits using quantum gates, and how to encode ASCII messages as qubits. I looked at a Web-based Blazor-powered UI that leveraged the quantum algorithm and sim- ulated sending quantum particles to different parties. I also showed you how to consume a Q# library in a Blazor server application and how to launch and coordinate multiple browser windows. Finally, I explained how to employ MVVM in a Blazor application. n
Daniel Vaughan is an author and software engineer working for Microsoft in Redmond, Wash. He’s a former nine-time Microsoft MVP, and is the developer behind several acclaimed consumer and enterprise mobile apps, such as Surfy Browser for Android and Windows Phone and Airlock Browser for Android. He’s also the creator of a number of popular open source projects, including the Codon and Calcium frameworks. Vaughan blogs at danielvaughan.org and tweets as @dbvaughan.
Thanks to the following Microsoft technical expert for reviewing this article: Bettina Heim (Microsoft Quantum Team)
msdnmagazine.com
Instantly Search Terabytes
dtSearch’s document filters support: • popular file types
• emails with multilevel attachments • a wide variety of databases
• web data
Over 25 search options including:
• efficient multithreaded search
• easy multicolor hit-highlighting
• forensics options like credit card search
Developers:
• SDKs for Windows, Linux, macOS
• Cross-platform APIs for C++, Java and .NET with .NET Standard / .NET Core
• FAQs on faceted search, granular data classification, Azure and more
Visit dtSearch.com for
• hundreds of reviews and case studies
• fully-functional enterprise and developer evaluations
The Smart Choice for Text Retrieval® since 1991
dtSearch.com 1-800-IT-FINDS
®


































































































   39   40   41   42   43