Statistiques
| Révision :

root / pobysoC-4.0 / src / pobyso.h @ 50

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

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

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

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

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

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

118 26 storres

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

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

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

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

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

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