Block-Structured AMR Software Framework
complex-type.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017, UChicago Argonne, LLC
3  * All Rights Reserved
4  *
5  * Hardware/Hybrid Cosmology Code (HACC), Version 1.0
6  *
7  * Salman Habib, Adrian Pope, Hal Finkel, Nicholas Frontiere, Katrin Heitmann,
8  * Vitali Morozov, Jeffrey Emberson, Thomas Uram, Esteban Rangel
9  * (Argonne National Laboratory)
10  *
11  * David Daniel, Patricia Fasel, Chung-Hsing Hsu, Zarija Lukic, James Ahrens
12  * (Los Alamos National Laboratory)
13  *
14  * George Zagaris
15  * (Kitware)
16  *
17  * OPEN SOURCE LICENSE
18  *
19  * Redistribution and use in source and binary forms, with or without
20  * modification, are permitted provided that the following conditions are met:
21  *
22  * 1. Redistributions of source code must retain the above copyright notice,
23  * this list of conditions and the following disclaimer. Software changes,
24  * modifications, or derivative works, should be noted with comments and
25  * the author and organization's name.
26  *
27  * 2. Redistributions in binary form must reproduce the above copyright
28  * notice, this list of conditions and the following disclaimer in the
29  * documentation and/or other materials provided with the distribution.
30  *
31  * 3. Neither the names of UChicago Argonne, LLC or the Department of Energy
32  * nor the names of its contributors may be used to endorse or promote
33  * products derived from this software without specific prior written
34  * permission.
35  *
36  * 4. The software and the end-user documentation included with the
37  * redistribution, if any, must include the following acknowledgment:
38  *
39  * "This product includes software produced by UChicago Argonne, LLC under
40  * Contract No. DE-AC02-06CH11357 with the Department of Energy."
41  *
42  * *****************************************************************************
43  * DISCLAIMER
44  * THE SOFTWARE IS SUPPLIED "AS IS" WITHOUT WARRANTY OF ANY KIND. NEITHER THE
45  * UNITED STATES GOVERNMENT, NOR THE UNITED STATES DEPARTMENT OF ENERGY, NOR
46  * UCHICAGO ARGONNE, LLC, NOR ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY,
47  * EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE
48  * ACCURARY, COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, DATA, APPARATUS,
49  * PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
50  * PRIVATELY OWNED RIGHTS.
51  *
52  * *****************************************************************************
53  */
54 
55 // Compatibility file for C99 and C++ complex. This header
56 // can be included by either C99 or ANSI C++ programs to
57 // allow complex arithmetic to be written in a common subset.
58 // Note that overloads for both the real and complex math
59 // functions are available after this header has been
60 // included.
61 
62 #ifndef HACC_COMPLEXTYPE_H
63 #define HACC_COMPLEXTYPE_H
64 
65 #ifdef __cplusplus
66 
67 #include <cmath>
68 #include <complex>
69 
70 typedef std::complex<double> complex_t;
71 
72 #define I complex_t(0.0, 1.0)
73 
74 #else
75 
76 #include <complex.h>
77 #include <math.h>
78 
79 typedef double complex complex_t;
80 
81 #define complex_t(r,i) ((double)(r) + ((double)(i)) * I)
82 
83 #define real(x) creal(x)
84 #define imag(x) cimag(x)
85 #define abs(x) fabs(x)
86 #define arg(x) carg(x)
87 
88 #endif // #ifdef __cplusplus
89 
90 #endif // HACC_COMPLEXTYPE_H
#define complex_t(r, i)
Definition: complex-type.h:81