Quantum++  v1.0.0-beta3
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 // constants
31 
32 namespace qpp
33 {
34 
40 inline constexpr cplx operator "" _i(unsigned long long int x) noexcept
41 {
42  return {0., static_cast<double>(x)};
43 }
44 
50 inline constexpr cplx operator "" _i(long double x) noexcept
51 {
52  return {0., static_cast<double>(x)};
53 }
54 
59 constexpr double chop = 1e-10;
60 
67 constexpr double eps = 1e-12;
68 
74 constexpr idx maxn = 64; // maximum number of qubits/qudits a state may have
75 
79 constexpr double pi = 3.141592653589793238462643383279502884;
83 constexpr double ee = 2.718281828459045235360287471352662497;
84 
88 constexpr double infty = std::numeric_limits<double>::infinity();
89 
96 inline cplx omega(idx D)
97 {
98  if (D == 0)
100  return exp(2.0 * pi * 1_i / static_cast<double>(D));
101 }
102 
103 } /* namespace qpp */
104 
105 #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:59
constexpr idx maxn
Maximum number of allowed qubits/qudits (subsystems)
Definition: constants.h:74
cplx omega(idx D)
D-th root of unity.
Definition: constants.h:96
constexpr double eps
Used to decide whether a number or expression in double precision is zero or not. ...
Definition: constants.h:67
Quantum++ main namespace.
Definition: codes.h:30
std::complex< double > cplx
Complex number in double precision.
Definition: types.h:46
constexpr double infty
Used to denote infinity in double precision.
Definition: constants.h:88
constexpr double pi
Definition: constants.h:79
std::size_t idx
Non-negative integer index.
Definition: types.h:36
constexpr double ee
Base of natural logarithm, .
Definition: constants.h:83