complex.h revision 250990
178172Sru/*- 2226458Sdas * Copyright (c) 2001-2011 The FreeBSD Project. 378172Sru * All rights reserved. 478172Sru * 578172Sru * Redistribution and use in source and binary forms, with or without 678172Sru * modification, are permitted provided that the following conditions 778172Sru * are met: 878172Sru * 1. Redistributions of source code must retain the above copyright 978172Sru * notice, this list of conditions and the following disclaimer. 1078172Sru * 2. Redistributions in binary form must reproduce the above copyright 1178172Sru * notice, this list of conditions and the following disclaimer in the 1278172Sru * documentation and/or other materials provided with the distribution. 1378172Sru * 1478172Sru * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1578172Sru * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1678172Sru * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1778172Sru * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1878172Sru * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1978172Sru * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2078172Sru * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2178172Sru * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2278172Sru * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2378172Sru * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2478172Sru * SUCH DAMAGE. 2578172Sru * 2678172Sru * $FreeBSD: head/include/complex.h 250990 2013-05-25 18:55:55Z ed $ 2778172Sru */ 2878172Sru 2978172Sru#ifndef _COMPLEX_H 30133724Sstefanf#define _COMPLEX_H 3178172Sru 32229590Sed#include <sys/cdefs.h> 33229590Sed 3478172Sru#ifdef __GNUC__ 35133725Sstefanf#if __STDC_VERSION__ < 199901 36133724Sstefanf#define _Complex __complex__ 37133725Sstefanf#endif 38229590Sed#define _Complex_I ((float _Complex)1.0i) 39230278Sed#endif 40230278Sed 41230278Sed#ifdef __generic 42229590Sed_Static_assert(__generic(_Complex_I, float _Complex, 1, 0), 43229590Sed "_Complex_I must be of type float _Complex"); 4478172Sru#endif 4578172Sru 46133724Sstefanf#define complex _Complex 47133724Sstefanf#define I _Complex_I 4878172Sru 49250990Sed#if __ISO_C_VISIBLE >= 2011 50250990Sed#ifdef __clang__ 51250990Sed#define CMPLX(x, y) ((double complex){ x, y }) 52250990Sed#define CMPLXF(x, y) ((float complex){ x, y }) 53250990Sed#define CMPLXL(x, y) ((long double complex){ x, y }) 54250990Sed#elif __GNUC_PREREQ__(4, 7) 55250990Sed#define CMPLX(x, y) __builtin_complex((double)(x), (double)(y)) 56250990Sed#define CMPLXF(x, y) __builtin_complex((float)(x), (float)(y)) 57250990Sed#define CMPLXL(x, y) __builtin_complex((long double)(x), (long double)(y)) 58250990Sed#endif 59250990Sed#endif /* __ISO_C_VISIBLE >= 2011 */ 60250990Sed 6178172Sru__BEGIN_DECLS 6278172Sru 63129864Sstefanfdouble cabs(double complex); 64129864Sstefanffloat cabsf(float complex); 65177760Sdaslong double cabsl(long double complex); 66174561Sdasdouble carg(double complex); 67174561Sdasfloat cargf(float complex); 68181375Sdaslong double cargl(long double complex); 69226458Sdasdouble complex ccos(double complex); 70226458Sdasfloat complex ccosf(float complex); 71226458Sdasdouble complex ccosh(double complex); 72226458Sdasfloat complex ccoshf(float complex); 73219379Sdasdouble complex cexp(double complex); 74219379Sdasfloat complex cexpf(float complex); 75181375Sdasdouble cimag(double complex) __pure2; 76181375Sdasfloat cimagf(float complex) __pure2; 77181375Sdaslong double cimagl(long double complex) __pure2; 78181375Sdasdouble complex conj(double complex) __pure2; 79181375Sdasfloat complex conjf(float complex) __pure2; 80129864Sstefanflong double complex 81181375Sdas conjl(long double complex) __pure2; 82181377Sdasfloat complex cprojf(float complex) __pure2; 83181377Sdasdouble complex cproj(double complex) __pure2; 84181377Sdaslong double complex 85181377Sdas cprojl(long double complex) __pure2; 86181375Sdasdouble creal(double complex) __pure2; 87181375Sdasfloat crealf(float complex) __pure2; 88181375Sdaslong double creall(long double complex) __pure2; 89226458Sdasdouble complex csin(double complex); 90226458Sdasfloat complex csinf(float complex); 91226458Sdasdouble complex csinh(double complex); 92226458Sdasfloat complex csinhf(float complex); 93174617Sdasdouble complex csqrt(double complex); 94174617Sdasfloat complex csqrtf(float complex); 95177761Sdaslong double complex 96177761Sdas csqrtl(long double complex); 97226458Sdasdouble complex ctan(double complex); 98226458Sdasfloat complex ctanf(float complex); 99226458Sdasdouble complex ctanh(double complex); 100226458Sdasfloat complex ctanhf(float complex); 10178172Sru 10278172Sru__END_DECLS 10378172Sru 10478172Sru#endif /* _COMPLEX_H */ 105