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

Definition of a list that can quickly sort real machine floating-point numbers and keep track of their permutation. More...

Go to the source code of this file.

Data Structures

struct  list_struct
 A list of real numbers that can be sorted, while keeping track of original order. More...
 

Macros

#define LIST_FACTOR   1.2
 The multiplicative factor by which to grow the lists.
 
#define LIST_TERM   100
 The additive term by which to grow the lists.
 

Typedefs

typedef list_struct list_t[1]
 Practical wrapper for list_struct. More...
 
typedef list_structlist
 Convenience pointer to list_struct.
 

Functions

list list_new (deg_t size)
 Returns a new list of machine real numbers, with storage space for size numbers. More...
 
bool list_init (list l, deg_t size)
 Initializes an existing list l with storage space for size numbers. More...
 
bool list_free (list l)
 Frees all the memory used by the list l, assuming the struct has been allocated with malloc(), for example with list_new(). More...
 
bool list_clear (list l)
 Frees all the memory used by the list l, but not the list l itself. More...
 
list list_clone (list l)
 Returns a copy of the list l. More...
 
bool list_add (list l, deg_t k, real_t s)
 Adds the couple (k,s) at a new position at the end of the list l. More...
 
bool list_trim (list l)
 Trims the list l to minimal size to contain all its elements. More...
 
bool list_sort (list l)
 Sorts the list in descending order while preserving couples (k[i],s[i]) for all i. More...
 

Detailed Description

Definition of a list that can quickly sort real machine floating-point numbers and keep track of their permutation.

Definition in file list.h.

Typedef Documentation

◆ list_t

typedef list_struct list_t[1]

Practical wrapper for list_struct.

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

Definition at line 46 of file list.h.

Function Documentation

◆ list_add()

bool list_add ( list  l,
deg_t  k,
real_t  s 
)

Adds the couple (k,s) at a new position at the end of the list l.

Parameters
lthe list
kthe index
sthe real number
Returns
true if successfull, false otherwise.

◆ list_clear()

bool list_clear ( list  l)

Frees all the memory used by the list l, but not the list l itself.

Parameters
lthe list
Returns
true if successfull, false otherwise.

◆ list_clone()

list list_clone ( list  l)

Returns a copy of the list l.

Parameters
lthe list
Returns
the new list, NULL if some error occurred.

◆ list_free()

bool list_free ( list  l)

Frees all the memory used by the list l, assuming the struct has been allocated with malloc(), for example with list_new().

Parameters
lthe list
Returns
true if successfull, false otherwise.

◆ list_init()

bool list_init ( list  l,
deg_t  size 
)

Initializes an existing list l with storage space for size numbers.

Parameters
lthe list
sizethe size of the list
Returns
true if successfull, false otherwise.

◆ list_new()

list list_new ( deg_t  size)

Returns a new list of machine real numbers, with storage space for size numbers.

Parameters
sizethe size of the list
Returns
the new list, NULL if some error occurred.

◆ list_sort()

bool list_sort ( list  l)

Sorts the list in descending order while preserving couples (k[i],s[i]) for all i.

Warning
The memory usage will double during the operation, all cleared up before returning. In case of failure, the original list is destroyed.
Parameters
lthe list
Returns
true if successfull, false otherwise.

◆ list_trim()

bool list_trim ( list  l)

Trims the list l to minimal size to contain all its elements.

Parameters
lthe list
Returns
true if successfull, false otherwise.