FastPolyEval  1.0
Fast Evaluation of Real and Complex Polynomials
powsr.h
Go to the documentation of this file.
1 //
2 // powsr.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 //
14 
20 #ifndef powsr_h
21 #define powsr_h
22 
23 #include <mpfr.h>
24 
25 #include "ntypes.h"
26 
27 // MARK: data types
28 
29 // comment this line to use repeated squares method and buffers to compute powers of @c x
30 // leave uncommented tu use a direct computation with @c mpfr_pow_ui()
31 #define POWSR_DIRECT_POWERS
32 
33 #ifdef POWSR_DIRECT_POWERS
34 
37 typedef struct {
39  bool inited;
40  mpfr_t x;
41  mpfr_t res;
42 } powsr_struct;
43 
44 #else
45 
48 typedef struct {
49  prec_t prec;
50  deg_t size;
51  byte tps;
52  bool *computed;
53  mpfr_ptr xn;
54  mpfr_t pth;
55  mpfr_t res;
56 } powsr_struct;
57 
58 #endif
59 
63 typedef powsr_struct powsr_t[1];
64 
67 
68 // MARK: macros & functions prototypes
69 
80 
87 bool powsr_free(powsr xn);
88 
95 bool powsr_set(powsr xn, mpfr_t x);
96 
106 mpfr_ptr powsr_pow(powsr xn, deg_t pow);
107 
116 mpfr_ptr powsr_pow_once(powsr xn, deg_t pow);
117 
118 #endif /* powsr_h */
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
mpfr_ptr powsr_pow_once(powsr xn, deg_t pow)
Computes x^pow using repeated squares method and the cache of previously computed powers.
powsr_struct powsr_t[1]
Practical wrapper for powsr_struct.
Definition: powsr.h:63
powsr_struct * powsr
Convenience pointer to eval_struct.
Definition: powsr.h:66
bool powsr_set(powsr xn, mpfr_t x)
Sets the real number of which the powers will be computed by the buffer xn.
bool powsr_free(powsr xn)
Frees all the memory used by the buffer xn, assuming the struct has been allocated with malloc(),...
mpfr_ptr powsr_pow(powsr xn, deg_t pow)
Computes x^pow using repeated squares method and the cache of previously computed powers.
powsr powsr_new(prec_t prec, deg_t size)
Returns a new buffer of powers of real numbers of precision prec, with initial storage space for size...
The powers of the real number x using multi-precision floating point numbers.
Definition: powsr.h:37
prec_t prec
the precision of the powers of x, in bits
Definition: powsr.h:38
bool inited
the status of the value x
Definition: powsr.h:39
mpfr_t res
a buffer
Definition: powsr.h:41
mpfr_t x
the real number
Definition: powsr.h:40