Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 418384/* Implementation specifics for expression evaluation.12Copyright 2000-2002, 2004 Free Software Foundation, Inc.34This file is part of the GNU MP Library.56The GNU MP Library is free software; you can redistribute it and/or modify7it under the terms of either:89* the GNU Lesser General Public License as published by the Free10Software Foundation; either version 3 of the License, or (at your11option) any later version.1213or1415* the GNU General Public License as published by the Free Software16Foundation; either version 2 of the License, or (at your option) any17later version.1819or both in parallel, as here.2021The GNU MP Library is distributed in the hope that it will be useful, but22WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY23or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License24for more details.2526You should have received copies of the GNU General Public License and the27GNU Lesser General Public License along with the GNU MP Library. If not,28see https://www.gnu.org/licenses/. */2930#include <stdarg.h>3132#include "expr.h"333435#define isasciidigit(c) (isascii (c) && isdigit (c))36#define isasciicsym(c) (isascii (c) && (isalnum(c) || (c) == '_'))3738#define isasciidigit_in_base(c,base) \39(isascii (c) \40&& ((isdigit (c) && (c)-'0' < (base)) \41|| (isupper (c) && (c)-'A'+10 < (base)) \42|| (islower (c) && (c)-'a'+10 < (base))))434445union mpX_t {46mpz_t z;47mpq_t q;48mpf_t f;49};5051typedef union mpX_t *mpX_ptr;52typedef const union mpX_t *mpX_srcptr;5354typedef void (*mpexpr_fun_one_t) (mpX_ptr);55typedef unsigned long (*mpexpr_fun_ui_one_t) (mpX_ptr);5657typedef void (*mpexpr_fun_0ary_t) (mpX_ptr);58typedef int (*mpexpr_fun_i_0ary_t) (void);5960typedef void (*mpexpr_fun_unary_t) (mpX_ptr, mpX_srcptr);61typedef void (*mpexpr_fun_unary_ui_t) (mpX_ptr, unsigned long);62typedef int (*mpexpr_fun_i_unary_t) (mpX_srcptr);63typedef int (*mpexpr_fun_i_unary_ui_t) (unsigned long);6465typedef void (*mpexpr_fun_binary_t) (mpX_ptr, mpX_srcptr, mpX_srcptr);66typedef void (*mpexpr_fun_binary_ui_t) (mpX_ptr, mpX_srcptr, unsigned long);67typedef int (*mpexpr_fun_i_binary_t) (mpX_srcptr, mpX_srcptr);68typedef int (*mpexpr_fun_i_binary_ui_t) (mpX_srcptr, unsigned long);6970typedef void (*mpexpr_fun_ternary_t) (mpX_ptr, mpX_srcptr, mpX_srcptr, mpX_srcptr);71typedef void (*mpexpr_fun_ternary_ui_t) (mpX_ptr, mpX_srcptr, mpX_srcptr, unsigned long);72typedef int (*mpexpr_fun_i_ternary_t) (mpX_srcptr, mpX_srcptr, mpX_srcptr);73typedef int (*mpexpr_fun_i_ternary_ui_t) (mpX_srcptr, mpX_srcptr, unsigned long);7475typedef size_t (*mpexpr_fun_number_t) (mpX_ptr, const char *str, size_t len, int base);76typedef void (*mpexpr_fun_swap_t) (mpX_ptr, mpX_ptr);77typedef unsigned long (*mpexpr_fun_get_ui_t) (mpX_srcptr);78typedef void (*mpexpr_fun_set_si_t) (mpX_srcptr, long);7980struct mpexpr_control_t {81const struct mpexpr_operator_t *op;82int argcount;83};8485#define MPEXPR_VARIABLES 268687struct mpexpr_parse_t {88const struct mpexpr_operator_t *table;8990mpX_ptr res;91int base;92unsigned long prec;93const char *e;94size_t elen;95mpX_srcptr *var;96int error_code;9798int token;99const struct mpexpr_operator_t *token_op;100101union mpX_t *data_stack;102int data_top;103int data_alloc;104int data_inited;105106struct mpexpr_control_t *control_stack;107int control_top;108int control_alloc;109110mpexpr_fun_0ary_t mpX_clear;111mpexpr_fun_i_unary_t mpX_ulong_p;112mpexpr_fun_get_ui_t mpX_get_ui;113mpexpr_fun_unary_ui_t mpX_init;114mpexpr_fun_number_t mpX_number;115mpexpr_fun_unary_t mpX_set;116mpexpr_fun_unary_t mpX_set_or_swap;117mpexpr_fun_set_si_t mpX_set_si;118mpexpr_fun_swap_t mpX_swap;119};120121122int mpexpr_evaluate (struct mpexpr_parse_t *p);123int mpexpr_va_to_var (void *var[], va_list ap);124size_t mpexpr_mpz_number (mpz_ptr res, const char *e, size_t elen, int base);125126127