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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
/***
complex number
@classmod a.complex
*/
#ifndef LUA_LIBA_COMPLEX_H
#define LUA_LIBA_COMPLEX_H
#include "a.h"
/***
complex number
@field real real part of complex number
@field imag imaginary part of complex number
@field rho the magnitude of complex number
@field theta the phase angle of complex number
@table a.complex
*/
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
/***
constructor for complex number from real and imaginary parts
@tparam[opt] number|string|a.complex real real part of complex number
@tparam[opt] number imag imaginary part of complex number
@treturn a.complex complex number userdata
@function new
*/
int liba_complex_new(lua_State *L);
/***
constructor for complex number from rectangular Cartesian components
@tparam[opt] number real real part of complex number
@tparam[opt] number imag imaginary part of complex number
@treturn a.complex complex number userdata
@function rect
*/
int liba_complex_rect(lua_State *L);
/***
constructor for complex number from polar form
@tparam[opt] number rho a distance from a reference point
@tparam[opt] number theta an angle from a reference direction
@treturn a.complex complex number userdata
@function polar
*/
int liba_complex_polar(lua_State *L);
/***
complex number self is equal to complex number that
@tparam a.complex that complex number
@treturn bool result of comparison
@function eq
*/
int liba_complex_eq(lua_State *L);
/***
complex number self is not equal to complex number that
@tparam a.complex that complex number
@treturn bool result of comparison
@function ne
*/
int liba_complex_ne(lua_State *L);
/***
computes the natural logarithm of magnitude of a complex number
@treturn number log|z|
@function logabs
*/
int liba_complex_logabs(lua_State *L);
/***
computes the squared magnitude of a complex number
@treturn number a^2+b^2
@function abs2
*/
int liba_complex_abs2(lua_State *L);
/***
computes the magnitude of a complex number
@treturn number sqrt{a^2+b^2}
@function abs
*/
int liba_complex_abs(lua_State *L);
/***
computes the phase angle of a complex number
@treturn number arctan(b/a)
@function arg
*/
int liba_complex_arg(lua_State *L);
/***
computes the projection on Riemann sphere
@treturn a.complex complex number userdata
@function proj
*/
int liba_complex_proj(lua_State *L);
/***
computes the complex conjugate
@treturn a.complex complex number userdata
@function conj
*/
int liba_complex_conj(lua_State *L);
/***
computes the complex negative
@treturn a.complex complex number userdata
@function unm
*/
int liba_complex_neg(lua_State *L);
/***
inverse of a complex number
@treturn a.complex complex number userdata
@function inv
*/
int liba_complex_inv(lua_State *L);
/***
addition of complex numbers
@tparam a.complex z complex number userdata
@treturn a.complex complex number userdata
@function add
*/
int liba_complex_add(lua_State *L);
/***
subtraction of complex numbers
@tparam a.complex z complex number userdata
@treturn a.complex complex number userdata
@function sub
*/
int liba_complex_sub(lua_State *L);
/***
multiplication of complex numbers
@tparam a.complex z complex number userdata
@treturn a.complex complex number userdata
@function mul
*/
int liba_complex_mul(lua_State *L);
/***
division of complex numbers
@tparam a.complex z complex number userdata
@treturn a.complex complex number userdata
@function div
*/
int liba_complex_div(lua_State *L);
/***
complex number z raised to complex power a
@tparam a.complex a complex number userdata
@treturn a.complex complex number userdata
@function pow
*/
int liba_complex_pow(lua_State *L);
/***
computes the complex base-b logarithm
@tparam a.complex b complex number userdata
@treturn a.complex complex number userdata
@function logb
*/
int liba_complex_logb(lua_State *L);
/***
computes the complex base-e exponential
@treturn a.complex complex number userdata
@function exp
*/
int liba_complex_exp(lua_State *L);
/***
computes the complex natural logarithm
@treturn a.complex complex number userdata
@function log
*/
int liba_complex_log(lua_State *L);
/***
computes the complex square root
@treturn a.complex complex number userdata
@function sqrt
*/
int liba_complex_sqrt(lua_State *L);
/***
computes the complex base-2 logarithm
@treturn a.complex complex number userdata
@function log2
*/
int liba_complex_log2(lua_State *L);
/***
computes the complex base-10 logarithm
@treturn a.complex complex number userdata
@function log10
*/
int liba_complex_log10(lua_State *L);
/***
computes the complex sine
@treturn a.complex complex number userdata
@function sin
*/
int liba_complex_sin(lua_State *L);
/***
computes the complex cosine
@treturn a.complex complex number userdata
@function cos
*/
int liba_complex_cos(lua_State *L);
/***
computes the complex tangent
@treturn a.complex complex number userdata
@function tan
*/
int liba_complex_tan(lua_State *L);
/***
computes the complex secant
@treturn a.complex complex number userdata
@function sec
*/
int liba_complex_sec(lua_State *L);
/***
computes the complex cosecant
@treturn a.complex complex number userdata
@function csc
*/
int liba_complex_csc(lua_State *L);
/***
computes the complex cotangent
@treturn a.complex complex number userdata
@function cot
*/
int liba_complex_cot(lua_State *L);
/***
computes the complex arc sine
@treturn a.complex complex number userdata
@function asin
*/
int liba_complex_asin(lua_State *L);
/***
computes the complex arc cosine
@treturn a.complex complex number userdata
@function acos
*/
int liba_complex_acos(lua_State *L);
/***
computes the complex arc tangent
@treturn a.complex complex number userdata
@function atan
*/
int liba_complex_atan(lua_State *L);
/***
computes the complex arc secant
@treturn a.complex complex number userdata
@function asec
*/
int liba_complex_asec(lua_State *L);
/***
computes the complex arc cosecant
@treturn a.complex complex number userdata
@function acsc
*/
int liba_complex_acsc(lua_State *L);
/***
computes the complex arc cotangent
@treturn a.complex complex number userdata
@function acot
*/
int liba_complex_acot(lua_State *L);
/***
computes the complex hyperbolic sine
@treturn a.complex complex number userdata
@function sinh
*/
int liba_complex_sinh(lua_State *L);
/***
computes the complex hyperbolic cosine
@treturn a.complex complex number userdata
@function cosh
*/
int liba_complex_cosh(lua_State *L);
/***
computes the complex hyperbolic tangent
@treturn a.complex complex number userdata
@function tanh
*/
int liba_complex_tanh(lua_State *L);
/***
computes the complex hyperbolic secant
@treturn a.complex complex number userdata
@function sech
*/
int liba_complex_sech(lua_State *L);
/***
computes the complex hyperbolic cosecant
@treturn a.complex complex number userdata
@function csch
*/
int liba_complex_csch(lua_State *L);
/***
computes the complex hyperbolic cotangent
@treturn a.complex complex number userdata
@function coth
*/
int liba_complex_coth(lua_State *L);
/***
computes the complex arc hyperbolic sine
@treturn a.complex complex number userdata
@function asinh
*/
int liba_complex_asinh(lua_State *L);
/***
computes the complex arc hyperbolic cosine
@treturn a.complex complex number userdata
@function acosh
*/
int liba_complex_acosh(lua_State *L);
/***
computes the complex arc hyperbolic tangent
@treturn a.complex complex number userdata
@function atanh
*/
int liba_complex_atanh(lua_State *L);
/***
computes the complex arc hyperbolic secant
@treturn a.complex complex number userdata
@function asech
*/
int liba_complex_asech(lua_State *L);
/***
computes the complex arc hyperbolic cosecant
@treturn a.complex complex number userdata
@function acsch
*/
int liba_complex_acsch(lua_State *L);
/***
computes the complex arc hyperbolic cotangent
@treturn a.complex complex number userdata
@function acoth
*/
int liba_complex_acoth(lua_State *L);
#if defined(__cplusplus)
} /* extern "C" */
#endif /* __cplusplus */
#endif /* complex.h */