File: usercomplex.h

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 254,920 kB
  • sloc: ansic: 1,134,743; cpp: 46,133; makefile: 4,875; fortran: 2,087; java: 1,826; sh: 996; ruby: 725; python: 495; asm: 371; sed: 166; awk: 44
file content (232 lines) | stat: -rw-r--r-- 9,489 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
//------------------------------------------------------------------------------
// GraphBLAS/Demo/Include/usercomplex.h:  complex numbers as a user-defined type
//------------------------------------------------------------------------------

// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2025, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

//------------------------------------------------------------------------------

#ifndef USERCOMPLEX_H
#define USERCOMPLEX_H

 typedef struct { double re ; double im ; } mycx ;
#define MYCX_DEFN \
"typedef struct { double re ; double im ; } mycx ;"

//------------------------------------------------------------------------------
// 10 binary functions, z=f(x,y), where CxC -> C
//------------------------------------------------------------------------------

extern
GrB_BinaryOp Complex_first , Complex_second , Complex_min ,
             Complex_max   , Complex_plus   , Complex_minus ,
             Complex_times , Complex_div    , Complex_rdiv  ,
             Complex_rminus, Complex_pair ;

//------------------------------------------------------------------------------
// 6 binary comparators, z=f(x,y), where CxC -> C
//------------------------------------------------------------------------------

extern
GrB_BinaryOp Complex_iseq , Complex_isne ,
             Complex_isgt , Complex_islt ,
             Complex_isge , Complex_isle ;

//------------------------------------------------------------------------------
// 3 binary boolean functions, z=f(x,y), where CxC -> C
//------------------------------------------------------------------------------

extern
GrB_BinaryOp Complex_or , Complex_and , Complex_xor ;

//------------------------------------------------------------------------------
// 6 binary comparators, z=f(x,y), where CxC -> bool
//------------------------------------------------------------------------------

extern
GrB_BinaryOp Complex_eq , Complex_ne ,
             Complex_gt , Complex_lt ,
             Complex_ge , Complex_le ;

//------------------------------------------------------------------------------
// 1 binary function, z=f(x,y), where double x double -> C
//------------------------------------------------------------------------------

extern GrB_BinaryOp Complex_complex ;

//------------------------------------------------------------------------------
// 5 unary functions, z=f(x) where C -> C
//------------------------------------------------------------------------------

extern
GrB_UnaryOp  Complex_identity , Complex_ainv , Complex_minv ,
             Complex_not ,      Complex_conj,
             Complex_one ,      Complex_abs  ;

//------------------------------------------------------------------------------
// 4 unary functions, z=f(x) where C -> double
//------------------------------------------------------------------------------

extern
GrB_UnaryOp Complex_real, Complex_imag,
            Complex_cabs, Complex_angle ;

//------------------------------------------------------------------------------
// 2 unary functions, z=f(x) where double -> C
//------------------------------------------------------------------------------

extern GrB_UnaryOp Complex_complex_real, Complex_complex_imag ;

//------------------------------------------------------------------------------
// Complex type, scalars, monoids, and semiring
//------------------------------------------------------------------------------

extern GrB_Type Complex ;
extern GrB_Monoid   Complex_plus_monoid, Complex_times_monoid ;
extern GrB_Semiring Complex_plus_times ;

GrB_Info Complex_init (bool builtin_complex) ;
GrB_Info Complex_finalize (void) ;

//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------

