-
Notifications
You must be signed in to change notification settings - Fork 118
1. Introduction
Quantum++ is a C++11 general purpose quantum computing library, composed solely of header files. Quantum++ is written in standard C++11 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 I 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, I hope that what makes Quantum++ different is the ease of use, portability and high performance. I have chosen the C++ programming language (standard C++11) 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 I 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 I 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. For detailed installation instructions as well as for additional information regarding the library see the main repository page. If you are interesting in contributing, or for any comments or suggestions, please do not hesitate to email me at vgheorgh AT gmail DOT com.
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 systems or Building instructions for Windows platforms in this Wiki.
In this section I 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/eigen
. You can change the name of the directory, but in the
current document I will use $HOME/eigen
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++11 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
, available for download in
examples/minimal.cpp
and with
the content listed below.
// Minimal example
// Source: ./examples/minimal.cpp
#include <iostream>
#include "qpp.h"
int main() {
using namespace qpp;
std::cout << "Hello Quantum++!\nThis is the |0> state:\n";
std::cout << disp(st.z0) << '\n';
}
Next, compile the file using the C++11 compliant compiler. In the
following I assume you use g++, but the building
instructions are similar for other compilers. From the directory
$HOME/testing
type
g++ -std=c++11 -isystem $HOME/eigen -I $HOME/qpp/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.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(st.z0) << '\n';
displays the state |0> represented by the Singleton qpp::st.z0
in a
nice format using the display 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.
Copyright (c) 2017 - 2024 softwareQ Inc. All rights reserved.