SAF
Loading...
Searching...
No Matches
saf_utility_complex.c
Go to the documentation of this file.
1/*
2 * Copyright 2016-2018 Leo McCormack
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
15 */
16
28#include "saf_utility_complex.h"
29
30#if __STDC_VERSION__ >= 199901L
31 /* for C99 (and above) compliant compilers */
32
33 /*
34 Single-Precision Complex Operations
35 */
36 inline float_complex cmplxf(float re, float im) { return re + im * I; }
37 inline float_complex ccaddf(float_complex x, float_complex y) { return x + y; }
38 inline float_complex craddf(float_complex x, float y) { return x + y; }
39 inline float_complex ccsubf(float_complex x, float_complex y) { return x - y; }
40 inline float_complex crsubf(float_complex x, float y) { return x - y; }
41 inline float_complex ccmulf(float_complex x, float_complex y) { return x * y; }
42 inline float_complex cccmulf(float_complex x, float_complex y, float_complex z) { return x * y * z; }
43 inline float_complex crmulf(float_complex x, float y) { return x * y; }
44 inline float_complex ccdivf(float_complex x, float_complex y) { return x / y; }
45 inline float_complex crdivf(float_complex x, float y) { return x / y; }
46
47 /*
48 Double-Precision Complex Operations
49 */
50 inline double_complex cmplx(double re, double im) { return re + im * I; }
51 inline double_complex ccadd(double_complex x, double_complex y) { return x + y; }
52 inline double_complex cradd(double_complex x, double y) { return x + y; }
53 inline double_complex ccsub(double_complex x, double_complex y) { return x - y; }
54 inline double_complex crsub(double_complex x, double y) { return x - y; }
55 inline double_complex ccmul(double_complex x, double_complex y) { return x * y; }
56 inline double_complex cccmul(double_complex x, double_complex y, double_complex z) { return x * y * z; }
57 inline double_complex crmul(double_complex x, double y) { return x * y; }
58 inline double_complex ccdiv(double_complex x, double_complex y) { return x / y; }
59 inline double_complex crdiv(double_complex x, double y) { return x / y; }
60
61#endif
Contains wrappers for handling complex numbers across both C99-compliant compilers and Microsoft Visu...