Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Quantum Computing with Silq Programming

You're reading from   Quantum Computing with Silq Programming Get up and running with quantum computing with the simplicity of this new high-level programming language

Arrow left icon
Product type Paperback
Published in Apr 2021
Publisher Packt
ISBN-13 9781800569669
Length 310 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Thomas Cambier Thomas Cambier
Author Profile Icon Thomas Cambier
Thomas Cambier
Srinjoy Ganguly Srinjoy Ganguly
Author Profile Icon Srinjoy Ganguly
Srinjoy Ganguly
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Preface 1. Section 1: Essential Background and Introduction to Quantum Computing
2. Chapter 1: Essential Mathematics and Algorithmic Thinking FREE CHAPTER 3. Chapter 2: Quantum Bits, Quantum Measurements, and Quantum Logic Gates 4. Chapter 3: Multiple Quantum Bits, Entanglement, and Quantum Circuits 5. Chapter 4: Physical Realization of a Quantum Computer 6. Section 2: Challenges in Quantum Programming and Silq Programming
7. Chapter 5: Challenges in Quantum Computer Programming 8. Chapter 6: Silq Programming Basics and Features 9. Chapter 7: Programming Multiple-Qubit Quantum Circuits with Silq 10. Section 3: Quantum Algorithms Using Silq Programming
11. Chapter 8: Quantum Algorithms I – Deutsch-Jozsa and Bernstein-Vazirani 12. Chapter 9: Quantum Algorithms II – Grover's Search Algorithm and Simon's Algorithm 13. Chapter 10: Quantum Algorithms III – Quantum Fourier Transform and Phase Estimation 14. Section 4: Applications of Quantum Computing
15. Chapter 11: Quantum Error Correction 16. Chapter 12: Quantum Cryptography – Quantum Key Distribution 17. Chapter 13: Quantum Machine Learning 18. Other Books You May Enjoy

Grover's search for one solution using Silq programming

In this section, let's start coding Grover's search algorithm using the Silq programming language and you will see that the uncomputation of Grover's oracle and the Grover diffusion circuit happens automatically. Because of this advantage of automatic uncomputation, the Grover code is very simple and concise and intuitive.

Let's start coding the Grover diffusion operator first because that operator is generic and can be used by any kind of Grover's oracle. Open a new Silq file, name it groverDiffusion.slq, and save it inside a folder called helpers. Then, inside this file, insert the following code:

def groverDiffusion[n:!](cand:uint[n])mfree: uint[n]{
    for k in [0..n) { cand[k] := H(cand[k]); }
    if cand!=0{ phase(); }
    for k in [0..n) { cand[k] := H(cand[k]); }
    return cand;
}

Let's try to understand...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £16.99/month. Cancel anytime