FastPolyEval  1.0
Fast Evaluation of Real and Complex Polynomials
Data Structures | Macros | Typedefs | Functions
comp.h File Reference

Definition of MPFR complex numbers. More...

Go to the source code of this file.

Data Structures

struct  comp_struct
 Multi-precision floating point complex numbers. More...
 

Macros

#define comp_init(d, prec)
 Allocates memory for the digits of d. More...
 
#define comp_initz(d, prec)
 Allocates memory for the digits of d and sets its value to 0. More...
 
#define comp_clear(d)
 De-allocates the memory used by the digits of d. More...
 
#define comp_zero(d)   (mpfr_zero_p((d)->x) && mpfr_zero_p((d)->y))
 Tests if d==0.
 
#define comp_add(d, a, b)
 Adds a to b and stores the result in d, all of type comp or comp_ptr. More...
 
#define comp_set(d, a)
 Sets d to a. More...
 
#define comp_setr(d, a)
 Sets d to the real value a. More...
 
#define comp_neg(d, a)
 Sets d to -a. More...
 
#define comp_addr(d, a, r)
 Adds the complex number a to the real number b and stores the result in d. More...
 
#define comp_amu(d, a, r, buf)
 Adds the complex number a*r to d, where d,a are complex and r is unsigned integer. More...
 
#define comp_sub(d, a, b)
 Subtracts b from a and stores the result in d, all of type comp or comp_ptr. More...
 
#define comp_subr(d, a, r)
 Subtracts the real number b from the complex number a and stores the result in d. More...
 
#define comp_mul(d, a, b, buf1, buf2)
 Multiplies a to b and stores the result in d, all of type comp or comp_ptr. More...
 
#define comp_div(d, a, b, b1, b2, b3)
 Divides a by b and stores the result in d, all of type comp or comp_ptr. More...
 
#define comp_mod(m, a)   mpfr_hypot((m), (a)->x, (a)->y, MPFR_RNDN);
 Computes the modulus of a and stores the result in m, a of type comp and m of type mpfr_t.
 
#define comp_mulr(d, a, r)
 Multiplies the complex number a to the real number r and stores the result in d. More...
 
#define comp_muli(d, a, i)
 Multiplies the complex number a to the integer i and stores the result in d. More...
 
#define comp_mulu(d, a, i)
 Multiplies the complex number a to the unsigned integer i and stores the result in d. More...
 
#define comp_sqr(d, a, buf)
 Squares a and stores the result in d, all of type comp or comp_ptr. More...
 

Typedefs

typedef comp_struct comp[1]
 Practical wrapper for comp_struct. More...
 
typedef comp_structcomp_ptr
 Convenience pointer to comp_struct.
 

Functions

real_t comp_log2 (comp z)
 Computes the base 2 log of |z|. More...
 
real_t real_log2 (mpfr_t x)
 Computes the base 2 log of |x|. More...
 
real_t comp_s (comp z)
 Computes s(z). More...
 
real_t mpfr_s (mpfr_t x)
 Computes s(x). More...
 

Detailed Description

Definition of MPFR complex numbers.

Definition in file comp.h.

Macro Definition Documentation

◆ comp_add

#define comp_add (   d,
  a,
 
)
Value:
mpfr_add((d)->x, (a)->x, (b)->x, MPFR_RNDN); \
mpfr_add((d)->y, (a)->y, (b)->y, MPFR_RNDN);

Adds a to b and stores the result in d, all of type comp or comp_ptr.

Definition at line 64 of file comp.h.

◆ comp_addr

#define comp_addr (   d,
  a,
 
)
Value:
mpfr_add((d)->x, (a)->x, (r), MPFR_RNDN); \
mpfr_set((d)->y, (a)->y, MPFR_RNDN);

Adds the complex number a to the real number b and stores the result in d.

Definition at line 80 of file comp.h.

◆ comp_amu

#define comp_amu (   d,
  a,
  r,
  buf 
)
Value:
mpfr_mul_ui((buf), (a)->x, (r), MPFR_RNDN); \
mpfr_add((d)->x, (d)->x, (buf), MPFR_RNDN); \
mpfr_mul_ui((buf), (a)->y, (r), MPFR_RNDN); \
mpfr_add((d)->y, (d)->y, (buf), MPFR_RNDN);

Adds the complex number a*r to d, where d,a are complex and r is unsigned integer.

Definition at line 84 of file comp.h.

◆ comp_clear

#define comp_clear (   d)
Value:
mpfr_clear((d)->x); \
mpfr_clear((d)->y);

De-allocates the memory used by the digits of d.

Definition at line 57 of file comp.h.

◆ comp_div

#define comp_div (   d,
  a,
  b,
  b1,
  b2,
  b3 
)
Value:
mpfr_sqr((b3), (b)->x, MPFR_RNDN); \
mpfr_sqr((b2), (b)->y, MPFR_RNDN); \
mpfr_add((b3), (b3), (b2), MPFR_RNDN); \
mpfr_mul((b1), (a)->x, (b)->x, MPFR_RNDN); \
mpfr_mul((b2), (a)->y, (b)->y, MPFR_RNDN); \
mpfr_add((b1), (b1), (b2), MPFR_RNDN); \
mpfr_mul((b2), (a)->x, (b)->y, MPFR_RNDN); \
mpfr_mul((d)->y, (a)->y, (b)->x, MPFR_RNDN); \
mpfr_sub((d)->y, (d)->y, (b2), MPFR_RNDN); \
mpfr_div((d)->y, (d)->y, (b3), MPFR_RNDN); \
mpfr_div((d)->x, (b1), (b3), MPFR_RNDN);

Divides a by b and stores the result in d, all of type comp or comp_ptr.

