BRL-CAD

Complex numbers. More...

Collaboration diagram for Complex Numbers:

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...
 

Detailed Description

Complex numbers.

Macro Definition Documentation

◆ bn_cx_copy

#define bn_cx_copy (   ap,
  bp 
)    {*(ap) = *(bp);}

Definition at line 45 of file complex.h.

◆ bn_cx_neg

#define bn_cx_neg (   cp)    { (cp)->re = -((cp)->re);(cp)->im = -((cp)->im);}

Definition at line 46 of file complex.h.

◆ bn_cx_real

#define bn_cx_real (   cp)    (cp)->re

Definition at line 47 of file complex.h.

◆ bn_cx_imag

#define bn_cx_imag (   cp)    (cp)->im

Definition at line 48 of file complex.h.

◆ bn_cx_add

#define bn_cx_add (   ap,
  bp 
)    { (ap)->re += (bp)->re; (ap)->im += (bp)->im;}

Definition at line 50 of file complex.h.

◆ bn_cx_ampl

#define bn_cx_ampl (   cp)    hypot((cp)->re, (cp)->im)

Definition at line 51 of file complex.h.

◆ bn_cx_amplsq

#define bn_cx_amplsq (   cp)    ((cp)->re * (cp)->re + (cp)->im * (cp)->im)

Definition at line 52 of file complex.h.

◆ bn_cx_conj

#define bn_cx_conj (   cp)    { (cp)->im = -(cp)->im; }

Definition at line 53 of file complex.h.

◆ bn_cx_cons

#define bn_cx_cons (   cp,
  r,
 
)    { (cp)->re = r; (cp)->im = i; }

Definition at line 54 of file complex.h.

◆ bn_cx_phas

#define bn_cx_phas (   cp)    atan2((cp)->im, (cp)->re)

Definition at line 55 of file complex.h.

◆ bn_cx_scal

#define bn_cx_scal (   cp,
 
)    { (cp)->re *= (s); (cp)->im *= (s); }

Definition at line 56 of file complex.h.

◆ bn_cx_sub

#define bn_cx_sub (   ap,
  bp 
)    { (ap)->re -= (bp)->re; (ap)->im -= (bp)->im;}

Definition at line 57 of file complex.h.

◆ bn_cx_mul

#define bn_cx_mul (   ap,
  bp 
)
Value:
{ register fastf_t a__re, b__re; \
(ap)->re = ((a__re=(ap)->re)*(b__re=(bp)->re)) - (ap)->im*(bp)->im; \
(ap)->im = a__re*(bp)->im + (ap)->im*b__re; }
double fastf_t
fastest 64-bit (or larger) floating point type
Definition: vmath.h:330

Definition at line 59 of file complex.h.

◆ bn_cx_mul2

#define bn_cx_mul2 (   ap,
  bp,
  cp 
)
Value:
{ \
(ap)->re = (cp)->re * (bp)->re - (cp)->im * (bp)->im; \
(ap)->im = (cp)->re * (bp)->im + (cp)->im * (bp)->re; }

Definition at line 65 of file complex.h.

Typedef Documentation

◆ bn_complex_t

typedef struct bn_complex bn_complex_t

"complex number" data type

Function Documentation

◆ bn_cx_div()

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.

◆ bn_cx_sqrt()

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.