void mycx_first (mycx *z, const mycx *x, const mycx *y) ;
void mycx_second (mycx *z, const mycx *x, const mycx *y) ;
void mycx_pair (mycx *z, const mycx *x, const mycx *y) ;
void mycx_plus (mycx *z, const mycx *x, const mycx *y) ;
void mycx_minus (mycx *z, const mycx *x, const mycx *y) ;
void mycx_rminus (mycx *z, const mycx *x, const mycx *y) ;
void mycx_times (mycx *z, const mycx *x, const mycx *y) ;
void mycx_div (mycx *z, const mycx *x, const mycx *y) ;
void mycx_rdiv (mycx *z, const mycx *x, const mycx *y) ;
void fx64_min (GxB_FC64_t *z, const GxB_FC64_t *x, const GxB_FC64_t *y) ;
void mycx_min (mycx *z, const mycx *x, const mycx *y) ;
void fx64_max (GxB_FC64_t *z, const GxB_FC64_t *x, const GxB_FC64_t *y) ;
void mycx_max (mycx *z, const mycx *x, const mycx *y) ;
void mycx_iseq (mycx *z, const mycx *x, const mycx *y) ;
void mycx_isne (mycx *z, const mycx *x, const mycx *y) ;
void fx64_isgt (GxB_FC64_t *z, const GxB_FC64_t *x, const GxB_FC64_t *y) ;
void mycx_isgt (mycx *z, const mycx *x, const mycx *y) ;
void fx64_islt (GxB_FC64_t *z, const GxB_FC64_t *x, const GxB_FC64_t *y) ;
void mycx_islt (mycx *z, const mycx *x, const mycx *y) ;
void fx64_isge (GxB_FC64_t *z, const GxB_FC64_t *x, const GxB_FC64_t *y) ;
void mycx_isge (mycx *z, const mycx *x, const mycx *y) ;
void fx64_isle (GxB_FC64_t *z, const GxB_FC64_t *x, const GxB_FC64_t *y) ;
void mycx_isle (mycx *z, const mycx *x, const mycx *y) ;
void fx64_or (GxB_FC64_t *z, const GxB_FC64_t *x, const GxB_FC64_t *y) ;
void mycx_or (mycx *z, const mycx *x, const mycx *y) ;
void fx64_and (GxB_FC64_t *z, const GxB_FC64_t *x, const GxB_FC64_t *y) ;
void mycx_and (mycx *z, const mycx *x, const mycx *y) ;
void fx64_xor (GxB_FC64_t *z, const GxB_FC64_t *x, const GxB_FC64_t *y) ;
void mycx_xor (mycx *z, const mycx *x, const mycx *y) ;
void mycx_eq (bool *z, const mycx *x, const mycx *y) ;
void mycx_ne (bool *z, const mycx *x, const mycx *y) ;
void fx64_gt (bool *z, const GxB_FC64_t *x, const GxB_FC64_t *y) ;
void mycx_gt (bool *z, const mycx *x, const mycx *y) ;
void fx64_lt (bool *z, const GxB_FC64_t *x, const GxB_FC64_t *y) ;
void mycx_lt (bool *z, const mycx *x, const mycx *y) ;
void fx64_ge (bool *z, const GxB_FC64_t *x, const GxB_FC64_t *y) ;
void mycx_ge (bool *z, const mycx *x, const mycx *y) ;
void fx64_le (bool *z, const GxB_FC64_t *x, const GxB_FC64_t *y) ;
void mycx_le (bool *z, const mycx *x, const mycx *y) ;
void mycx_cmplx (mycx *z, const double *x, const double *y) ;
void mycx_one (mycx *z, const mycx *x) ;
void mycx_identity (mycx *z, const mycx *x) ;
void mycx_ainv (mycx *z, const mycx *x) ;
void mycx_minv (mycx *z, const mycx *x) ;
void mycx_conj (mycx *z, const mycx *x) ;
void fx64_abs (GxB_FC64_t *z, const GxB_FC64_t *x) ;
void mycx_abs (mycx *z, const mycx *x) ;
void fx64_not (GxB_FC64_t *z, const GxB_FC64_t *x) ;
void mycx_not (mycx *z, const mycx *x) ;
void mycx_real (double *z, const mycx *x) ;
void mycx_imag (double *z, const mycx *x) ;
void mycx_cabs (double *z, const mycx *x) ;
void mycx_angle (double *z, const mycx *x) ;
void fx64_cmplx_real (GxB_FC64_t *z, const double *x) ;
void mycx_cmplx_real (mycx *z, const double *x) ;
void fx64_cmplx_imag (GxB_FC64_t *z, const double *x) ;
void mycx_cmplx_imag (mycx *z, const double *x) ;

//------------------------------------------------------------------------------
// C++ compatibility
//------------------------------------------------------------------------------

#if defined ( __cplusplus )

    #define crealf(x)   std::real(x)
    #define creal(x)    std::real(x)
    #define cimagf(x)   std::imag(x)
    #define cimag(x)    std::imag(x)
    #define cpowf(x,y)  std::pow(x,y)
    #define cpow(x,y)   std::pow(x,y)
    #define powf(x,y)   std::pow(x,y)
    #define cexpf(x)    std::exp(x)
    #define cexp(x)     std::exp(x)
    #define expf(x)     std::exp(x)

    #define clogf(x)    std::log(x)
    #define clog(x)     std::log(x)
    #define logf(x)     std::log(x)

    #define cabsf(x)    std::abs(x)
    #define cabs(x)     std::abs(x)
    #define absf(x)     std::abs(x)

    #define csqrtf(x)   std::sqrt(x)
    #define csqrt(x)    std::sqrt(x)
    #define sqrtf(x)    std::sqrt(x)

    #define conjf(x)    std::conj(x)

    #define cargf(x)    std::arg(x)
    #define carg(x)     std::arg(x)

    #define csinf(x)    std::sin(x)
    #define csin(x)     std::sin(x)
    #define sinf(x)     std::sin(x)
    #define ccosf(x)    std::cos(x)
    #define ccos(x)     std::cos(x)
    #define cosf(x)     std::cos(x)
    #define ctanf(x)    std::tan(x)
    #define ctan(x)     std::tan(x)
    #define tanf(x)     std::tan(x)

    #define casinf(x)   std::asin(x)
    #define casin(x)    std::asin(x)
    #define asinf(x)    std::asin(x)
    #define cacosf(x)   std::acos(x)
    #define cacos(x)    std::acos(x)
    #define acosf(x)    std::acos(x)
    #define catanf(x)   std::atan(x)
    #define catan(x)    std::atan(x)
    #define atanf(x)    std::atan(x)

    #define csinhf(x)   std::sinh(x)
    #define csinh(x)    std::sinh(x)
    #define sinhf(x)    std::sinh(x)
    #define ccoshf(x)   std::cosh(x)
    #define ccosh(x)    std::cosh(x)
    #define coshf(x)    std::cosh(x)
    #define ctanhf(x)   std::tanh(x)
    #define ctanh(x)    std::tanh(x)
    #define tanhf(x)    std::tanh(x)

    #define casinhf(x)  std::asinh(x)
    #define casinh(x)   std::asinh(x)
    #define asinhf(x)   std::asinh(x)
    #define cacoshf(x)  std::acosh(x)
    #define cacosh(x)   std::acosh(x)
    #define acoshf(x)   std::acosh(x)
    #define catanhf(x)  std::atanh(x)
    #define catanh(x)   std::atanh(x)
    #define atanhf(x)   std::atanh(x)

#endif


#endif