Version 1.0-rc1 - Release Candidate 1, 11 November 2016
Quantum++ is a modern C++11 general purpose quantum computing library, composed solely of template header files. Quantum++ is written in standard C++11 and has very low external dependencies, using only the Eigen 3 linear algebra header-only template library and, if available, the OpenMP multi-processing library.
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.
To report any bugs or ask for additional features/enhancements, please submit an issue with an appropriate label.
If you are interesting in contributing to this project, please contact me. To contribute, you need to have a solid knowledge of C++ (preferably C++11), including templates and the standard library, a basic knowledge of quantum computing and linear algebra, and working experience with Eigen 3.
For additional Eigen 3 documentation see http://eigen.tuxfamily.org/dox/. For a simple Eigen 3 quick ASCII reference see http://eigen.tuxfamily.org/dox/AsciiQuickReference.txt.
Copyright (c) 2013 - 2017 Vlad Gheorghiu, vgheorgh AT gmail DOT com.
Quantum++ is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Quantum++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Quantum++. If not, see http://www.gnu.org/licenses/.
Building instructions for POSIX-compliant platforms
- Compiler: g++ version 4.8.2 or later (for good C++11 support)
Eigen 3 library located in
- Quantum++ library located in
- CMake version 3.0.0 or later, highly recommended
MATLAB compiler include header
MATLAB compiler shared library
CMake (version 3.0.0 or later)Building using
The current version of the repository has a
file for building examples using CMake.
To build an example using CMake,
I recommend an out-of-source build, i.e., from the root of the project
./include is located), type
mkdir ./build cd ./build cmake .. make
The commands above build the relase version (default) executable
from the source file
without MATLAB support (default),
inside the directory
./build. To build a different configuration,
e.g. debug version with MATLAB
support, type from the root of the project
cd ./build rm -rf * cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_MATLAB=ON .. make
Or, to disable OpenMP support (enabled by default), type
cd ./build rm -rf * cmake -DWITH_OPENMP=OFF .. make
To change the name of the example file, the location of the
library or the location of MATLAB
installation, edit the
./CMakeLists.txt file. See also
for additional options. Do not forget to clean the
./build directory before
a fresh build!
Building without an automatic build system
- Example file:
- Output executable:
- You must run the commands below from inside the directory
MATLAB support)Release version (without
g++ -pedantic -std=c++11 -Wall -Wextra -Weffc++ -fopenmp \ -O3 -DNDEBUG -DEIGEN_NO_DEBUG \ -isystem $HOME/eigen -I $HOME/qpp/include \ minimal.cpp -o minimal
MATLAB support)Debug version (without
g++ -pedantic -std=c++11 -Wall -Wextra -Weffc++ -fopenmp \ -g3 -DDEBUG \ -isystem $HOME/eigen -I $HOME/qpp/include \ minimal.cpp -o minimal
MATLAB support)Release version (with
g++ -pedantic -std=c++11 -Wall -Wextra -Weffc++ -fopenmp \ -O3 -DNDEBUG -DEIGEN_NO_DEBUG \ -isystem $HOME/eigen -I $HOME/qpp/include \ -I/Applications/MATLAB_R2016a.app/extern/include \ -L/Applications/MATLAB_R2016a.app/bin/maci64 \ -lmx -lmat minimal.cpp -o minimal
MATLAB support)Debug version (with
g++ -pedantic -std=c++11 -Wall -Wextra -Weffc++ -fopenmp \ -g3 -DDEBUG \ -isystem $HOME/eigen -I $HOME/qpp/include \ -I /Applications/MATLAB_R2016a.app/extern/include \ -L /Applications/MATLAB_R2016a.app/bin/maci64 \ -lmx -lmat minimal.cpp -o minimal
Additional building instructions for particular platforms
- Some earlier versions of
Cygwin had a bug related to lack of support for some
C++11 math functions, see
for more details. Quick fix: patch the standard library header file
<cmath>using the provided patch
./cmath_cygwin.patch. Latest Cygwin (as of Nov. 11, 2016) seem to have fixed the issue.
Windows via Visual Studio
Project/Properties/Configuration Properties/C_C++/Language/Open MP Support
#define WITH_OPENMP_ in your source file.
To create a Visual Studio 2015 or later console solution, start by creating a Win32 Console Application
File/New/Project.../Installed/Templates/Visual C++/Win32/Win32 Console Application
Click Next then select Console Application as Application Type. Click Finish to create the solution. Next select
from the main menu. The Property Pages configuration window will open. From the latter select All configurations from the top left Configuration drop box. Next select
and add to the field Additional Include Directories the location of Quantum++
./includefolder as well as the location of Eigen 3. It should look similar to
and add to the field Disable Specific Warnings the values 4503;4996. Click Ok to save the settings and close the Property Pages window. You are now ready to go.
If you run the program with MATLAB support, make sure that the environment variable
DYLD_LIBRARY_PATHis set to point to the MATLAB compiler library location, see the
run_mac_MATLABscript. Otherwise, you get a runtime error similar to
dyld: Library not loaded: @rpath/libmat.dylib.
I recommend running via a script, as otherwise setting the
DYLD_LIBRARY_PATHglobally may interfere with macports' CMake installation (in case you use CMake from macports). If you use a script, then the environment variable is local to the script and does not interfere with the rest of the system.
Example of script, assumed to be located in the root directory of Quantum++
#!/bin/sh MATLAB=/Applications/MATLAB_R2016a.app export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$MATLAB/bin/maci64 ./build/qpp
If you build a debug version with g++ and use gdb to step inside template functions you may want to add
-fno-weakcompiler flag. See http://stackoverflow.com/questions/23330641/gnu-gdb-can-not-step-into-template-functions-os-x-mavericks for more details about this problem.
Quantum++ was extensively tested under multiple flavours of Linux,
via a suite of unit tests constructed with
Google Test 1.8.0 (included with the
./unit_tests/lib/gtest-1.8.0). The source code of the unit tests
is provided under
./unit_tests/tests. To build and run the unit tests, I
strongly recommend to use CMake version 3.0.0 or
later. Assuming you do use CMake, switch to the
./unit_tests directory, create a
build directory inside it, then from the
cmake .. make
The commands above build
./unit_tests/build/tests/qpp_testing, which you
then may run. Note that
qpp::Timer tests or tests related to random functions
qpp::rand() may sometime (very rarely) fail, due to timing
imprecision or statistical errors. Such behaviour is perfectly normal.
The CMake configuration file
./unit_tests/CMakeLists.txt defines the same building options and default
choices as the main
./CMakeLists.txt of Quantum++. Therefore you can use the
same flags as the ones mentioned at the beginning of this document when
customizing the build. You should modify
accordingly in case your Eigen 3 library or
MATLAB include/library files are
in a different location than the one assumed in this document.