Definition at line 107 of file comp.h.

◆ comp_init

#define comp_init (   d,
  prec 
)
Value:
mpfr_init2((d)->x, prec); \
mpfr_init2((d)->y, prec);

Allocates memory for the digits of d.

Definition at line 47 of file comp.h.

◆ comp_initz

#define comp_initz (   d,
  prec 
)
Value:
mpfr_init2((d)->x, prec); \
mpfr_init2((d)->y, prec); \
mpfr_set_zero((d)->x, 1); \
mpfr_set_zero((d)->y, 1);

Allocates memory for the digits of d and sets its value to 0.

Definition at line 51 of file comp.h.

◆ comp_mul

#define comp_mul (   d,
  a,
  b,
  buf1,
  buf2 
)
Value:
mpfr_mul((buf1), (a)->x, (b)->x, MPFR_RNDN); \
mpfr_mul((buf2), (a)->y, (b)->y, MPFR_RNDN); \
mpfr_sub((buf1), (buf1), (buf2), MPFR_RNDN); \
mpfr_mul((buf2), (a)->x, (b)->y, MPFR_RNDN); \
mpfr_mul((d)->y, (a)->y, (b)->x, MPFR_RNDN); \
mpfr_add((d)->y, (d)->y, (buf2), MPFR_RNDN); \
mpfr_set((d)->x, (buf1), MPFR_RNDN);

Multiplies a to b and stores the result in d, all of type comp or comp_ptr.

Definition at line 98 of file comp.h.

◆ comp_muli

#define comp_muli (   d,
  a,
 
)
Value:
mpfr_mul_si((d)->x, (a)->x, (i), MPFR_RNDN); \
mpfr_mul_si((d)->y, (a)->y, (i), MPFR_RNDN);

Multiplies the complex number a to the integer i and stores the result in d.

Definition at line 127 of file comp.h.

◆ comp_mulr

#define comp_mulr (   d,
  a,
 
)
Value:
mpfr_mul((d)->x, (a)->x, (r), MPFR_RNDN); \
mpfr_mul((d)->y, (a)->y, (r), MPFR_RNDN);

Multiplies the complex number a to the real number r and stores the result in d.

Definition at line 123 of file comp.h.

◆ comp_mulu

#define comp_mulu (   d,
  a,
 
)
Value:
mpfr_mul_ui((d)->x, (a)->x, (i), MPFR_RNDN); \
mpfr_mul_ui((d)->y, (a)->y, (i), MPFR_RNDN);

Multiplies the complex number a to the unsigned integer i and stores the result in d.

Definition at line 131 of file comp.h.

◆ comp_neg

#define comp_neg (   d,
 
)
Value:
mpfr_neg((d)->x, (a)->x, MPFR_RNDN); \
mpfr_neg((d)->y, (a)->y, MPFR_RNDN);

Sets d to -a.

Definition at line 76 of file comp.h.

◆ comp_set

#define comp_set (   d,
 
)
Value:
mpfr_set((d)->x, (a)->x, MPFR_RNDN); \
mpfr_set((d)->y, (a)->y, MPFR_RNDN);

Sets d to a.

Definition at line 68 of file comp.h.

◆ comp_setr

#define comp_setr (   d,
 
)
Value:
mpfr_set((d)->x, (a), MPFR_RNDN); \
mpfr_set_zero((d)->y, 1);

Sets d to the real value a.

Definition at line 72 of file comp.h.

◆ comp_sqr

#define comp_sqr (   d,
  a,
  buf 
)
Value:
mpfr_sqr((buf), (a)->y, MPFR_RNDN); \
mpfr_mul((d)->y, (a)->x, (a)->y, MPFR_RNDN); \
mpfr_mul_2si((d)->y, (d)->y, 1, MPFR_RNDN); \
mpfr_sqr((d)->x, (a)->x, MPFR_RNDN); \
mpfr_sub((d)->x, (d)->x, (buf), MPFR_RNDN);

Squares a and stores the result in d, all of type comp or comp_ptr.

Definition at line 135 of file comp.h.

◆ comp_sub

#define comp_sub (   d,
  a,
 
)
Value:
mpfr_sub((d)->x, (a)->x, (b)->x, MPFR_RNDN); \
mpfr_sub((d)->y, (a)->y, (b)->y, MPFR_RNDN);

Subtracts b from a and stores the result in d, all of type comp or comp_ptr.

Definition at line 90 of file comp.h.

◆ comp_subr

#define comp_subr (   d,
  a,
 
)
Value:
mpfr_sub((d)->x, (a)->x, (r), MPFR_RNDN); \
mpfr_set((d)->y, (a)->y, MPFR_RNDN);

Subtracts the real number b from the complex number a and stores the result in d.

Definition at line 94 of file comp.h.

Typedef Documentation

◆ comp

typedef comp_struct comp[1]

Practical wrapper for comp_struct.

To avoid the constant use * and & the type compf is a pointer.

Definition at line 39 of file comp.h.

Function Documentation

◆ comp_log2()

real_t comp_log2 ( comp  z)

Computes the base 2 log of |z|.

Parameters
zthe complex number
Returns
log_2(|z|)

◆ comp_s()

real_t comp_s ( comp  z)

Computes s(z).

See also
[1]
Parameters
zthe complex number
Returns
[log_2(|z|)]+1

◆ mpfr_s()

real_t mpfr_s ( mpfr_t  x)

Computes s(x).

See also
[1]
Parameters
xthe real number
Returns
[log_2(|z|)]+1

◆ real_log2()

real_t real_log2 ( mpfr_t  x)

Computes the base 2 log of |x|.

Parameters
xthe real number
Returns
log_2(|x|)