BRL-CAD
|
Complex numbers. More...
Files | |
file | complex.h |
Data Structures | |
struct | bn_complex |
Macros | |
#define | bn_cx_copy(ap, bp) {*(ap) = *(bp);} |
#define | bn_cx_neg(cp) { (cp)->re = -((cp)->re);(cp)->im = -((cp)->im);} |
#define | bn_cx_real(cp) (cp)->re |
#define | bn_cx_imag(cp) (cp)->im |
#define | bn_cx_add(ap, bp) { (ap)->re += (bp)->re; (ap)->im += (bp)->im;} |
#define | bn_cx_ampl(cp) hypot((cp)->re, (cp)->im) |
#define | bn_cx_amplsq(cp) ((cp)->re * (cp)->re + (cp)->im * (cp)->im) |
#define | bn_cx_conj(cp) { (cp)->im = -(cp)->im; } |
#define | bn_cx_cons(cp, r, i) { (cp)->re = r; (cp)->im = i; } |
#define | bn_cx_phas(cp) atan2((cp)->im, (cp)->re) |
#define | bn_cx_scal(cp, s) { (cp)->re *= (s); (cp)->im *= (s); } |
#define | bn_cx_sub(ap, bp) { (ap)->re -= (bp)->re; (ap)->im -= (bp)->im;} |
#define | bn_cx_mul(ap, bp) |
#define | bn_cx_mul2(ap, bp, cp) |
Typedefs | |
typedef struct bn_complex | bn_complex_t |
Functions | |
void | bn_cx_div (bn_complex_t *ap, const bn_complex_t *bp) |
Divide one complex by another. More... | |
void | bn_cx_sqrt (bn_complex_t *op, const bn_complex_t *ip) |
Compute square root of complex number. More... | |
Complex numbers.
#define bn_cx_neg | ( | cp | ) | { (cp)->re = -((cp)->re);(cp)->im = -((cp)->im);} |
#define bn_cx_add | ( | ap, | |
bp | |||
) | { (ap)->re += (bp)->re; (ap)->im += (bp)->im;} |
#define bn_cx_amplsq | ( | cp | ) | ((cp)->re * (cp)->re + (cp)->im * (cp)->im) |
#define bn_cx_cons | ( | cp, | |
r, | |||
i | |||
) | { (cp)->re = r; (cp)->im = i; } |
#define bn_cx_scal | ( | cp, | |
s | |||
) | { (cp)->re *= (s); (cp)->im *= (s); } |
#define bn_cx_sub | ( | ap, | |
bp | |||
) | { (ap)->re -= (bp)->re; (ap)->im -= (bp)->im;} |
#define bn_cx_mul | ( | ap, | |
bp | |||
) |
#define bn_cx_mul2 | ( | ap, | |
bp, | |||
cp | |||
) |
typedef struct bn_complex bn_complex_t |
"complex number" data type
void bn_cx_div | ( | bn_complex_t * | ap, |
const bn_complex_t * | bp | ||
) |
Divide one complex by another.
bn_cx_div(&a, &b). divides a by b. Zero divisor fails. a and b may coincide. Result stored in a.
void bn_cx_sqrt | ( | bn_complex_t * | op, |
const bn_complex_t * | ip | ||
) |
Compute square root of complex number.
bn_cx_sqrt(&out, &c) replaces out by sqrt(c)
Note: This is a double-valued function; the result of bn_cx_sqrt() always has nonnegative imaginary part.