FastPolyEval  1.0
Fast Evaluation of Real and Complex Polynomials
polyr.h
Go to the documentation of this file.
1 //
2 // polyr.h
3 //
4 // Authors: Nicolae Mihalache & François Vigneron
5 //
6 // This software is released under BSD licence, with an attribution clause (see Licence file).
7 // Please cite the reference below if you use or distribute this software.
8 //
9 // • [1] R. Anton, N. Mihalache & F. Vigneron. Fast evaluation of real and complex polynomials. 2022.
10 // https://hal.archives-ouvertes.fr/hal-03820369
11 //
12 // Copyright 2022 Univ. Paris-Est Créteil & Univ. de Reims Champagne-Ardenne.
13 
19 #ifndef polyr_h
20 #define polyr_h
21 
22 #include <mpfr.h>
23 
24 #include "ntypes.h"
25 #include "comp.h"
26 
27 // MARK: data types
28 
31 typedef struct {
34  mpfr_ptr a;
35  bool modified;
36  mpfr_t buf1;
37  mpfr_t buf2;
38 } polyr_struct;
39 
43 typedef polyr_struct polyr_t[1];
44 
47 
48 // MARK: functions prototypes
49 
58 polyr polyr_new(deg_t degree, prec_t prec);
59 
66 bool polyr_free(polyr P);
67 
75 bool polyr_set(polyr P, mpfr_t coeff, deg_t ind);
76 
84 bool polyr_seti(polyr P, long coeff, deg_t ind);
85 
93 bool polyr_eval_c(comp res, polyr P, comp z);
94 
102 bool polyr_eval(mpfr_t res, polyr P, mpfr_t x);
103 
110 
118 
126 
134 
141 
149 polyr poly_hyp(int n, prec_t prec);
150 
157 polyr poly_cheb(int n, prec_t prec);
158 
165 polyr poly_leg(int n, prec_t prec);
166 
173 polyr poly_her(int n, prec_t prec);
174 
181 polyr poly_lag(int n, prec_t prec);
182 
183 #endif /* polyr_h */
Definition of MPFR complex numbers.
comp_struct comp[1]
Practical wrapper for comp_struct.
Definition: comp.h:39
Definition of basic types.
ulong deg_t
The integer number type to use for polynomial degrees and indexes.
Definition: ntypes.h:128
ulong prec_t
The integer number type to use for polynomial degrees and indexes.
Definition: ntypes.h:188
polyr poly_hyp(int n, prec_t prec)
Computes the n-th hyperbolic polynomial, the n-th image of 0 under the iteration of z->z^2+c....
polyr polyr_prod(polyr P, polyr Q)
Computes P*Q.
polyr polyr_new(deg_t degree, prec_t prec)
Returns a new real polynomial of given degree, with coefficients of precision prec.
polyr_struct * polyr
Convenience pointer to polyr_struct.
Definition: polyr.h:46
polyr poly_leg(int n, prec_t prec)
Computes the Legendre polynomial of degree n.
polyr_struct polyr_t[1]
Practical wrapper for polyr_struct.
Definition: polyr.h:43
polyr poly_cheb(int n, prec_t prec)
Computes the Chebyshev polynomial of degree n.
polyr polyr_diff(polyr P, polyr Q)
Computes P-Q.
polyr polyr_derivative(polyr P)
Computes the derivative of P.
bool polyr_set(polyr P, mpfr_t coeff, deg_t ind)
Sets the coefficient of the polynomial P corresponding to the power ind to coeff.
polyr poly_her(int n, prec_t prec)
Computes the Hermite polynomial of degree n.
bool polyr_seti(polyr P, long coeff, deg_t ind)
Sets the coefficient of the polynomial P corresponding to the power ind to coeff.
polyr poly_lag(int n, prec_t prec)
Computes the Laguerre polynomial of degree n.
bool polyr_eval(mpfr_t res, polyr P, mpfr_t x)
Evaluates P(x) using Horner's method.
polyr polyr_sqr(polyr P)
Computes the square of P.
bool polyr_eval_c(comp res, polyr P, comp z)
Evaluates P(z) using Horner's method.
polyr polyr_sum(polyr P, polyr Q)
Computes P+Q.
bool polyr_free(polyr P)
Frees all the memory used by the polynomial P, assuming the struct has been allocated with malloc(),...
Polynomial with multi-precision floating point complex coefficients.
Definition: polyr.h:31
mpfr_ptr a
the coefficients
Definition: polyr.h:34
prec_t prec
the precision of the coefficients, in bits
Definition: polyr.h:33
bool modified
the status of the coefficients
Definition: polyr.h:35
mpfr_t buf2
another buffer
Definition: polyr.h:37
mpfr_t buf1
a buffer
Definition: polyr.h:36
deg_t degree
the degree of the polynomial
Definition: polyr.h:32