Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/c_lib/include/mpn_pylong.h
4056 views
1
#ifndef MPN_PYLONG_H
2
#define MPN_PYLONG_H
3
4
#include <Python.h>
5
#include <gmp.h>
6
7
/************************************************************/
8
9
/* Python internals for pylong */
10
11
#include <longintrepr.h>
12
typedef int py_size_t; /* what python uses for ob_size */
13
14
/************************************************************/
15
16
/* mpn -> pylong conversion */
17
18
int mpn_pylong_size (mp_ptr up, mp_size_t un);
19
20
/* Assume digits points to a chunk of size size
21
* where size >= mpn_pylong_size(up, un)
22
*/
23
void mpn_get_pylong (digit *digits, py_size_t size, mp_ptr up, mp_size_t un);
24
25
/************************************************************/
26
27
/* pylong -> mpn conversion */
28
29
mp_size_t mpn_size_from_pylong (digit *digits, py_size_t size);
30
31
/* Assume up points to a chunk of size un
32
* where un >= mpn_size_from_pylong(digits, size)
33
*/
34
void mpn_set_pylong (mp_ptr up, mp_size_t un, digit *digits, py_size_t size);
35
36
/************************************************************/
37
38
/* Python hashing */
39
40
/*
41
* for an mpz, this number has to be multiplied by the sign
42
* also remember to catch -1 and map it to -2 !
43
*/
44
45
long mpn_pythonhash (mp_ptr up, mp_size_t un);
46
47
/************************************************************/
48
49
#endif
50
51