Quantum++  v0.7
C++11 quantum computing library
constants.h
Go to the documentation of this file.
1 /*
2  * Quantum++
3  *
4  * Copyright (c) 2013 - 2015 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
41 ""
42 
43 _i(unsigned long long int x) noexcept
44 {
45  return
46  {0., static_cast<double>(x)};
47 }
48 
54 inline constexpr cplx operator
55 ""
56 
57 _i(long double x) noexcept
58 {
59  return
60  {0., static_cast<double>(x)};
61 }
62 
67 constexpr double chop = 1e-10;
68 
75 constexpr double eps = 1e-12;
76 
82 constexpr idx maxn = 64; // maximum number of qudits a state may have
83 
87 constexpr double pi = 3.141592653589793238462643383279502884;
91 constexpr double ee = 2.718281828459045235360287471352662497;
92 
96 constexpr double infty = std::numeric_limits<double>::infinity();
97 
104 inline cplx omega(idx D)
105 {
106  if (D == 0)
108  return exp(2.0 * pi * 1_i / static_cast<double>(D));
109 }
110 
111 } /* namespace qpp */
112 
113 #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:67
constexpr idx maxn
Maximum number of allowed qu(d)its (subsystems)
Definition: constants.h:82
cplx omega(idx D)
D-th root of unity.
Definition: constants.h:104
constexpr double eps
Used to decide whether a number or expression in double precision is zero or not. ...
Definition: constants.h:75
Quantum++ main namespace.
Definition: codes.h:30
std::complex< double > cplx
Complex number in double precision.
Definition: types.h:41
constexpr double infty
Used to denote infinity in double precision.
Definition: constants.h:96
constexpr double pi
Definition: constants.h:87
std::size_t idx
Non-negative integer index.
Definition: types.h:36
constexpr double ee
Base of natural logarithm, .
Definition: constants.h:91