forked from QuEST-Kit/QuEST
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuEST__complex_8h_source.html
150 lines (150 loc) · 13.5 KB
/
QuEST__complex_8h_source.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!-- HTML header for doxygen 1.8.8-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- For Mobile Devices -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<title>QuEST: QuEST_complex.h Source File</title>
<!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="style.css" rel="stylesheet" type="text/css"/>
<link href='https://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="jquery.smartmenus.bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="jquery.smartmenus.js"></script>
<!-- SmartMenus jQuery Bootstrap Addon -->
<script type="text/javascript" src="jquery.smartmenus.bootstrap.js"></script>
<!-- SmartMenus jQuery plugin -->
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand"><img alt="Logo" src="logo.png"/></a>
<a class="navbar-brand"><b>QuEST</b> v3.4.0<br>The Quantum Exact Simulation Toolkit</a>
</div>
</div>
</nav>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div class="content" id="content">
<div class="container">
<div class="row">
<div class="col-sm-12 panel " style="padding-bottom: 15px;">
<div style="margin-bottom: 15px;">
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_e145b6391efe0b6e575fd5bb5f76dbf8.html">QuEST</a></li><li class="navelem"><a class="el" href="dir_aaf4e0c86438000dc030ca371e863336.html">QuEST</a></li><li class="navelem"><a class="el" href="dir_ea73998990134951f0a2a9d1cfc118c0.html">include</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">QuEST_complex.h</div> </div>
</div><!--header-->
<div class="contents">
<a href="QuEST__complex_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">// Distributed under MIT licence. See https://github.com/QuEST-Kit/QuEST/blob/master/LICENCE.txt for details</span></div>
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span>  </div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="preprocessor">#ifndef QUEST_COMPLEX_H</span></div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="preprocessor">#define QUEST_COMPLEX_H</span></div>
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span>  </div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span>  </div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="comment">/*</span></div>
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="comment"> * creating precision-specific complex aliases</span></div>
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span> <span class="comment"> */</span></div>
<div class="line"><a name="l00028"></a><span class="lineno"> 28</span>  </div>
<div class="line"><a name="l00029"></a><span class="lineno"> 29</span> <span class="comment">// hide these from doxygen</span></div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span> <span class="comment">// \cond HIDDEN_SYMBOLS </span></div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>  </div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span> <span class="comment">// C++ uses complex<T></span></div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span> <span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a name="l00034"></a><span class="lineno"> 34</span>  </div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span> <span class="preprocessor">#include <cmath></span></div>
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span> <span class="preprocessor">#include <complex></span></div>
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span>  </div>
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span> <span class="keyword">using namespace </span>std;</div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>  </div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span> <span class="keyword">typedef</span> complex<float> float_complex;</div>
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span> <span class="keyword">typedef</span> complex<double> double_complex;</div>
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span> <span class="keyword">typedef</span> complex<long double> long_double_complex;</div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  </div>
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span> <span class="comment">// enable C-style funcs in C++</span></div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span> <span class="preprocessor">#define creal(x) real(x)</span></div>
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span> <span class="preprocessor">#define cimag(x) imag(x)</span></div>
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span> <span class="preprocessor">#define carg(x) arg(x)</span></div>
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span> <span class="preprocessor">#define cabs(x) abs(x)</span></div>
<div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  </div>
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span> <span class="preprocessor">#else</span></div>
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  </div>
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span> <span class="comment">// C uses complex type</span></div>
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span> <span class="preprocessor">#include <tgmath.h></span> <span class="comment">// includes <math.h> and <complex.h></span></div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  </div>
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span> <span class="keyword">typedef</span> <span class="keywordtype">float</span> complex float_complex;</div>
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span> <span class="keyword">typedef</span> <span class="keywordtype">double</span> complex double_complex;</div>
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span> <span class="keyword">typedef</span> <span class="keywordtype">long</span> <span class="keywordtype">double</span> complex long_double_complex;</div>
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span>  </div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span> <span class="preprocessor">#define float_complex(r,i) ((float)(r) + ((float)(i))*I)</span></div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span> <span class="preprocessor">#define double_complex(r,i) ((double)(r) + ((double)(i))*I)</span></div>
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span> <span class="preprocessor">#define long_double_complex(r,i) ((long double)(r) + ((long double)(i))*I)</span></div>
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span>  </div>
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span> <span class="preprocessor">#endif // #ifdef __cplusplus</span></div>
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  </div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span> <span class="comment">// \endcond</span></div>
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  </div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span>  </div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span> <span class="comment">/*</span></div>
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span> <span class="comment"> * creating a single precision-agnostic type</span></div>
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span> <span class="comment"> */</span></div>
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  </div>
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span> <span class="comment">// this horrible hack is needed for doxygen doc</span></div>
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span> <span class="preprocessor">#define qcomp</span></div>
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span> <span class="preprocessor">#undef qcomp</span></div>
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  </div>
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span> <span class="preprocessor">#if QuEST_PREC==1</span></div>
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span> <span class="preprocessor">#define qcomp float_complex</span></div>
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span> <span class="preprocessor">#elif QuEST_PREC==2</span></div>
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span> <span class="preprocessor">#define qcomp double_complex</span></div>
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span> <span class="preprocessor">#elif QuEST_PREC==4</span></div>
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span> <span class="preprocessor">#define qcomp long_double_complex</span></div>
<div class="line"><a name="l00082"></a><span class="lineno"> 82</span> <span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  </div>
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  </div>
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span> <span class="comment">/*</span></div>
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span> <span class="comment"> * creating converters to/from QuEST's internal type</span></div>
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span> <span class="comment"> */</span></div>
<div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  </div>
<div class="line"><a name="l00089"></a><span class="lineno"> 89</span> <span class="preprocessor">#define toComplex(scalar) ((Complex) {.real = creal(scalar), .imag = cimag(scalar)})</span></div>
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span> <span class="preprocessor">#define fromComplex(comp) qcomp(comp.real, comp.imag)</span></div>
<div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  </div>
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  </div>
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span> <span class="comment">/*</span></div>
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span> <span class="comment"> * creating doc</span></div>
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span> <span class="comment"> */</span></div>
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  </div>
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span> <span class="preprocessor">#endif // #ifndef QUEST_COMPLEX_H</span></div>
</div><!-- fragment --></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.8-->
<!-- start footer part -->
</div>
</div>
</div>
</div>
</div>
</body>
<script type="text/javascript" src="boot.js"></script>
</html>