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

Definition of a buffer for pre-computed powers of a real number with arbitary precision. More...

Go to the source code of this file.

Data Structures

struct  powsr_struct
 The powers of the real number x using multi-precision floating point numbers. More...
 

Typedefs

typedef powsr_struct powsr_t[1]
 Practical wrapper for powsr_struct. More...
 
typedef powsr_structpowsr
 Convenience pointer to eval_struct.
 

Functions

powsr powsr_new (prec_t prec, deg_t size)
 Returns a new buffer of powers of real numbers of precision prec, with initial storage space for size powers. More...
 
bool powsr_free (powsr xn)
 Frees all the memory used by the buffer xn, assuming the struct has been allocated with malloc(), for example with powsr_new(). More...
 
bool powsr_set (powsr xn, mpfr_t x)
 Sets the real number of which the powers will be computed by the buffer xn. More...
 
mpfr_ptr powsr_pow (powsr xn, deg_t pow)
 Computes x^pow using repeated squares method and the cache of previously computed powers. More...
 
mpfr_ptr powsr_pow_once (powsr xn, deg_t pow)
 Computes x^pow using repeated squares method and the cache of previously computed powers. More...
 

Detailed Description

Definition of a buffer for pre-computed powers of a real number with arbitary precision.

Definition in file powsr.h.

Typedef Documentation

◆ powsr_t

typedef powsr_struct powsr_t[1]

Practical wrapper for powsr_struct.

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

Definition at line 63 of file powsr.h.

Function Documentation

◆ powsr_free()

bool powsr_free ( powsr  xn)

Frees all the memory used by the buffer xn, assuming the struct has been allocated with malloc(), for example with powsr_new().

Parameters
xnthe powers buffer
Returns
true if successfull, false otherwise.

◆ powsr_new()

powsr powsr_new ( prec_t  prec,
deg_t  size 
)

Returns a new buffer of powers of real numbers of precision prec, with initial storage space for size powers.

Warning
prec must be at least precf and size at most MAX_DEG.
Parameters
precthe precision of the coefficients, in bits
sizethessize of the buffer
Returns
the new buffer, NULL if some error occurred.

◆ powsr_pow()

mpfr_ptr powsr_pow ( powsr  xn,
deg_t  pow 
)

Computes x^pow using repeated squares method and the cache of previously computed powers.

It caches intermediary powers of x that have been computed to accelerate later calls of this function. Also, if pow is larger than the size of the buffer xn, it is automatically increased to store the result.

Parameters
xnthe powers buffer
powthe power to compute
Returns
the result x^pow, NULL if some error occurred.

◆ powsr_pow_once()

mpfr_ptr powsr_pow_once ( powsr  xn,
deg_t  pow 
)

Computes x^pow using repeated squares method and the cache of previously computed powers.

It does NOT cache intermediary powers of x into xn.

Parameters
xnthe powers buffer
powthe power to compute
Returns
the result x^pow, NULL if some error occurred.

◆ powsr_set()

bool powsr_set ( powsr  xn,
mpfr_t  x 
)

Sets the real number of which the powers will be computed by the buffer xn.

Parameters
xnthe powers buffer
xthe complex number
Returns
true if successfull, false otherwise.