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

Definition of a buffer for pre-computed powers of a machine real number. More...

Go to the source code of this file.

Data Structures

struct  powsfr_struct
 The powers of the real number x using machine floating point numbers. More...
 

Typedefs

typedef powsfr_struct powsfr_t[1]
 Practical wrapper for powsfr_struct. More...
 
typedef powsfr_structpowsfr
 Convenience pointer to eval_struct.
 

Functions

powsfr powsfr_new (deg_t size)
 Returns a new buffer of powers of machine real numbers, with initial storage space for size powers. More...
 
bool powsfr_free (powsfr xn)
 Frees all the memory used by the buffer xn, assuming the struct has been allocated with malloc(), for example with powsfr_new(). More...
 
bool powsfr_set (powsfr xn, coeff_t x)
 Sets the real number of which the powers will be computed by the buffer xn. More...
 
coeff_t powsfr_pow (powsfr xn, deg_t pow)
 Computes x^pow using repeated squares method and the cache of previously computed powers. More...
 
coeff_t powsfr_pow_once (powsfr 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 machine real number.

Definition in file powsfr.h.

Typedef Documentation

◆ powsfr_t

typedef powsfr_struct powsfr_t[1]

Practical wrapper for powsfr_struct.

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

Definition at line 56 of file powsfr.h.

Function Documentation

◆ powsfr_free()

bool powsfr_free ( powsfr  xn)

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

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

◆ powsfr_new()

powsfr powsfr_new ( deg_t  size)

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

Warning
size must be at most MAX_DEG.
Parameters
sizethe size of the buffer
Returns
the new buffer, NULL if some error occurred.

◆ powsfr_pow()

coeff_t powsfr_pow ( powsfr  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, NaN if some error occurred.

◆ powsfr_pow_once()

coeff_t powsfr_pow_once ( powsfr  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.

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

◆ powsfr_set()

bool powsfr_set ( powsfr  xn,
coeff_t  x 
)

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

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