Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/c_lib/src/ZZ_pylong.cpp
4026 views
1
/*****************************************************************************
2
# Copyright (C) 2007 William Stein <[email protected]>
3
#
4
# Distributed under the terms of the GNU General Public License (GPL)
5
# as published by the Free Software Foundation; either version 2 of
6
# the License, or (at your option) any later version.
7
# http://www.gnu.org/licenses/
8
#*****************************************************************************/
9
10
/* Author: Joel B. Mohler <[email protected]>
11
2007-06-17 */
12
13
#include "ZZ_pylong.h"
14
#include "ntl_wrap.h"
15
extern "C" {
16
#include "mpz_pylong.h"
17
}
18
19
using namespace NTL;
20
21
/* ZZ -> pylong conversion */
22
PyObject * ZZ_get_pylong(ZZ &z)
23
{
24
mpz_t temp;
25
PyObject *val;
26
mpz_init(temp);
27
ZZ_to_mpz( &temp, &z );
28
val = mpz_get_pylong( temp );
29
mpz_clear( temp );
30
return val;
31
}
32
33
/* pylong -> ZZ conversion */
34
int ZZ_set_pylong(ZZ &z, PyObject * ll)
35
{
36
mpz_t temp;
37
mpz_init(temp);
38
mpz_set_pylong( temp, ll );
39
mpz_to_ZZ( &z, &temp );
40
mpz_clear( temp );
41
return 0;
42
}
43
44