1 /** @file py_func.cpp 2 * 3 * Function table containing the functions used in the Sage - Pynac 4 * interface. 5 * */ 6 7 #ifndef PY_FUNC_H_ 8 # define PY_FUNC_H_ 9 10 #include "basic.h" 11 #include "constant.h" 12 #include "ex.h" 13 14 #include <gmp.h> 15 #include <stdexcept> 16 #include <vector> 17 #include <iostream> 18 19 namespace GiNaC { 20 typedef std::multiset<unsigned> paramset; 21 22 struct py_funcs_struct { 23 PyObject* (*py_gcd)(PyObject* a, PyObject* b); 24 PyObject* (*py_lcm)(PyObject* a, PyObject* b); 25 PyObject* (*py_real)(PyObject* a); 26 PyObject* (*py_imag)(PyObject* a); 27 PyObject* (*py_numer)(PyObject* a); 28 PyObject* (*py_denom)(PyObject* a); 29 int (*py_is_rational)(PyObject* a); 30 int (*py_is_real)(PyObject* a); 31 int (*py_is_integer)(PyObject* a); 32 int (*py_is_equal)(PyObject* a, PyObject* b); 33 int (*py_is_even)(PyObject* a); 34 int (*py_is_prime)(PyObject* n); 35 int (*py_is_exact)(PyObject* a); 36 37 PyObject* (*py_integer_from_long)(long int x); 38 PyObject* (*py_integer_from_python_obj)(PyObject* x); 39 PyObject* (*py_integer_from_mpz)(mpz_t); 40 PyObject* (*py_rational_from_mpq)(mpq_t); 41 int (*py_is_Integer)(PyObject *); 42 int (*py_is_Rational)(PyObject *); 43 __mpz_struct* (*py_mpz_from_integer)(PyObject *); 44 __mpq_struct* (*py_mpq_from_rational)(PyObject *); 45 46 PyObject* (*py_float)(PyObject* a, PyObject* parent); 47 48 PyObject* (*py_factorial)(PyObject* a); 49 PyObject* (*py_fibonacci)(PyObject* n); 50 PyObject* (*py_step)(PyObject* n); 51 PyObject* (*py_doublefactorial)(PyObject* a); 52 PyObject* (*py_bernoulli)(PyObject* n); 53 PyObject* (*py_sin)(PyObject* n); 54 PyObject* (*py_cos)(PyObject* n); 55 PyObject* (*py_zeta)(PyObject* n); 56 PyObject* (*py_stieltjes)(PyObject* n); 57 PyObject* (*py_exp)(PyObject* n); 58 PyObject* (*py_log)(PyObject* n); 59 PyObject* (*py_tan)(PyObject* n); 60 PyObject* (*py_asin)(PyObject* n); 61 PyObject* (*py_acos)(PyObject* n); 62 PyObject* (*py_atan)(PyObject* n); 63 PyObject* (*py_atan2)(PyObject* n, PyObject* y); 64 PyObject* (*py_sinh)(PyObject* n); 65 PyObject* (*py_cosh)(PyObject* n); 66 PyObject* (*py_tanh)(PyObject* n); 67 PyObject* (*py_asinh)(PyObject* n); 68 PyObject* (*py_acosh)(PyObject* n); 69 PyObject* (*py_atanh)(PyObject* n); 70 PyObject* (*py_psi)(PyObject* n); 71 PyObject* (*py_psi2)(PyObject* n, PyObject* b); 72 PyObject* (*py_isqrt)(PyObject* n); 73 PyObject* (*py_sqrt)(PyObject* n); 74 PyObject* (*py_mod)(PyObject* n, PyObject* b); 75 PyObject* (*py_smod)(PyObject* n, PyObject* b); 76 PyObject* (*py_irem)(PyObject* n, PyObject* b); 77 78 PyObject* (*py_eval_constant)(unsigned serial, PyObject* parent); 79 PyObject* (*py_eval_unsigned_infinity)(); 80 PyObject* (*py_eval_infinity)(); 81 PyObject* (*py_eval_neg_infinity)(); 82 83 // we use this to check if the element lives in a domain of positive 84 // characteristic, in which case we have to do modulo reductions 85 int (*py_get_parent_char)(PyObject* o); 86 87 // printing helpers 88 std::string* (*py_latex)(PyObject* o, int level); 89 std::string* (*py_repr)(PyObject* o, int level); 90 91 // archive helper 92 std::string* (*py_dumps)(PyObject* o); 93 PyObject* (*py_loads)(PyObject* s); 94 95 PyObject* (*exvector_to_PyTuple)(GiNaC::exvector seq); 96 GiNaC::ex (*pyExpression_to_ex)(PyObject* s); 97 PyObject* (*ex_to_pyExpression)(GiNaC::ex e); 98 std::string* (*py_print_function)(unsigned id, PyObject* args); 99 std::string* (*py_latex_function)(unsigned id, PyObject* args); 100 PyObject* (*subs_args_to_PyTuple)(const GiNaC::exmap & m, unsigned options, const GiNaC::exvector & seq); 101 int (*py_get_ginac_serial)(); 102 PyObject* (*py_get_sfunction_from_serial)(unsigned id); 103 unsigned (*py_get_serial_from_sfunction)(PyObject* f); 104 unsigned (*py_get_serial_for_new_sfunction)(std::string &s, unsigned nargs); 105 106 constant (*py_get_constant)(const char* name); 107 108 std::string* (*py_print_fderivative)(unsigned id, PyObject* params, PyObject* args); 109 std::string* (*py_latex_fderivative)(unsigned id, PyObject* params, PyObject* args); 110 PyObject* (*paramset_to_PyTuple)(const GiNaC::paramset &s); 111 112 }; 113 114 extern py_funcs_struct py_funcs; 115 116 } 117 118 119 #endif /* !PY_FUNC_H_ */ 120