Statistiques
| Révision :

root / pobysoC-4.0 / pobyso.h @ 12

Historique | Voir | Annoter | Télécharger (6,92 ko)

1 12 storres
/** @file pobyso.h
2 12 storres
 * Integration of Sollya to C programs
3 12 storres
 * @author S.T.
4 12 storres
 * @date 2011-10-11
5 12 storres
 * Note: pobyso stands for POwered BY SOllya.
6 12 storres
 *                         --      -- --
7 12 storres
 */
8 12 storres
/******************************************************************************/
9 12 storres
10 12 storres
/*
11 12 storres
 * Add below all the headers needed to get this header work.
12 12 storres
 */
13 12 storres
/* <stdio.h> is needed *before* <mpfr.h> for all MPFR input/output functions
14 12 storres
 * prototypes be defined. */
15 12 storres
#include <stdio.h>
16 12 storres
#include <sollya.h>
17 12 storres
#include <mpfr.h>
18 12 storres
19 12 storres
#ifndef POBYSO_h
20 12 storres
21 12 storres
#define POBYSO_ABSOLUTE 1
22 12 storres
#define POBYSO_RELATIVE 2
23 12 storres
/* Mimic the default behavior of interactive Sollya. */
24 12 storres
#define POBYSO_DEFAULT_POINTS 501
25 12 storres
#define POBYSO_INF_NORM_NUM_POINTS (POBYSO_DEFAULT_POINTS)
26 12 storres
#define POBYSO_GUESS_DEGREE_BOUND 1024
27 12 storres
28 12 storres
/**
29 12 storres
 * Print object(s) to stdout.
30 12 storres
 * A very thin wrapper around the lib_sollya_v_autoprint() function.
31 12 storres
 * Should be called with NULL as the final argument.
32 12 storres
 */
33 12 storres
void
34 12 storres
pobyso_autoprint(sollya_obj_t soObj, ...);
35 12 storres
36 12 storres
/**
37 12 storres
 * Print object(s) to stdout: the va_list companion function.
38 12 storres
 * A very thin wrapper around the lib_sollya_v_autoprint() function.
39 12 storres
 * The last argument in the va_list should be NULL.
40 12 storres
 */
41 12 storres
42 12 storres
void
43 12 storres
pobyso_autoprint_v(sollya_obj_t soObj, va_list va);
44 12 storres
45 12 storres
/**
46 12 storres
 * Parse a string to create a Sollya object.
47 12 storres
 * A very thin wrapper around the sollya_lib_parse_string() function.
48 12 storres
 */
49 12 storres
sollya_obj_t
50 12 storres
pobyso_parse_string(const char* expression);
51 12 storres
52 12 storres
/**
53 12 storres
 * Set the verbosity mode off (level 0).
54 12 storres
 * If currentVerbosity != NULL, currentVerbosity is set
55 12 storres
 * to the current verbosity level. It may be used to reset the
56 12 storres
 * verbosity level later.
57 12 storres
 */
58 12 storres
void
59 12 storres
pobyso_set_verbosity_off(sollya_obj_t* currentVerbosityLevel);
60 12 storres
61 12 storres
/**
62 12 storres
 * Set the verbosity level to newVerbosityLevel.
63 12 storres
 * @param newVerbosityLevel must be a Sollay object corresponding to an
64 12 storres
 *        integer constant.
65 12 storres
 */
66 12 storres
void
67 12 storres
pobyso_set_verbosity_to(sollya_obj_t newVerbosityLevel);
68 12 storres
69 12 storres
#if 0
70 12 storres
/**
71 12 storres
 * Create the canonical (non sparse) base of monomials for a given degree.
72 12 storres
 */
73 12 storres
chain*
74 12 storres
pobyso_create_canonical_monomials_base(const unsigned int degree);
75 12 storres

76 12 storres
/**
77 12 storres
 * Create a chain from an array of int.
78 12 storres
 */
79 12 storres
sollya_int_list
80 12 storres
pobyso_create_int_list_from_int_Array(int* intArray,
81 12 storres
                                    const unsigned int arrayLength);
82 12 storres

83 12 storres
/**
84 12 storres
 * Create a chain from an array of int.
85 12 storres
 */
86 12 storres
sollya_int_list_t
87 12 storres
pobyso_create_int_list_from_unsigned_int_array(unsigned int* intArray,
88 12 storres
                                            const unsigned int arrayLength);
89 12 storres
/**
90 12 storres
 * Differentiation of a function.
91 12 storres
 * A slim wrapper around the Sollya differentiate function.
92 12 storres
 * @param functionNode - the Sollya node to differentiate;
93 12 storres
 * @return a node representing the function differentiated or NULL, if
94 12 storres
 *         something goes wrong.
95 12 storres
 */
96 12 storres

97 12 storres
sollya_obj_t
98 12 storres
pobyso_diff(sollya_obj_t function);
99 12 storres

