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

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

Go to the source code of this file.

Data Structures

struct  powsf_struct
 The powers of the complex number z using machine floating point numbers. More...
 

Typedefs

typedef powsf_struct powsf_t[1]
 Practical wrapper for powsf_struct. More...
 
typedef powsf_structpowsf
 Convenience pointer to eval_struct.
 

Functions

powsf powsf_new (deg_t size)
 Returns a new buffer of powers of machine complex numbers, with initial storage space for size powers. More...
 
bool powsf_free (powsf zn)
 Frees all the memory used by the buffer zn, assuming the struct has been allocated with malloc(), for example with powsf_new(). More...
 
bool powsf_set (powsf zn, compf z)
 Sets the complex number of which the powers will be computed by the buffer zn. More...
 
compf_ptr powsf_pow (powsf zn, deg_t pow)
 Computes z^pow using repeated squares method and the cache of previously computed powers. More...
 
compf_ptr powsf_pow_once (powsf zn, deg_t pow)
 Computes z^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 complex number.

Definition in file powsf.h.

Typedef Documentation

◆ powsf_t

typedef powsf_struct powsf_t[1]

Practical wrapper for powsf_struct.

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

Definition at line 41 of file powsf.h.

Function Documentation

◆ powsf_free()

bool powsf_free ( powsf  zn)

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

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

◆ powsf_new()

powsf powsf_new ( deg_t  size)

Returns a new buffer of powers of machine complex 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.

◆ powsf_pow()

compf_ptr powsf_pow ( powsf  zn,
deg_t  pow 
)

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

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

Warning
fails if pow==0
Parameters
znthe powers buffer
powthe power to compute
Returns
the result z^pow, NULL if some error occurred.

◆ powsf_pow_once()

compf_ptr powsf_pow_once ( powsf  zn,
deg_t  pow 
)

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

It does NOT cache intermediary powers of z into zn.

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

◆ powsf_set()

bool powsf_set ( powsf  zn,
compf  z 
)

Sets the complex number of which the powers will be computed by the buffer zn.

Parameters
znthe powers buffer
zthe complex number
Returns
true if successfull, false otherwise.