forked from mabl/wgms3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomplex_functions.h
53 lines (40 loc) · 1.53 KB
/
complex_functions.h
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
/*
wgms3d - a full-vectorial finite-difference mode solver.
Copyright (C) 2005-2014 Michael Krause <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WGMS3D_COMPLEX_FUNCTIONS_H
#define WGMS3D_COMPLEX_FUNCTIONS_H
/** \file
*
* Some helper functions for dealing with complex numbers.
*/
#include <complex>
namespace wgms3d {
/// Convert complex number to complex number (= do nothing),
/// required for complex calculation mode.
inline const std::complex<double> & maybeConvertComplexToReal (
const std::complex<double> &x,
std::complex<double> /* tag */)
{
return x;
}
/// Convert complex number to real number (= discarding the
/// imaginary part), required for real calculation mode.
inline double maybeConvertComplexToReal (
const std::complex<double> &x,
double /* tag */)
{
return x.real();
}
} // namespace wgms3d
#endif // WGMS3D_COMPLEX_FUNCTIONS_H