PSCF v1.5.0
complex.cpp
1/*
2* PSCF - Polymer Self-Consistent Field
3*
4* Copyright 2015 - 2026, David Morse (morse012@um.edu) and co-authors
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "complex.h"
9
10namespace Pscf {
11
12 // Exponentiation and logarithm
13
14 /*
15 * Exponentation of a ffts_complex variable, z = exp(a).
16 */
17 void assignExp(fftw_complex & z, fftw_complex const & a)
18 {
19 std::complex<double> arg = std::complex<double>(a[0], a[1]);
20 std::complex<double> result = std::exp(arg);
21 z[0] = result.real();
22 z[1] = result.imag();
23 }
24
25 /*
26 * Logarithm of an fftw_complex variable, z = log(a).
27 */
28 void assignLog(fftw_complex & z, fftw_complex const & a)
29 {
30 std::complex<double> arg = std::complex<double>(a[0], a[1]);
31 std::complex<double> result = std::log(arg);
32 z[0] = result.real();
33 z[1] = result.imag();
34 }
35
36 /*
37 * Stream extraction operator for fftw_complex.
38 */
39 std::istream& operator >> (std::istream& is, fftw_complex& z)
40 {
41 is >> z[0] >> z[1];
42 return is;
43 }
44
45 /*
46 * Stream insertion operator for fftw_complex.
47 */
48 std::ostream& operator << (std::ostream& os, fftw_complex const & z)
49 {
50 os << z[0] << " " << z[1];
51 return os;
52 }
53
54}
void assignExp(fftw_complex &z, fftw_complex const &a)
Exponentation of a ffts_complex variable, z = exp(a).
Definition complex.cpp:17
void assignLog(fftw_complex &z, fftw_complex const &a)
Logarithm of an fftw_complex variable, z = log(a).
Definition complex.cpp:28
PSCF package top-level namespace.
std::istream & operator>>(std::istream &in, Pair< Data > &pair)
Input a Pair from an istream.
Definition Pair.h:44
std::ostream & operator<<(std::ostream &out, const Pair< Data > &pair)
Output a Pair to an ostream, without line breaks.
Definition Pair.h:57