Skip to content

Commit 8eefa22

Browse files
committed
Most recent version
1 parent e068942 commit 8eefa22

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

NormalizModule.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ using std::string;
1818

1919
#include <libnormaliz/libnormaliz.h>
2020

21+
#ifdef ENFNORMALIZ
2122
using eantic::renf_elem_class;
2223
using eantic::renf_class;
24+
#endif
2325

2426
using libnormaliz::Cone;
2527
// using libnormaliz::ConeProperty;
@@ -744,7 +746,7 @@ NmzAutomorphismsToPython(const AutomorphismGroup< Integer >& grp)
744746

745747
#ifdef ENFNORMALIZ
746748
struct NumberFieldCone {
747-
renf_class* nf;
749+
const renf_class* nf;
748750
Cone< renf_elem_class >* cone;
749751
};
750752
#endif
@@ -793,31 +795,31 @@ static Cone< renf_elem_class >* get_cone_renf(PyObject* cone)
793795
return cone_ptr->cone;
794796
}
795797

796-
static renf_class* get_cone_renf_renf(PyObject* cone)
798+
static const renf_class* get_cone_renf_renf(PyObject* cone)
797799
{
798800
NumberFieldCone* cone_ptr = reinterpret_cast< NumberFieldCone* >(
799801
PyCapsule_GetPointer(cone, cone_name_renf));
800802
return cone_ptr->nf;
801803
}
802804
#endif
803805

804-
static PyObject* pack_cone(Cone< mpz_class >* C, void* dummy = nullptr)
806+
static PyObject* pack_cone(Cone< mpz_class >* C, const void* dummy = nullptr)
805807
{
806808
return PyCapsule_New(reinterpret_cast< void* >(C), cone_name,
807809
&delete_cone_mpz);
808810
}
809811

810-
static PyObject* pack_cone(Cone< long long >* C, void* dummy = nullptr)
812+
static PyObject* pack_cone(Cone< long long >* C, const void* dummy = nullptr)
811813
{
812814
return PyCapsule_New(reinterpret_cast< void* >(C), cone_name_long,
813815
&delete_cone_long);
814816
}
815817

816818
#ifdef ENFNORMALIZ
817-
static PyObject* pack_cone(Cone< renf_elem_class >* C, void* nf)
819+
static PyObject* pack_cone(Cone< renf_elem_class >* C, const void* nf)
818820
{
819821
NumberFieldCone* cone_ptr = new NumberFieldCone();
820-
cone_ptr->nf = reinterpret_cast< renf_class* >(nf);
822+
cone_ptr->nf = reinterpret_cast< const renf_class* >(nf);
821823
cone_ptr->cone = C;
822824
return PyCapsule_New(reinterpret_cast< void* >(cone_ptr), cone_name_renf,
823825
&delete_cone_renf);
@@ -1015,9 +1017,9 @@ static PyObject* _NmzConeIntern_renf(PyObject* kwargs)
10151017
string poly = PyUnicodeToString(PySequence_GetItem(number_field_data, 0));
10161018
string var = PyUnicodeToString(PySequence_GetItem(number_field_data, 1));
10171019
string emb = PyUnicodeToString(PySequence_GetItem(number_field_data, 2));
1018-
std::shared_ptr<const renf_class>* renf = new std::shared_ptr<const renf_class>;
1019-
*renf = renf_class::make(poly, var, emb);
1020-
const renf_class* my_renf = renf->get();
1020+
// std::shared_ptr<const renf_class>* renf = new std::shared_ptr<const renf_class>;
1021+
std::shared_ptr<const renf_class> renf = renf_class::make(poly, var, emb);
1022+
const renf_class* my_renf = renf.get();
10211023

10221024
map< InputType, vector< vector< renf_elem_class > > > input;
10231025

@@ -1054,8 +1056,8 @@ static PyObject* _NmzConeIntern_renf(PyObject* kwargs)
10541056

10551057
Cone< renf_elem_class >* C = new Cone< renf_elem_class >(input);
10561058
C->setRenf(my_renf);
1057-
1058-
PyObject* return_container = pack_cone(C, renf);
1059+
1060+
PyObject* return_container = pack_cone(C, my_renf);
10591061

10601062
return return_container;
10611063
FUNC_END
@@ -1323,7 +1325,7 @@ PyObject* _NmzModify(Cone<Integer>* cone, PyObject* args)
13231325
}
13241326

13251327
#ifdef ENFNORMALIZ
1326-
PyObject* _NmzModify_Renf(Cone<renf_elem_class>* cone, renf_class* nf, PyObject* args)
1328+
PyObject* _NmzModify_Renf(Cone<renf_elem_class>* cone, const renf_class* nf, PyObject* args)
13271329
{
13281330
string property = PyUnicodeToString( PyTuple_GetItem(args, 1) );
13291331
PyObject* matrix_py = PyTuple_GetItem(args,2);
@@ -1362,7 +1364,7 @@ PyObject* _NmzModify_Outer(PyObject* self, PyObject* args)
13621364
#ifdef ENFNORMALIZ
13631365
else if (is_cone_renf(cone)) {
13641366
Cone< renf_elem_class >* cone_ptr = get_cone_renf(cone);
1365-
renf_class* nf = get_cone_renf_renf(cone);
1367+
const renf_class* nf = get_cone_renf_renf(cone);
13661368
return _NmzModify_Renf(cone_ptr, nf, args);
13671369
}
13681370
#endif
@@ -1594,7 +1596,7 @@ second is the projection third is the annihilator.
15941596

15951597
template < typename Integer >
15961598
static PyObject*
1597-
_NmzResultImpl(Cone< Integer >* C, PyObject* prop_obj, void* nf = nullptr)
1599+
_NmzResultImpl(Cone< Integer >* C, PyObject* prop_obj, const void* nf = nullptr)
15981600
{
15991601

16001602
string prop = PyUnicodeToString(prop_obj);
@@ -1843,7 +1845,7 @@ MatrixHandler = NULL;
18431845
Cone< renf_elem_class >* cone_ptr = get_cone_renf(cone);
18441846
result = _NmzResultImpl(
18451847
cone_ptr, prop,
1846-
reinterpret_cast< void* >(get_cone_renf_renf(cone)));
1848+
reinterpret_cast< const void* >(get_cone_renf_renf(cone)));
18471849
}
18481850
#endif
18491851

@@ -2423,7 +2425,7 @@ static PyObject* NmzGetRenfInfo(PyObject* self, PyObject* args)
24232425
);
24242426
return NULL;
24252427
}
2426-
renf_class* renf = get_cone_renf_renf(cone_py);
2428+
const renf_class* renf = get_cone_renf_renf(cone_py);
24272429
std::string minpoly_str;
24282430
minpoly_str = fmpq_poly_get_str_pretty(renf->get_renf()->nf->pol, renf->gen_name().c_str());
24292431
std::string res1 = arb_get_str(renf->get_renf()->emb, 64, 0);

0 commit comments

Comments
 (0)