Quantum++  v1.0-rc2
A modern C++11 quantum computing library
constants.h
Go to the documentation of this file.
1 /*
2  * Quantum++
3  *
4  * Copyright (c) 2013 - 2017 Vlad Gheorghiu (vgheorgh@gmail.com)
5  *
6  * This file is part of Quantum++.
7  *
8  * Quantum++ is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * Quantum++ is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Quantum++. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
27 #ifndef CONSTANTS_H_
28 #define CONSTANTS_H_
29 
30 namespace qpp
31 {
37 inline constexpr cplx operator "" _i(unsigned long long int x) noexcept
38 {
39  return {0., static_cast<double>(x)};
40 }
41 
47 inline constexpr cplx operator "" _i(long double x) noexcept
48 {
49  return {0., static_cast<double>(x)};
50 }
51 
56 constexpr double chop = 1e-10;
57 
64 constexpr double eps = 1e-12;
65 
71 constexpr idx maxn = 64; // maximum number of qubits/qudits a state may have
72 
76 constexpr double pi = 3.141592653589793238462643383279502884;
80 constexpr double ee = 2.718281828459045235360287471352662497;
81 
85 constexpr double infty = std::numeric_limits<double>::max();
86 
93 inline cplx omega(idx D)
94 {
95  if (D == 0)
96  throw exception::OutOfRange("qpp::omega()");
97  return exp(2.0 * pi * 1_i / static_cast<double>(D));
98 }
99 
100 } /* namespace qpp */
101 
102 #endif /* CONSTANTS_H_ */
constexpr double chop
Used in qpp::disp() for setting to zero numbers that have their absolute value smaller than qpp::chop...
Definition: constants.h:56
constexpr idx maxn
Maximum number of allowed qubits/qudits (subsystems)
Definition: constants.h:71
cplx omega(idx D)
D-th root of unity.
Definition: constants.h:93
constexpr double eps
Used to decide whether a number or expression in double precision is zero or not. ...
Definition: constants.h:64
Quantum++ main namespace.
Definition: codes.h:30
std::complex< double > cplx
Complex number in double precision.
Definition: types.h:45
constexpr double infty
Used to denote infinity in double precision.
Definition: constants.h:85
constexpr double pi
Definition: constants.h:76
Parameter out of range exception.
Definition: exception.h:567
std::size_t idx
Non-negative integer index.
Definition: types.h:35
constexpr double ee
Base of natural logarithm, .
Definition: constants.h:80