1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
|
#include <sollya.h>
#include <mpfr.h>
#include <mpfi.h>
int stupid_wrapper(sollya_obj_t f, sollya_base_function_t *type, int *n, ...) {
va_list va;
int res;
va_start(va, n);
res = sollya_lib_v_decompose_function(f, type, n, va);
va_end(va);
return res;
}
char *pretty_print(sollya_base_function_t type) {
switch(type) {
case SOLLYA_BASE_FUNC_ABS: return "SOLLYA_BASE_FUNC_ABS";
case SOLLYA_BASE_FUNC_ACOS: return "SOLLYA_BASE_FUNC_ACOS";
case SOLLYA_BASE_FUNC_ACOSH: return "SOLLYA_BASE_FUNC_ACOSH";
case SOLLYA_BASE_FUNC_ADD: return "SOLLYA_BASE_FUNC_ADD";
case SOLLYA_BASE_FUNC_ASIN: return "SOLLYA_BASE_FUNC_ASIN";
case SOLLYA_BASE_FUNC_ASINH: return "SOLLYA_BASE_FUNC_ASINH";
case SOLLYA_BASE_FUNC_ATAN: return "SOLLYA_BASE_FUNC_ATAN";
case SOLLYA_BASE_FUNC_ATANH: return "SOLLYA_BASE_FUNC_ATANH";
case SOLLYA_BASE_FUNC_CEIL: return "SOLLYA_BASE_FUNC_CEIL";
case SOLLYA_BASE_FUNC_CONSTANT: return "SOLLYA_BASE_FUNC_CONSTANT";
case SOLLYA_BASE_FUNC_COS: return "SOLLYA_BASE_FUNC_COS";
case SOLLYA_BASE_FUNC_COSH: return "SOLLYA_BASE_FUNC_COSH";
case SOLLYA_BASE_FUNC_DIV: return "SOLLYA_BASE_FUNC_DIV";
case SOLLYA_BASE_FUNC_DOUBLE: return "SOLLYA_BASE_FUNC_DOUBLE";
case SOLLYA_BASE_FUNC_DOUBLEDOUBLE: return "SOLLYA_BASE_FUNC_DOUBLEDOUBLE";
case SOLLYA_BASE_FUNC_DOUBLEEXTENDED: return "SOLLYA_BASE_FUNC_DOUBLEEXTENDED";
case SOLLYA_BASE_FUNC_ERF: return "SOLLYA_BASE_FUNC_ERF";
case SOLLYA_BASE_FUNC_ERFC: return "SOLLYA_BASE_FUNC_ERFC";
case SOLLYA_BASE_FUNC_EXP: return "SOLLYA_BASE_FUNC_EXP";
case SOLLYA_BASE_FUNC_EXP_M1: return "SOLLYA_BASE_FUNC_EXP_M1";
case SOLLYA_BASE_FUNC_FLOOR: return "SOLLYA_BASE_FUNC_FLOOR";
case SOLLYA_BASE_FUNC_FREE_VARIABLE: return "SOLLYA_BASE_FUNC_FREE_VARIABLE";
case SOLLYA_BASE_FUNC_HALFPRECISION: return "SOLLYA_BASE_FUNC_HALFPRECISION";
case SOLLYA_BASE_FUNC_LIBRARYCONSTANT: return "SOLLYA_BASE_FUNC_LIBRARYCONSTANT";
case SOLLYA_BASE_FUNC_LIBRARYFUNCTION: return "SOLLYA_BASE_FUNC_LIBRARYFUNCTION";
case SOLLYA_BASE_FUNC_LOG: return "SOLLYA_BASE_FUNC_LOG";
case SOLLYA_BASE_FUNC_LOG_10: return "SOLLYA_BASE_FUNC_LOG_10";
case SOLLYA_BASE_FUNC_LOG_1P: return "SOLLYA_BASE_FUNC_LOG_1P";
case SOLLYA_BASE_FUNC_LOG_2: return "SOLLYA_BASE_FUNC_LOG_2";
case SOLLYA_BASE_FUNC_MUL: return "SOLLYA_BASE_FUNC_MUL";
case SOLLYA_BASE_FUNC_NEARESTINT: return "SOLLYA_BASE_FUNC_NEARESTINT";
case SOLLYA_BASE_FUNC_NEG: return "SOLLYA_BASE_FUNC_NEG";
case SOLLYA_BASE_FUNC_PI: return "SOLLYA_BASE_FUNC_PI";
case SOLLYA_BASE_FUNC_POW: return "SOLLYA_BASE_FUNC_POW";
case SOLLYA_BASE_FUNC_PROCEDUREFUNCTION: return "SOLLYA_BASE_FUNC_PROCEDUREFUNCTION";
case SOLLYA_BASE_FUNC_QUAD: return "SOLLYA_BASE_FUNC_QUAD";
case SOLLYA_BASE_FUNC_SIN: return "SOLLYA_BASE_FUNC_SIN";
case SOLLYA_BASE_FUNC_SINGLE: return "SOLLYA_BASE_FUNC_SINGLE";
case SOLLYA_BASE_FUNC_SINH: return "SOLLYA_BASE_FUNC_SINH";
case SOLLYA_BASE_FUNC_SQRT: return "SOLLYA_BASE_FUNC_SQRT";
case SOLLYA_BASE_FUNC_SUB: return "SOLLYA_BASE_FUNC_SUB";
case SOLLYA_BASE_FUNC_TAN: return "SOLLYA_BASE_FUNC_TAN";
case SOLLYA_BASE_FUNC_TANH: return "SOLLYA_BASE_FUNC_TANH";
case SOLLYA_BASE_FUNC_TRIPLEDOUBLE: return"SOLLYA_BASE_FUNC_TRIPLEDOUBLE";
default: return "Unknown type";
}
}
void euler_gamma(mpfr_t res, mp_prec_t prec) {
mpfr_set_prec(res, prec);
mpfr_const_euler(res, GMP_RNDN);
return;
}
int stupid1(mpfi_t result, mpfi_t x, int n) {
(void)x; /* Avoiding "unused parameter" warning */
(void)n; /* Avoiding "unused parameter" warning */
mpfi_set_ui(result, 0);
return 0;
}
/* Note: given as an example in the documentation.
We suppose that the library has already been initialized */
int is_made_of_constants(sollya_obj_t f) {
sollya_obj_t tmp1 = NULL;
sollya_obj_t tmp2 = NULL;
int n, r, res;
sollya_base_function_t type;
r = sollya_lib_decompose_function(f, &type, &n, &tmp1, &tmp2, NULL);
if (!r) { sollya_lib_printf("%b is not a mathematical function.", f); res = 0; }
else if (n >= 3) {
sollya_lib_printf("Unexpected error: %b has more than two arguments.\n", f);
res = 0;
}
else {
switch (type) {
case SOLLYA_BASE_FUNC_FREE_VARIABLE: res = 0; break;
case SOLLYA_BASE_FUNC_PI: res = 1; break;
case SOLLYA_BASE_FUNC_CONSTANT: res = 1; break;
case SOLLYA_BASE_FUNC_LIBRARYCONSTANT: res = 1; break;
default:
res = is_made_of_constants(tmp1);
if ((res) && (n==2)) res = is_made_of_constants(tmp2);
}
}
if (tmp1) sollya_lib_clear_obj(tmp1);
if (tmp2) sollya_lib_clear_obj(tmp2);
return res;
}
int main(void) {
sollya_obj_t f, tmp, tmp2, tmp3;
sollya_base_function_t type;
sollya_obj_t g[3];
int n;
int res;
sollya_lib_init();
/* Constant */
f = SOLLYA_PI;
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, &n, &g[0], &g[1], &g[2], NULL);
if (res) sollya_lib_printf("%b: type = %s, n = %d, subfunctions = %b, %b and %b.\n", f, pretty_print(type), n, g[0], g[1], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s, n=%d, g[0]=%b, g[1]=%b, g[2]=%b. Expecting -1, -1, NULL, NULL, NULL)\n", f, pretty_print(type), n, g[0], g[1], g[2]);
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/* Another constant */
f = SOLLYA_CONST(3);
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, &n, &g[0], &g[1], &g[2], NULL);
if (res) sollya_lib_printf("%b: type = %s, n = %d, subfunctions = %b, %b and %b.\n", f, pretty_print(type), n, g[0], g[1], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s, n=%d, g[0]=%b, g[1]=%b, g[2]=%b. Expecting -1, -1, NULL, NULL, NULL)\n", f, pretty_print(type), n, g[0], g[1], g[2]);
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/* A library constant constant */
f = sollya_lib_libraryconstant("superconst", euler_gamma);
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, &n, &g[0], &g[1], &g[2], NULL);
if (res) sollya_lib_printf("%b: type = %s, n = %d, subfunctions = %b, %b and %b.\n", f, pretty_print(type), n, g[0], g[1], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s, n=%d, g[0]=%b, g[1]=%b, g[2]=%b. Expecting -1, -1, NULL, NULL, NULL)\n", f, pretty_print(type), n, g[0], g[1], g[2]);
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/* Free variable */
f = SOLLYA_X_;
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, &n, &g[0], &g[1], &g[2], NULL);
if (res) sollya_lib_printf("%b: type = %s, n = %d, subfunctions = %b, %b and %b.\n", f, pretty_print(type), n, g[0], g[1], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s, n=%d, g[0]=%b, g[1]=%b, g[2]=%b. Expecting -1, -1, NULL, NULL, NULL)\n", f, pretty_print(type), n, g[0], g[1], g[2]);
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/* Elementary function */
f = SOLLYA_EXP(SOLLYA_ADD(SOLLYA_SIN(SOLLYA_X_), SOLLYA_CONST(17)));
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, &n, &g[0], &g[1], &g[2], NULL);
if (res) sollya_lib_printf("%b: type = %s, n = %d, subfunctions = %b, %b and %b.\n", f, pretty_print(type), n, g[0], g[1], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s, n=%d, g[0]=%b, g[1]=%b, g[2]=%b. Expecting -1, -1, NULL, NULL, NULL)\n", f, pretty_print(type), n, g[0], g[1], g[2]);
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/* Procedure function */
tmp = sollya_lib_parse_string("proc(X,n,p) {var res, oldPrec; oldPrec = prec; prec = p!; res = exp(X); prec = oldPrec!; return res; };");
tmp = sollya_lib_build_function_procedurefunction(SOLLYA_X_, tmp);
tmp2 = sollya_lib_diff(tmp);
tmp3 = SOLLYA_SIN(SOLLYA_X_);
f = sollya_lib_apply(tmp2, tmp3, NULL);
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, &n, &g[0], &g[1], &g[2], NULL);
if (res) sollya_lib_printf("%b: type = %s, n = %d, subfunctions = %b, %b and %b.\n", f, pretty_print(type), n, g[0], g[1], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s, n=%d, g[0]=%b, g[1]=%b, g[2]=%b. Expecting -1, -1, NULL, NULL, NULL)\n", f, pretty_print(type), n, g[0], g[1], g[2]);
sollya_lib_clear_obj(tmp);
sollya_lib_clear_obj(tmp2);
sollya_lib_clear_obj(tmp3);
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/* Library function */
f = sollya_lib_build_function_libraryfunction(SOLLYA_COS(SOLLYA_X_), "stupid1", stupid1);
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, &n, &g[0], &g[1], &g[2], NULL);
if (res) sollya_lib_printf("%b: type = %s, n = %d, subfunctions = %b, %b and %b.\n", f, pretty_print(type), n, g[0], g[1], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s, n=%d, g[0]=%b, g[1]=%b, g[2]=%b. Expecting -1, -1, NULL, NULL, NULL)\n", f, pretty_print(type), n, g[0], g[1], g[2]);
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/* arithmetic operator */
f = SOLLYA_ADD(SOLLYA_X_,
sollya_lib_build_function_libraryfunction(SOLLYA_X_, "stupid1", stupid1));
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, &n, &g[0], &g[1], &g[2], NULL);
if (res) sollya_lib_printf("%b: type = %s, n = %d, subfunctions = %b, %b and %b.\n", f, pretty_print(type), n, g[0], g[1], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s, n=%d, g[0]=%b, g[1]=%b, g[2]=%b. Expecting -1, -1, NULL, NULL, NULL)\n", f, pretty_print(type), n, g[0], g[1], g[2]);
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/* A Sollya object that is not an expression */
f = sollya_lib_absolute();
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, &n, &g[0], &g[1], &g[2], NULL);
if (res) sollya_lib_printf("%b: type = %s, n = %d, subfunctions = %b, %b and %b.\n", f, pretty_print(type), n, g[0], g[1], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s. Expecting 'Unknown type')\n", f, pretty_print(type));
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/* Another one */
f = sollya_lib_parse_string("[1,2]");
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, &n, &g[0], &g[1], &g[2], NULL);
if (res) sollya_lib_printf("%b: type = %s, n = %d, subfunctions = %b, %b and %b.\n", f, pretty_print(type), n, g[0], g[1], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s. Expecting 'Unknown type')\n", f, pretty_print(type));
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/*************************************************************/
/* Testing what happens when NULL is encountered prematurely */
/*************************************************************/
/* As second argument */
f = SOLLYA_EXP(SOLLYA_ADD(SOLLYA_SIN(SOLLYA_X_), SOLLYA_CONST(17)));
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, NULL, &n, &g[1], &g[2]);
if (res) sollya_lib_printf("NULL given as 2nd argument. %b: type = %s, n = %d, subfunctions = %b and %b.\n", f, pretty_print(type), n, g[1], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s. Expecting 'Unknown type')\n", f, pretty_print(type));
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/* As third argument */
f = SOLLYA_EXP(SOLLYA_ADD(SOLLYA_SIN(SOLLYA_X_), SOLLYA_CONST(17)));
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, NULL, &g[1], &g[2]);
if (res) sollya_lib_printf("NULL given as 3rd argument. %b: type = %s, n = %d, subfunctions = %b and %b.\n", f, pretty_print(type), n, g[1], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s. Expecting 'Unknown type')\n", f, pretty_print(type));
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/* As fourth argument */
f = SOLLYA_EXP(SOLLYA_ADD(SOLLYA_SIN(SOLLYA_X_), SOLLYA_CONST(17)));
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, &n, NULL, &g[1], &g[2]);
if (res) sollya_lib_printf("NULL given as 4th argument. %b: type = %s, n = %d, subfunctions = %b and %b.\n", f, pretty_print(type), n, g[1], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s. Expecting 'Unknown type')\n", f, pretty_print(type));
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/* As fourth argument in a binary operator */
f = SOLLYA_ADD(SOLLYA_SIN(SOLLYA_X_), SOLLYA_CONST(17));
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, &n, NULL, &g[1], &g[2]);
if (res) sollya_lib_printf("NULL given as 4th argument. %b: type = %s, n = %d, subfunctions = %b and %b.\n", f, pretty_print(type), n, g[1], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s. Expecting 'Unknown type')\n", f, pretty_print(type));
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/* As fifth argument in a binary operator */
f = SOLLYA_ADD(SOLLYA_SIN(SOLLYA_X_), SOLLYA_CONST(17));
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, &n, &g[0], NULL, &g[2]);
if (res) sollya_lib_printf("NULL given as 5th argument. %b: type = %s, n = %d, subfunctions = %b and %b.\n", f, pretty_print(type), n, g[0], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s. Expecting 'Unknown type')\n", f, pretty_print(type));
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/* As fourth argument in a library function */
f = sollya_lib_build_function_libraryfunction(SOLLYA_COS(SOLLYA_X_), "stupid1", stupid1);
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, &n, NULL, &g[1], &g[2]);
if (res) sollya_lib_printf("NULL given as 4th argument. %b: type = %s, n = %d, subfunctions = %b and %b.\n", f, pretty_print(type), n, g[1], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s. Expecting 'Unknown type')\n", f, pretty_print(type));
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/* As fifth argument in a library function */
f = sollya_lib_build_function_libraryfunction(SOLLYA_COS(SOLLYA_X_), "stupid1", stupid1);
type = (sollya_base_function_t) -1;
g[0] = NULL; g[1] = NULL; g[2] = NULL;
n = -1;
res = stupid_wrapper(f, &type, &n, &g[0], NULL, &g[2]);
if (res) sollya_lib_printf("NULL given as 5th argument. %b: type = %s, n = %d, subfunctions = %b and %b.\n", f, pretty_print(type), n, g[0], g[2]);
else sollya_lib_printf("%b is not a functional expression (type=%s. Expecting 'Unknown type')\n", f, pretty_print(type));
sollya_lib_clear_obj(f);
sollya_lib_clear_obj(g[0]);
sollya_lib_clear_obj(g[1]);
sollya_lib_clear_obj(g[2]);
/*******************************************************/
/* Testing the function presented in the documentation */
/*******************************************************/
f = sollya_lib_libraryconstant("superconst", euler_gamma);
f = SOLLYA_MUL(SOLLYA_ADD(SOLLYA_PI, SOLLYA_CONST(1)), f);
if (is_made_of_constants(f)) sollya_lib_printf("%b is made of constants.\n", f);
else sollya_lib_printf("%b is *NOT* made of constants.\n", f);
sollya_lib_clear_obj(f);
f = SOLLYA_X_;
if (is_made_of_constants(f)) sollya_lib_printf("%b is made of constants.\n", f);
else sollya_lib_printf("%b is *NOT* made of constants.\n", f);
sollya_lib_clear_obj(f);
f = SOLLYA_SIN(SOLLYA_ADD(SOLLYA_X_, SOLLYA_CONST(1)));
if (is_made_of_constants(f)) sollya_lib_printf("%b is made of constants.\n", f);
else sollya_lib_printf("%b is *NOT* made of constants.\n", f);
sollya_lib_clear_obj(f);
f = SOLLYA_SIN(SOLLYA_EXP(SOLLYA_CONST(1)));
if (is_made_of_constants(f)) sollya_lib_printf("%b is made of constants.\n", f);
else sollya_lib_printf("%b is *NOT* made of constants.\n", f);
sollya_lib_clear_obj(f);
f = sollya_lib_parse_string("[0,1]");
if (is_made_of_constants(f)) sollya_lib_printf("%b is made of constants.\n", f);
else sollya_lib_printf("%b is *NOT* made of constants.\n", f);
sollya_lib_clear_obj(f);
f = sollya_lib_relative();
if (is_made_of_constants(f)) sollya_lib_printf("%b is made of constants.\n", f);
else sollya_lib_printf("%b is *NOT* made of constants.\n", f);
sollya_lib_clear_obj(f);
sollya_lib_close();
return 0;
}
|