XACC
constants.h
Go to the documentation of this file.
1 /*
2  * This file is part of Quantum++.
3  *
4  * MIT License
5  *
6  * Copyright (c) 2013 - 2020 Vlad Gheorghiu.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24  * SOFTWARE.
25  */
26 
32 #ifndef CONSTANTS_H_
33 #define CONSTANTS_H_
34 
35 namespace qpp {
36 inline namespace literals {
42 inline constexpr cplx operator"" _i(unsigned long long int x) noexcept {
43  return {0., static_cast<double>(x)};
44 }
45 
51 inline constexpr cplx operator"" _i(long double x) noexcept {
52  return {0., static_cast<double>(x)};
53 }
54 
60 inline constexpr std::complex<float>
61 operator"" _if(unsigned long long int x) noexcept {
62  return {0., static_cast<float>(x)};
63 }
64 
70 inline constexpr std::complex<float> operator"" _if(long double x) noexcept {
71  return {0., static_cast<float>(x)};
72 }
73 
74 } /* namespace literals */
75 
80 constexpr double chop = 1e-14;
81 
87 constexpr idx maxn = 64; // maximum number of qubits/qudits a state may have
88 
92 constexpr double pi = 3.141592653589793238462643383279502884;
96 constexpr double ee = 2.718281828459045235360287471352662497;
97 
101 constexpr double infty = std::numeric_limits<double>::max();
102 
109 inline cplx omega(idx D) {
110  if (D == 0)
111  throw exception::OutOfRange("qpp::omega()");
112  return exp(2.0 * pi * 1_i / static_cast<double>(D));
113 }
114 
119 enum {
120  RES = 0,
121  PROB = 1,
122  ST = 2,
123 };
124 
125 } /* namespace qpp */
126 
127 #endif /* CONSTANTS_H_ */
Quantum++ main namespace.
Definition: circuits.h:35