100 12 storres
/**
101 12 storres
 * A match to the Sollya dirtyinfnorm.
102 12 storres
 * A slim wrapper around the Sollya function.
103 12 storres
 * @param infnorm - out parameter to return the result, must be "inited"
104 12 storres
 *                  and "cleared" by the caller;
105 12 storres
 * @param functionNode - the Sollya node to compute the infinite norm of;
106 12 storres
 * @param lowerBound - the lower bound of the interval;
107 12 storres
 * @param upperBound - the upper bound of the interval;
108 12 storres
 * @param precision  - the internal precision Sollya must use.
109 12 storres
 * @return 0 if everything is OK, != 0 if something goes wrong.
110 12 storres
 */
111 12 storres
int
112 12 storres
pobyso_dirty_infnorm(mpfr_t infNorm,
113 12 storres
                      node *functionNode,
114 12 storres
                      mpfr_t lowerBound,
115 12 storres
                      mpfr_t upperBound,
116 12 storres
                      mp_prec_t precision);
117 12 storres

118 12 storres

119 12 storres
/**
120 12 storres
 * Faithful evaluation of an expression.
121 12 storres
 *
122 12 storres
 * @param faitufulEvaluation - holds the result, must be "inited" by the
123 12 storres
 *                             caller;
124 12 storres
 */
125 12 storres
int
126 12 storres
pobyso_evaluate_faithful(mpfr_t faithfulEvaluation,
127 12 storres
                          node *nodeToEvaluate,
128 12 storres
                          mpfr_t argument,
129 12 storres
                          mpfr_prec_t precision);
130 12 storres

131 12 storres
/**
132 12 storres
 * Find the zeros of a function on a given interval.
133 12 storres
 */
134 12 storres
chain*
135 12 storres
pobyso_find_zeros(node *function,
136 12 storres
                  mpfr_t *lowerBound,
137 12 storres
                  mpfr_t *upperBound);
138 12 storres
/**
139 12 storres
 * Free a chain of node.
140 12 storres
 * All elements of the chain have to be nodes.
141 12 storres
 */
142 12 storres
void
143 12 storres
pobyso_free_chain_of_nodes(chain *theChain);
144 12 storres

145 12 storres
/**
146 12 storres
 * Free a range.
147 12 storres
 * It involves clearing the mpfr_t elements and deallocating the
148 12 storres
 * pointers.
149 12 storres
 */
150 12 storres
void
151 12 storres
pobyso_free_range(rangetype range);
152 12 storres

153 12 storres
/**
154 12 storres
 * Computes a good polynomial approximation with fixed-point or floating-point
155 12 storres
 * coefficients.
156 12 storres
 */
157 12 storres
node*
158 12 storres
pobyso_fp_minimax_canonical_monomials_base(node *function,
159 12 storres
                                          int degree,
160 12 storres
                                          chain *formats,
161 12 storres
                                          chain *points,
162 12 storres
                                          mpfr_t lowerBound,
163 12 storres
                                          mpfr_t upperBound,
164 12 storres
                                          int fpFixedArg,
165 12 storres
                                          int absRel,
166 12 storres
                                          node *constPart,
167 12 storres
                                          node *minimax);
168 12 storres
/**
169 12 storres
 * Parses a string to build the node representing the function.
170 12 storres
 * In fact, does nothing for the moment: the string must be a correct function
171 12 storres
 * definition. No error correction takes place here.
172 12 storres
 */
173 12 storres
node*
174 12 storres
pobyso_parse_function(char *functionString,
175 12 storres
                      char *freeVariableNameString);
176 12 storres

177 12 storres
/** Compute a polynomial approximation in the canonical monomials basis for
178 12 storres
 *  a function, for a given precision. The returned polynomial has the minimal
179 12 storres
 *  degree to achieve the required precision.
180 12 storres
 */
181 12 storres
node*
182 12 storres
pobyso_remez_approx_canonical_monomials_base_for_error(node *functionNode,
183 12 storres
                                                      unsigned int mode,
184 12 storres
                                                      mpfr_t lowerBound,
185 12 storres
                                                      mpfr_t upperBound,
186 12 storres
                                                      mpfr_t eps);
187 12 storres

188 12 storres
/**
189 12 storres
 * Computes a the remez approximation of a function.
190 12 storres
 * @param function   - the node holding the function to approximate;
191 12 storres
 * @param weight     - the node holding the weight function, can be NULL. In
192 12 storres
 *                     this case a default weight of "1" will be provided and
193 12 storres
 *                     the approximation is related is with respect to the
194 12 storres
 *                     absolute error.
195 12 storres
 * @param degree     - the degree of the approximation polynomial;
196 12 storres
 * @param lowerBound - the lower bound of the approximation interval;
197 12 storres
 * @param upperBound - the upper bound of the approximation interval;
198 12 storres
 * @param quality    - quality = (eps - eps*) / eps*; the search stop when the required
199 12 storres
 *                     quality is achieved.
200 12 storres
 *
201 12 storres
 * @return a node holding the approximation polynomial in Horner form.
202 12 storres
 */
203 12 storres
node*
204 12 storres
pobyso_remez_canonical_monomials_base(node *function,
205 12 storres
                                       node *weight,
206 12 storres
                                       unsigned int degree,
207 12 storres
                                       mpfr_t lowerBound,
208 12 storres
                                       mpfr_t upperBound,
209 12 storres
                                       mpfr_t quality);
210 12 storres
#endif
211 12 storres
#define POBYSO_h
212 12 storres
213 12 storres
#endif