1 //------------------------------------------------------------------------------ 2 // GraphBLAS/Demo/Include/usercomplex.h: complex numbers as a user-defined type 3 //------------------------------------------------------------------------------ 4 5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 6 // SPDX-License-Identifier: Apache-2.0 7 8 //------------------------------------------------------------------------------ 9 10 #ifndef USERCOMPLEX_H 11 #define USERCOMPLEX_H 12 13 //------------------------------------------------------------------------------ 14 // 10 binary functions, z=f(x,y), where CxC -> C 15 //------------------------------------------------------------------------------ 16 17 GB_PUBLIC 18 GrB_BinaryOp Complex_first , Complex_second , Complex_min , 19 Complex_max , Complex_plus , Complex_minus , 20 Complex_times , Complex_div , Complex_rdiv , 21 Complex_rminus, Complex_pair ; 22 23 //------------------------------------------------------------------------------ 24 // 6 binary comparison functions, z=f(x,y), where CxC -> C 25 //------------------------------------------------------------------------------ 26 27 GB_PUBLIC 28 GrB_BinaryOp Complex_iseq , Complex_isne , 29 Complex_isgt , Complex_islt , 30 Complex_isge , Complex_isle ; 31 32 //------------------------------------------------------------------------------ 33 // 3 binary boolean functions, z=f(x,y), where CxC -> C 34 //------------------------------------------------------------------------------ 35 36 GB_PUBLIC 37 GrB_BinaryOp Complex_or , Complex_and , Complex_xor ; 38 39 //------------------------------------------------------------------------------ 40 // 6 binary comparison functions, z=f(x,y), where CxC -> bool 41 //------------------------------------------------------------------------------ 42 43 GB_PUBLIC 44 GrB_BinaryOp Complex_eq , Complex_ne , 45 Complex_gt , Complex_lt , 46 Complex_ge , Complex_le ; 47 48 //------------------------------------------------------------------------------ 49 // 1 binary function, z=f(x,y), where double x double -> C 50 //------------------------------------------------------------------------------ 51 52 GB_PUBLIC GrB_BinaryOp Complex_complex ; 53 54 //------------------------------------------------------------------------------ 55 // 5 unary functions, z=f(x) where C -> C 56 //------------------------------------------------------------------------------ 57 58 GB_PUBLIC 59 GrB_UnaryOp Complex_identity , Complex_ainv , Complex_minv , 60 Complex_not , Complex_conj, 61 Complex_one , Complex_abs ; 62 63 //------------------------------------------------------------------------------ 64 // 4 unary functions, z=f(x) where C -> double 65 //------------------------------------------------------------------------------ 66 67 GB_PUBLIC 68 GrB_UnaryOp Complex_real, Complex_imag, 69 Complex_cabs, Complex_angle ; 70 71 //------------------------------------------------------------------------------ 72 // 2 unary functions, z=f(x) where double -> C 73 //------------------------------------------------------------------------------ 74 75 GB_PUBLIC GrB_UnaryOp Complex_complex_real, Complex_complex_imag ; 76 77 //------------------------------------------------------------------------------ 78 // Complex type, scalars, monoids, and semiring 79 //------------------------------------------------------------------------------ 80 81 GB_PUBLIC GrB_Type Complex ; 82 GB_PUBLIC GrB_Monoid Complex_plus_monoid, Complex_times_monoid ; 83 GB_PUBLIC GrB_Semiring Complex_plus_times ; 84 GB_PUBLIC GrB_Info Complex_init (bool builtin_complex) ; 85 GB_PUBLIC GrB_Info Complex_finalize ( ) ; 86 87 //------------------------------------------------------------------------------ 88 // C++ compatibility 89 //------------------------------------------------------------------------------ 90 91 #if defined ( __cplusplus ) 92 93 using namespace std ; 94 95 #define crealf(x) real(x) 96 #define creal(x) real(x) 97 #define cimagf(x) imag(x) 98 #define cimag(x) imag(x) 99 #define cpowf(x,y) pow(x,y) 100 #define cpow(x,y) pow(x,y) 101 #define powf(x,y) pow(x,y) 102 #define cexpf(x) exp(x) 103 #define cexp(x) exp(x) 104 #define expf(x) exp(x) 105 106 #define clogf(x) log(x) 107 #define clog(x) log(x) 108 #define logf(x) log(x) 109 110 #define cabsf(x) abs(x) 111 #define cabs(x) abs(x) 112 #define absf(x) abs(x) 113 114 #define csqrtf(x) sqrt(x) 115 #define csqrt(x) sqrt(x) 116 #define sqrtf(x) sqrt(x) 117 118 #define conjf(x) conj(x) 119 120 #define cargf(x) arg(x) 121 #define carg(x) arg(x) 122 123 #define csinf(x) sin(x) 124 #define csin(x) sin(x) 125 #define sinf(x) sin(x) 126 #define ccosf(x) cos(x) 127 #define ccos(x) cos(x) 128 #define cosf(x) cos(x) 129 #define ctanf(x) tan(x) 130 #define ctan(x) tan(x) 131 #define tanf(x) tan(x) 132 133 #define casinf(x) asin(x) 134 #define casin(x) asin(x) 135 #define asinf(x) asin(x) 136 #define cacosf(x) acos(x) 137 #define cacos(x) acos(x) 138 #define acosf(x) acos(x) 139 #define catanf(x) atan(x) 140 #define catan(x) atan(x) 141 #define atanf(x) atan(x) 142 143 #define csinhf(x) sinh(x) 144 #define csinh(x) sinh(x) 145 #define sinhf(x) sinh(x) 146 #define ccoshf(x) cosh(x) 147 #define ccosh(x) cosh(x) 148 #define coshf(x) cosh(x) 149 #define ctanhf(x) tanh(x) 150 #define ctanh(x) tanh(x) 151 #define tanhf(x) tanh(x) 152 153 #define casinhf(x) asinh(x) 154 #define casinh(x) asinh(x) 155 #define asinhf(x) asinh(x) 156 #define cacoshf(x) acosh(x) 157 #define cacosh(x) acosh(x) 158 #define acoshf(x) acosh(x) 159 #define catanhf(x) atanh(x) 160 #define catanh(x) atanh(x) 161 #define atanhf(x) atanh(x) 162 163 #endif 164 165 166 #endif 167 168