Debian Codegraph @

src/c/numbers/conjugate.d

raw
1 /* -*- Mode: C; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /* vim: set filetype=c tabstop=2 shiftwidth=2 expandtab: */
3
4 /*
5 * conjugate.d - trascendental functions: conjugateine
6 *
7 * Copyright (c) 1984 Taiichi Yuasa and Masami Hagiya
8 * Copyright (c) 1990 Giuseppe Attardi
9 * Copyright (c) 2001 Juan Jose Garcia Ripoll
10 *
11 * See file 'LICENSE' for the copyright details.
12 *
13 */
14
15 #include <ecl/ecl.h>
16 #include <ecl/impl/math_dispatch.h>
17
18 cl_object
19 cl_conjugate(cl_object x)
20 {
21 @(return ecl_conjugate(x));
22 }
23
24 static cl_object
25 ecl_conjugate_real(cl_object x)
26 {
27 return x;
28 }
29
30 static cl_object
31 ecl_conjugate_complex(cl_object x)
32 {
33 return ecl_make_complex(x->gencomplex.real, ecl_negate(x->gencomplex.imag));
34 }
35
36 #ifdef ECL_COMPLEX_FLOAT
37 static cl_object
38 ecl_conjugate_csfloat(cl_object x)
39 {
40 cl_object result = ecl_alloc_object(t_csfloat);
41 ecl_csfloat(result) = conjf(ecl_csfloat(x));
42 return result;
43 }
44
45 static cl_object
46 ecl_conjugate_cdfloat(cl_object x)
47 {
48 cl_object result = ecl_alloc_object(t_cdfloat);
49 ecl_cdfloat(result) = conj(ecl_cdfloat(x));
50 return result;
51 }
52
53 static cl_object
54 ecl_conjugate_clfloat(cl_object x)
55 {
56 cl_object result = ecl_alloc_object(t_clfloat);
57 ecl_clfloat(result) = conjl(ecl_clfloat(x));
58 return result;
59 }
60 #endif
61
62 MATH_DEF_DISPATCH1_NE(conjugate, @[conjugate], @[number],
63 ecl_conjugate_real, ecl_conjugate_real, ecl_conjugate_real,
64 ecl_conjugate_real, ecl_conjugate_real,
65 ecl_conjugate_real,
66 ecl_conjugate_complex,
67 ecl_conjugate_csfloat, ecl_conjugate_cdfloat, ecl_conjugate_clfloat);