3 * C99 Complex math cross-platform support code
6 * Joao Matos (joao.matos@xamarin.com)
8 * Copyright 2015 Xamarin, Inc (http://www.xamarin.com)
9 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
15 #if !defined (HAVE_COMPLEX_H)
16 #include <../../support/libm/complex.h>
21 #define _USE_MATH_DEFINES // needed by MSVC to define math constants
26 #define double_complex _C_double_complex
29 double_complex mono_double_complex_make(gdouble re, gdouble im)
31 return _Cbuild (re, im);
35 double_complex mono_double_complex_scalar_div(double_complex c, gdouble s)
37 return mono_double_complex_make(creal(c) / s, cimag(c) / s);
41 double_complex mono_double_complex_scalar_mul(double_complex c, gdouble s)
43 return mono_double_complex_make(creal(c) * s, cimag(c) * s);
47 double_complex mono_double_complex_div(double_complex left, double_complex right)
49 double denom = creal(right) * creal(right) + cimag(right) * cimag(right);
51 return mono_double_complex_make(
52 (creal(left) * creal(right) + cimag(left) * cimag(right)) / denom,
53 (-creal(left) * cimag(right) + cimag(left) * creal(right)) / denom);
57 double_complex mono_double_complex_sub(double_complex left, double_complex right)
59 return mono_double_complex_make(creal(left) - creal(right), cimag(left)
65 #define double_complex double complex
68 double_complex mono_double_complex_make(gdouble re, gdouble im)
74 double_complex mono_double_complex_scalar_div(double_complex c, gdouble s)
80 double_complex mono_double_complex_scalar_mul(double_complex c, gdouble s)
86 double_complex mono_double_complex_div(double_complex left, double_complex right)
92 double_complex mono_double_complex_sub(double_complex left, double_complex right)