PSCF v1.3
pscf/math/complex.h
1#ifndef PSCF_MATH_COMPLEX_H
2#define PSCF_MATH_COMPLEX_H
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2025, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <complex>
12#include <iostream>
13
14namespace Pscf {
15
36
37 /*
38 * The remainder of this file contains declarations of function
39 * templates for complex arithmetic that all belong to doxygen topic
40 * module Pscf_Math_Complex_Module, which is documented above.
41 * Throughout, the template argument CT represents an unspecified
42 * complex data type, while RT represents a corresponding real data
43 * type.
44 */
45
46 // Real and imaginary components
47
55 template <typename CT, typename RT>
56 RT real(CT const& a);
57
65 template <typename CT, typename RT>
66 RT imag(CT const& a);
67
68 // Absolute magnitude
69
77 template <typename CT, typename RT>
78 RT abs(CT const& a);
79
87 template <typename CT, typename RT>
88 RT absSq(CT const& a);
89
90 // Complex Conjugation
91
100 template <typename CT>
101 void conj(CT & z, CT const& a);
102
110 template <typename CT>
111 void conj(CT & a);
112
113 // Assignment
114
124 template <typename CT, typename RT>
125 void assign(CT & z, RT const& a, RT const& b);
126
135 template <typename CT, typename RT>
136 void assign(CT & z, RT const& a);
137
146 template <typename CT>
147 void assign(CT & z, CT const& a);
148
157 template <typename CT, typename RT>
158 void assign(CT & z, std::complex<RT> const& a);
159
168 template <typename CT, typename RT>
169 void assign(std::complex<RT> & z, CT const& a);
170
171 // Addition
172
182 template <typename CT>
183 void add(CT & z, CT const& a, CT const& b);
184
194 template <typename CT, typename RT>
195 void add(CT & z, CT const& a, RT const& b);
196
205 template <typename CT>
206 void addEq(CT & a, CT const& b);
207
216 template <typename CT, typename RT>
217 void addEq(CT & a, RT const& b);
218
219 // Subtraction
220
230 template <typename CT>
231 void sub(CT & z, CT const& a, CT const& b);
232
242 template <typename CT, typename RT>
243 void sub(CT & z, CT const& a, RT const& b);
244
253 template <typename CT>
254 void subEq(CT & a, CT const& b);
255
264 template <typename CT, typename RT>
265 void subEq(CT & a, RT const& b);
266
277 template <typename CT, typename RT>
278 RT absSqDiff(CT const& a, CT const& b);
279
280 // Multiplication
281
291 template <typename CT>
292 void mul(CT & z, CT const& a, CT const& b);
293
303 template <typename CT, typename RT>
304 void mul(CT & z, CT const& a, RT const& b);
305
314 template <typename CT>
315 void mulEq(CT & a, CT const& b);
316
325 template <typename CT, typename RT>
326 void mulEq(CT & a, RT const& b);
327
336 template <typename CT>
337 void square(CT & z, CT const& a);
338
339 // Division
340
350 template <typename CT>
351 void div(CT & z, CT const& a, CT const& b);
352
362 template <typename CT, typename RT>
363 void div(CT & z, CT const& a, RT const& b);
364
373 template <typename CT>
374 void divEq(CT & a, CT const & b);
375
384 template <typename CT, typename RT>
385 void divEq(CT & a, RT const& b);
386
387 #if 0
394 std::istream& operator >> (std::istream& is, CT & z);
395
403 std::ostream& operator << (std::ostream& os, CT const & z);
404 #endif
405
406} // namespace Pscf
407#endif
void div(CT &z, CT const &a, CT const &b)
Division of two complex numbers, z = a / b .
void square(CT &z, CT const &a)
Compute complex square of a complex number, z = a * a.
void conj(CT &z, CT const &a)
Compute complex conjugate, z = a^*.
void divEq(CT &a, CT const &b)
In place division of two complex number, a /= b.
void subEq(CT &a, CT const &b)
In place subtraction of two complex numbers, a -= b.
RT imag(CT const &a)
Return the imaginary part of a complex number.
RT abs(CT const &a)
Return absolute magnitude of a complex number.
void mulEq(CT &a, CT const &b)
In place multiplication of two complex number, a *= b.
RT absSq(CT const &a)
Return square of absolute magnitude of a complex number.
void assign(CT &z, RT const &a, RT const &b)
Create a complex number from real and imaginary parts, z = a + ib.
void addEq(CT &a, CT const &b)
In place addition of complex numbers, a += b.
RT absSqDiff(CT const &a, CT const &b)
Return square of the absolute magnitude of a complex difference.
RT real(CT const &a)
Return the real part of a complex number.
void add(CT &z, CT const &a, CT const &b)
Addition of two complex numbers, z = a + b.
void sub(CT &z, CT const &a, CT const &b)
Subtraction of two complex numbers, z = a - b.
void mul(CT &z, CT const &a, CT const &b)
Multiplication of two complex numbers, z = a * b.
PSCF package top-level namespace.
Definition param_pc.dox:1
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