Definition of machine complex numbers.
More...
Go to the source code of this file.
|
#define | compf_set(d, a) |
| Sets d to a . More...
|
|
#define | compf_setr(d, a) |
| Sets d to the real value a . More...
|
|
#define | compf_neg(d, a) |
| Sets d to -a . More...
|
|
#define | compf_add(d, a, b) |
| Adds a to b and stores the result in d , all of type compf or compf_ptr. More...
|
|
#define | compf_addr(d, a, r) |
| Adds the complex number a to the real number b and stores the result in d . More...
|
|
#define | compf_sub(d, a, b) |
| Subtracts b from a and stores the result in d , all of type compf or compf_ptr. More...
|
|
#define | compf_subr(d, a, r) |
| Subtracts the real number b from the complex number a and stores the result in d . More...
|
|
#define | compf_mul(d, a, b) |
|
#define | compf_mulr(d, a, r) |
| Multiplies the complex number a to the real number r and stores the result in d . More...
|
|
#define | compf_amr(d, a, r) |
| Adds the complex number a*r to d , where d ,a are complex and r is real. More...
|
|
#define | compf_sqr(d, a) |
| Squares a and stores the result in d , all of type compf or compf_ptr. More...
|
|
#define | compf_div(d, a, b) |
| Divides a by b and stores the result in d , all of type compf or compf_ptr. More...
|
|
#define | compf_mod(a) fhypot((a)->x, (a)->y) |
| Computes the modulus of the complex number a .
|
|
#define | compf_dist(a, b) fhypot((a)->x - (b)->x, (a)->y - (b)->y) |
| Computes the distance betwwen the complex numbera a and b .
|
|
#define | compf_mod2(a) ((a)->x * (a)->x + (a)->y * (a)->y) |
|
#define | compf_log2(a) (plog2(compf_mod(a))) |
| Computes the log_2 of the modulus of the complex number a .
|
|
#define | coeff_log2(a) (plog2((a) < 0 ? -(a) : (a))) |
| Computes the log_2 of the absolute value of the real number a .
|
|
#define | compf_s(a) (pfloor(plog2(compf_mod(a))) + 1) |
| Computes the scale of the complex number a , see [1].
|
|
#define | coeff_s(a) (pfloor(coeff_log2(a)) + 1) |
| Computes the scale of the real number a , see [1].
|
|
Definition of machine complex numbers.
Definition in file compf.h.
◆ compf_add
#define compf_add |
( |
|
d, |
|
|
|
a, |
|
|
|
b |
|
) |
| |
Value: (d)->x = (a)->x + (b)->x; \
(d)->y = (a)->y + (b)->y;
Adds a
to b
and stores the result in d
, all of type compf or compf_ptr.
Definition at line 63 of file compf.h.
◆ compf_addr
#define compf_addr |
( |
|
d, |
|
|
|
a, |
|
|
|
r |
|
) |
| |
Value: (d)->x = (a)->x + (r); \
(d)->y = (a)->y;
Adds the complex number a
to the real number b
and stores the result in d
.
Definition at line 67 of file compf.h.
◆ compf_amr
#define compf_amr |
( |
|
d, |
|
|
|
a, |
|
|
|
r |
|
) |
| |
Value: (d)->x += (a)->x * (r); \
(d)->y += (a)->y * (r);
Adds the complex number a*r
to d
, where d
,a are complex and r
is real.
Definition at line 87 of file compf.h.
◆ compf_div
#define compf_div |
( |
|
d, |
|
|
|
a, |
|
|
|
b |
|
) |
| |
Value: { \
coeff_t px = ((a)->x * (b)->x + (a)->y * (b)->y) / m2; \
(d)->y = ((a)->y * (b)->x - (a)->x * (b)->y) / m2; \
(d)->x = px;\
}
Divides a
by b
and stores the result in d
, all of type compf or compf_ptr.
Definition at line 96 of file compf.h.
◆ compf_mod2
#define compf_mod2 |
( |
|
a | ) |
((a)->x * (a)->x + (a)->y * (a)->y) |
Computes the square of the modulus of the complex number a
.
- Warning
- There is a danger of overflow, better use the slower
compf_mod()
instead.
Definition at line 111 of file compf.h.
◆ compf_mul
#define compf_mul |
( |
|
d, |
|
|
|
a, |
|
|
|
b |
|
) |
| |
Value: coeff_t px = (a)->x * (b)->x - (a)->y * (b)->y; \
(d)->y = (a)->x * (b)->y + (a)->y * (b)->x; \
(d)->x = px;
double coeff_t
The machine number type to use for polynomial coefficients and evaluation.
Definition at line 78 of file compf.h.
◆ compf_mulr
#define compf_mulr |
( |
|
d, |
|
|
|
a, |
|
|
|
r |
|
) |
| |
Value: (d)->x = (a)->x * (r); \
(d)->y = (a)->y * (r);
Multiplies the complex number a
to the real number r
and stores the result in d
.
Definition at line 83 of file compf.h.
◆ compf_neg
#define compf_neg |
( |
|
d, |
|
|
|
a |
|
) |
| |
Value: (d)->x = -(a)->x; \
(d)->y = -(a)->y;
Sets d
to -a
.
Definition at line 59 of file compf.h.
◆ compf_set
#define compf_set |
( |
|
d, |
|
|
|
a |
|
) |
| |
Value: (d)->x = (a)->x; \
(d)->y = (a)->y;
Sets d
to a
.
Definition at line 51 of file compf.h.
◆ compf_setr
#define compf_setr |
( |
|
d, |
|
|
|
a |
|
) |
| |
Value: (d)->x = (a); \
(d)->y = 0;
Sets d
to the real value a
.
Definition at line 55 of file compf.h.
◆ compf_sqr
#define compf_sqr |
( |
|
d, |
|
|
|
a |
|
) |
| |
Value: coeff_t px = (a)->x * (a)->x - (a)->y * (a)->y; \
(d)->y = 2 * (a)->x * (a)->y; \
(d)->x = px;
Squares a
and stores the result in d
, all of type compf or compf_ptr.
Definition at line 91 of file compf.h.
◆ compf_sub
#define compf_sub |
( |
|
d, |
|
|
|
a, |
|
|
|
b |
|
) |
| |
Value: (d)->x = (a)->x - (b)->x; \
(d)->y = (a)->y - (b)->y;
Subtracts b
from a
and stores the result in d
, all of type compf or compf_ptr.
Definition at line 71 of file compf.h.
◆ compf_subr
#define compf_subr |
( |
|
d, |
|
|
|
a, |
|
|
|
r |
|
) |
| |
Value: (d)->x = (a)->x - (r); \
(d)->y = (a)->y;
Subtracts the real number b
from the complex number a
and stores the result in d
.
Definition at line 75 of file compf.h.
◆ compf
Practical wrapper for compf_struct
.
To avoid the constant use *
and &
the type compf
is a pointer.
Example of use:
compf_struct compf[1]
Practical wrapper for compf_struct.
Polynomial with machine floating point complex coefficients.
Definition at line 43 of file compf.h.