Skip to content

1. Introduction

Vlad Gheorghiu edited this page Apr 5, 2024 · 46 revisions

About

Quantum++ is a modern C++ general purpose quantum computing library, composed solely of header files. Quantum++ is written in standard C++17 and has very low external dependencies. It only uses the Eigen 3 linear algebra library and, if available, the OpenMP multi-processing library. For additional Eigen 3 documentation please click here. For a simple Eigen 3 quick ASCII reference please click here.

Quantum++ is not restricted to qubit systems or specific quantum information processing tasks, being capable of simulating arbitrary quantum processes. The main design factors taken in consideration were the ease of use, high portability, and high performance. The library's simulation capabilities are only restricted by the amount of available physical memory. On a typical machine (Intel i5 8Gb RAM) Quantum++ can successfully simulate the evolution of 25 qubits in a pure state or of 12 qubits in a mixed state reasonably fast.

The simulator defines a large collection of (template) quantum computing related functions and a few useful classes. The main data types are complex vectors and complex matrices, which we will describe below. Most functions operate on such vectors/matrices and always return the result by value. Collection of objects are implemented via the standard library container std::vector<>, instantiated accordingly.

Although there are many available quantum computing libraries/simulators written in various programming languages, see e.g., Quantiki's list of QC simulators for a comprehensive list, we hope that what makes Quantum++ different is the ease of use, portability and high performance. we have chosen the C++ programming language (standard C++17) for implementing the library as it is by now a mature standard, fully (or almost fully) implemented by most important compilers, highly portable, and capable of producing highly optimized code.

In the reminder of this Wiki we will describe the main features of the library, "in a nutshell" fashion, via a series of simple examples. I assume that the reader is familiar with the basic concepts of quantum mechanics/quantum information, as we do not provide any introduction to this field. For a comprehensive introduction to the latter see e.g., M. Nielsen's and I. Chuang's Quantum computation and quantum information excellent reference. This Wiki is not intended to be a comprehensive documentation, but only a brief introduction to the library and its main features. For a detailed reference see the official API documentation which you can generate by running doxygen from the project's root directory. For detailed installation instructions as well as for additional information regarding the library see the main repository page. If you are interested in contributing, or for any comments or suggestions, please do not hesitate to email us at info AT softwareq DOT ca.


Building instructions for the truly impatient

If you really cannot wait anymore, continue reading the remaining. If you afford to be a bit patient, please skip the reminder of this section and read the detailed Building instructions for POSIX compliant platforms or Building instructions for Windows platforms in this Wiki.

Installing and running on POSIX compliant platforms

In this section we assume that you use a POSIX compliant system (e.g., UNIX-like). To get started with Quantum++, first download the Eigen 3 library into your home directory, as $HOME/eigen3. You can change the name of the directory, but in the current document we will use $HOME/eigen3 as the location of the Eigen 3 library. Next, download or clone Quantum++ library into the home directory as $HOME/qpp. Finally, make sure that your compiler supports C++17 and preferably OpenMP. As a compiler I recommend g++ version 5.0 or later or clang++ version 3.8 or later. You are now ready to go!

Next, we will build a simple minimal example to test that the installation was successful. Create a directory called $HOME/testing, and inside it create the file minimal.cpp, with the content listed below.

// Minimal example

#include <iostream>

#include "qpp/qpp.h"

int main() {
    using namespace qpp;

    std::cout << "Hello Quantum++!\nThis is the |0> state:\n";
    std::cout << disp(0_ket) << '\n';
}

Next, compile the file using the C++17 compliant compiler. In the following we assume you use g++, but the building instructions are similar for other compilers. From the directory $HOME/testing type

g++ -std=c++17 -isystem $HOME/eigen3 -I $HOME/qpp/include -I $HOME/qpp/qasmtools/include minimal.cpp -o minimal

Your compile command may differ from the above, depending on the C++ compiler and operating system. If everything went fine, the above command should build an executable minimal in $HOME/testing, which can be run by typing ./minimal. The output should be similar to the following:

Hello Quantum++!
This is the |0> state:
1
0

The line

#include "qpp/qpp.h"

includes the main header file of the library qpp.h This header file includes all other necessary internal Quantum++ header files. The line

using namespace qpp;

injects the Quantum++'s namespace into the working namespace, so we don't need to prefix the library functions by qpp::. Finally, the line

std::cout << disp(0_ket) << '\n';

displays the state |0> in a display-friendly format using the stream manipulator qpp::disp().

Installing and running under

Windows

We provide CMake support for Visual Studio. We recommend using Visual Studio 2017 or later. For comprehensive details about using CMake with Visual Studio please read this page.