Code Monkey home page Code Monkey logo

qpp's Introduction

Quantum++

Version 0.8.2 - 20 May 2015

Quantum++ is a C++11 general purpose quantum computing library, composed solely of template header files. It uses the Eigen 3 linear algebra library and, if available, the OpenMP multi-processing library. 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.

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.

If you are interesting in contributing, please contact me. To contribute, you need to have a decent knowledge of C++ (preferably C++11), including templates and the standard library, a basic knowledge of quantum computing and linear algebra, and some working experience with Eigen 3.

Copyright (c) 2013 - 2015 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

Configuration:

  • Compiler: g++ version 4.8 or later (for good C++11 support)
  • Eigen 3 library located in $HOME/eigen
  • Quantum++ library located in $HOME/qpp
  • MATLAB compiler include header files: /Applications/MATLAB_R2014b.app/extern/include
  • MATLAB compiler shared library files: /Applications/MATLAB_R2014b.app/bin/maci64

Building without a build system

  • Example file: $HOME/qpp/examples/minimal.cpp
  • Output executable: $HOME/qpp/examples/minimal
  • Must run the commands below from inside the directory $HOME/qpp/examples

Release version (without MATLAB support):

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

Debug version (without MATLAB support):

g++ -pedantic -std=c++11 -Wall -Wextra -Weffc++ -fopenmp \
     -g3 -DDEBUG \
     -isystem $HOME/eigen -I $HOME/qpp/include \
      minimal.cpp -o minimal

Release version (with MATLAB support):

g++ -pedantic -std=c++11 -Wall -Wextra -Weffc++ -fopenmp \
     -O3 -DNDEBUG -DEIGEN_NO_DEBUG \
     -isystem $HOME/eigen -I $HOME/qpp/include \
     -I/Applications/MATLAB_R2014b.app/extern/include \
     -L/Applications/MATLAB_R2014b.app/bin/maci64 \
     -lmx -lmat minimal.cpp -o minimal

Debug version (with MATLAB support):

g++ -pedantic -std=c++11 -Wall -Wextra -Weffc++ -fopenmp \
     -g3 -DDEBUG \
     -isystem $HOME/eigen -I $HOME/qpp/include \
     -I /Applications/MATLAB_R2014b.app/extern/include \
     -L /Applications/MATLAB_R2014b.app/bin/maci64 \
     -lmx -lmat minimal.cpp -o minimal

Building using cmake

The current version of the repository has a ./CMakeLists.txt configuration 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 (where ./include is located), type

mkdir ./build
cd ./build
cmake ..
make

The above commands build the relase version (default) executable qpp, from the source file ./examples/minimal.cpp, 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 Eigen 3 library or the location of MATLAB installation, edit the ./CMakeLists.txt file. See also ./CMakeLists.txt for additional options. Do not forget to remove everything from the ./build directory before a fresh build!

Additional remarks

  • The C++ compiler must be C++11 compliant.

  • If using Windows, I recommend compiling under cygwin via cmake and g++. See also http://stackoverflow.com/questions/28997206/cygwin-support-for-c11-in-g4-9-2 for a bug related to lack of support for some C++11 math functions, and how to fix it. Quick fix: patch the standard library header file <cmath> using the provided patch ./cmath_cygwin.patch.

  • If your compiler does not support OpenMP (as it is the case e.g with clang++), disable OpenMP in your build, as otherwise the linker may not find the gomp library.

  • If you run the program on OS X with MATLAB support, make sure that the environment variable DYLD_LIBRARY_PATH is set to point to the MATLAB compiler library location, see the run_OSX_MATLAB script. Otherwise, you will get a runtime error like dyld: Library not loaded: @rpath/libmat.dylib.

    • I recommend running via a script, as otherwise setting the DYLD_LIBRARY_PATH globally 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 running script, run from inside the directory where the executable qpp is located:

        #!/bin/sh # Run Quantum++ under OS X with MATLAB support
        
        export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:"/Applications/MATLAB_R2014b.app/bin/maci64"
        ./qpp
      
  • If you build a debug version with g++ under OS X and use gdb to step inside template functions you may want to add -fno-weak compiler flag. See http://stackoverflow.com/questions/23330641/gnu-gdb-can-not-step-into-template-functions-os-x-mavericks for more details about this problem.

qpp's People

Contributors

vsoftco avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.