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

Definition of complex polynomials with arbitary precision coefficients. More...

Go to the source code of this file.

Data Structures

struct  poly_struct
 Polynomial with multi-precision floating point complex coefficients. More...
 

Typedefs

typedef poly_struct poly_t[1]
 Practical wrapper for poly_struct. More...
 
typedef poly_structpoly
 Convenience pointer to poly_struct.
 

Functions

poly poly_new (deg_t degree, prec_t prec)
 Returns a new complex polynomial of given degree, with coefficients of precision prec. More...
 
poly poly_from_roots (comp_ptr roots, deg_t degree, prec_t prec)
 Returns a new complex polynomial given the list of its roots, with coefficients of precision prec. More...
 
bool poly_free (poly P)
 Frees all the memory used by the polynomial P, assuming the struct has been allocated with malloc(), for example with poly_new(). More...
 
bool poly_set (poly P, comp coeff, deg_t ind)
 Sets the coefficient of the polynomial P corresponding to the power ind to coeff. More...
 
bool poly_eval (comp res, poly P, comp z)
 Evaluates P(z) using Horner's method. More...
 
bool poly_eval_r (comp res, poly P, mpfr_t x)
 Evaluates P(x) using Horner's method. More...
 
poly poly_derivative (poly P)
 Computes the derivative of P. More...
 
poly poly_sum (poly P, poly Q)
 Computes P+Q. More...
 
poly poly_diff (poly P, poly Q)
 Computes P-Q. More...
 
poly poly_prod (poly P, poly Q)
 Computes P*Q. More...
 
poly poly_sqr (poly P)
 Computes the square of P. More...
 

Detailed Description

Definition of complex polynomials with arbitary precision coefficients.

Definition in file poly.h.

Typedef Documentation

◆ poly_t

typedef poly_struct poly_t[1]

Practical wrapper for poly_struct.

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

Definition at line 43 of file poly.h.

Function Documentation

◆ poly_derivative()

poly poly_derivative ( poly  P)

Computes the derivative of P.

Parameters
Pthe polynomial
Returns
the resulted polynomial, NULL if some error occurred.

◆ poly_diff()

poly poly_diff ( poly  P,
poly  Q 
)

Computes P-Q.

Parameters
Pa polynomial
Qanother polynomial
Returns
the resulted polynomial, NULL if some error occurred.

◆ poly_eval()

bool poly_eval ( comp  res,
poly  P,
comp  z 
)

Evaluates P(z) using Horner's method.

Parameters
resthe result
Pthe polynomial
zthe argument
Returns
true if successfull, false otherwise.

◆ poly_eval_r()

bool poly_eval_r ( comp  res,
poly  P,
mpfr_t  x 
)

Evaluates P(x) using Horner's method.

Parameters
resthe result
Pthe polynomial
xthe real argument
Returns
true if successfull, false otherwise.

◆ poly_free()

bool poly_free ( poly  P)

Frees all the memory used by the polynomial P, assuming the struct has been allocated with malloc(), for example with poly_new().

Parameters
Pthe polynomial
Returns
true if successfull, false otherwise.

◆ poly_from_roots()

poly poly_from_roots ( comp_ptr  roots,
deg_t  degree,
prec_t  prec 
)

Returns a new complex polynomial given the list of its roots, with coefficients of precision prec.

Warning
prec must be at least precf
Parameters
rootsthe roots of the polynomial
degreethe degree of the polynomial
precthe precision of the coefficients, in bits
Returns
the new polynomial, NULL if some error occurred.

◆ poly_new()

poly poly_new ( deg_t  degree,
prec_t  prec 
)

Returns a new complex polynomial of given degree, with coefficients of precision prec.

Warning
prec must be at least precf
Parameters
degreethe degree of the polynomial
precthe precision of the coefficients, in bits
Returns
the new polynomial, NULL if the degree is larger than MAX_DEG.

◆ poly_prod()

poly poly_prod ( poly  P,
poly  Q 
)

Computes P*Q.

Parameters
Pa polynomial
Qanother polynomial
Returns
the resulted polynomial, NULL if some error occurred.

◆ poly_set()

bool poly_set ( poly  P,
comp  coeff,
deg_t  ind 
)

Sets the coefficient of the polynomial P corresponding to the power ind to coeff.

Parameters
Pthe polynomial
coeffthe coefficient
indthe index
Returns
true if successfull, false otherwise.

◆ poly_sqr()

poly poly_sqr ( poly  P)

Computes the square of P.

Parameters
Pthe polynomial
Returns
the resulted polynomial, NULL if some error occurred.

◆ poly_sum()

poly poly_sum ( poly  P,
poly  Q 
)

Computes P+Q.

Parameters
Pa polynomial
Qanother polynomial
Returns
the resulted polynomial, NULL if some error occurred.