chiark
/
gitweb
/
~mdw
/
catacomb-python
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
catacomb/__init__.py: Import `sys' as a whole.
[catacomb-python]
/
field.c
diff --git
a/field.c
b/field.c
index af7a561fd69f02dcec684d1c61fd3d2052368324..fae03653140d1db5dd984aa8cd311e83a07e8865 100644
(file)
--- a/
field.c
+++ b/
field.c
@@
-1,6
+1,4
@@
/* -*-c-*-
/* -*-c-*-
- *
- * $Id$
*
* Abstract fields
*
*
* Abstract fields
*
@@
-68,7
+66,7
@@
static PyObject *field_dopywrap(PyTypeObject *ty, field *f)
fobj->ty.ht_type.tp_alloc = PyType_GenericAlloc;
fobj->ty.ht_type.tp_free = 0;
fobj->ty.ht_type.tp_new = fe_pynew;
fobj->ty.ht_type.tp_alloc = PyType_GenericAlloc;
fobj->ty.ht_type.tp_free = 0;
fobj->ty.ht_type.tp_new = fe_pynew;
-
PyType_R
eady(&fobj->ty.ht_type);
+
typer
eady(&fobj->ty.ht_type);
return ((PyObject *)fobj);
}
return ((PyObject *)fobj);
}
@@
-231,13
+229,7
@@
end:
}
static long fe_pyhash(PyObject *me)
}
static long fe_pyhash(PyObject *me)
-{
- long i = mp_tolong(FE_X(me));
- i ^= 0xdcf62d6c; /* random perturbance */
- if (i == -1)
- i = -2;
- return (i);
-}
+ { return (mphash(FE_X(me))); }
static int fe_pycoerce(PyObject **x, PyObject **y)
{
static int fe_pycoerce(PyObject **x, PyObject **y)
{
@@
-263,10
+255,12
@@
end:
static PyObject *fe_pyint(PyObject *x)
{
long l;
static PyObject *fe_pyint(PyObject *x)
{
long l;
+ PyObject *rc;
mp *xx = F_OUT(FE_F(x), MP_NEW, FE_X(x));
mp *xx = F_OUT(FE_F(x), MP_NEW, FE_X(x));
- if (mp_tolong_checked(xx, &l)) { MP_DROP(xx); return (0); }
+ if (!mp_tolong_checked(xx, &l, 0)) rc = PyInt_FromLong(l);
+ else rc = mp_topylong(xx);
MP_DROP(xx);
MP_DROP(xx);
- return (
PyInt_FromLong(l)
);
+ return (
rc
);
}
static PyObject *fe_pylong(PyObject *x)
}
static PyObject *fe_pylong(PyObject *x)
@@
-280,7
+274,7
@@
static PyObject *fe_pylong(PyObject *x)
#define BASEOP(name, radix, pre) \
static PyObject *fe_py##name(PyObject *x) { \
mp *xx = F_OUT(FE_F(x), MP_NEW, FE_X(x)); \
#define BASEOP(name, radix, pre) \
static PyObject *fe_py##name(PyObject *x) { \
mp *xx = F_OUT(FE_F(x), MP_NEW, FE_X(x)); \
- PyObject *rc = mp_topystring(
FE_X(x), radix, 0, pre, 0);
\
+ PyObject *rc = mp_topystring(
xx, radix, 0, pre, 0);
\
MP_DROP(xx); \
return (rc); \
}
MP_DROP(xx); \
return (rc); \
}
@@
-343,8
+337,8
@@
static PyObject *feget__value(PyObject *me, void *hunoz)
static PyGetSetDef fe_pygetset[] = {
#define GETSETNAME(op, name) fe##op##_##name
GET (field, "X.field -> field containing X")
static PyGetSetDef fe_pygetset[] = {
#define GETSETNAME(op, name) fe##op##_##name
GET (field, "X.field -> field containing X")
- GET (value, "X.value -> `natural'
integer
representation of X")
- GET (_value, "X._value -> internal
integer
representation of X")
+ GET (value, "X.value -> `natural'
MP/GF
representation of X")
+ GET (_value, "X._value -> internal
MP/GF
representation of X")
#undef GETSETNAME
{ 0 }
};
#undef GETSETNAME
{ 0 }
};
@@
-408,7
+402,7
@@
static PyNumberMethods fe_pynumber = {
static PyTypeObject fe_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
static PyTypeObject fe_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "
catacomb.FE",
/* @tp_name@ */
+ "
FE",
/* @tp_name@ */
sizeof(fe_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
sizeof(fe_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
@@
-531,14
+525,14
@@
static PyGetSetDef field_pygetset[] = {
static PyMethodDef field_pymethods[] = {
#define METHNAME(name) fmeth_##name
METH (_adopt, "F._adopt(X) -> FE")
static PyMethodDef field_pymethods[] = {
#define METHNAME(name) fmeth_##name
METH (_adopt, "F._adopt(X) -> FE")
- KWMETH(rand, "F.rand(
rng = rand
) -> FE, uniformly distributed")
+ KWMETH(rand, "F.rand(
[rng = rand]
) -> FE, uniformly distributed")
#undef METHNAME
{ 0 }
};
static PyTypeObject field_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
#undef METHNAME
{ 0 }
};
static PyTypeObject field_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "
catacomb.Field",
/* @tp_name@ */
+ "
Field",
/* @tp_name@ */
sizeof(field_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
sizeof(field_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
@@
-616,7
+610,7
@@
static PyGetSetDef primefield_pygetset[] = {
static PyTypeObject primefield_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
static PyTypeObject primefield_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "
catacomb.PrimeField",
/* @tp_name@ */
+ "
PrimeField",
/* @tp_name@ */
sizeof(field_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
sizeof(field_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
@@
-683,7
+677,7
@@
end:
static PyTypeObject niceprimefield_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
static PyTypeObject niceprimefield_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "
catacomb.NicePrimeField",
/* @tp_name@ */
+ "
NicePrimeField",
/* @tp_name@ */
sizeof(field_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
sizeof(field_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
@@
-743,7
+737,7
@@
static PyGetSetDef binfield_pygetset[] = {
static PyTypeObject binfield_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
static PyTypeObject binfield_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "
catacomb.BinField",
/* @tp_name@ */
+ "
BinField",
/* @tp_name@ */
sizeof(field_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
sizeof(field_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
@@
-807,8
+801,11
@@
end:
return (0);
}
return (0);
}
+static PyObject *bfget_p(PyObject *me, void *hunoz)
+ { return (gf_pywrap(MP_COPY(FIELD_F(me)->m))); }
+
static PyGetSetDef binpolyfield_pygetset[] = {
static PyGetSetDef binpolyfield_pygetset[] = {
-#define GETSETNAME(op, name)
p
f##op##_##name
+#define GETSETNAME(op, name)
b
f##op##_##name
GET (p, "F.p -> field polynomial")
#undef GETSETNAME
{ 0 }
GET (p, "F.p -> field polynomial")
#undef GETSETNAME
{ 0 }
@@
-816,7
+813,7
@@
static PyGetSetDef binpolyfield_pygetset[] = {
static PyTypeObject binpolyfield_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
static PyTypeObject binpolyfield_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "
catacomb.BinPolyField",
/* @tp_name@ */
+ "
BinPolyField",
/* @tp_name@ */
sizeof(field_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
sizeof(field_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
@@
-887,7
+884,7
@@
static PyObject *bnfget_beta(PyObject *me, void *hunoz)
}
static PyGetSetDef binnormfield_pygetset[] = {
}
static PyGetSetDef binnormfield_pygetset[] = {
-#define GETSETNAME(op, name)
p
f##op##_##name
+#define GETSETNAME(op, name)
b
f##op##_##name
GET (p, "F.p -> field polynomial")
#undef GETSETNAME
#define GETSETNAME(op, name) bnf##op##_##name
GET (p, "F.p -> field polynomial")
#undef GETSETNAME
#define GETSETNAME(op, name) bnf##op##_##name
@@
-898,7
+895,7
@@
static PyGetSetDef binnormfield_pygetset[] = {
static PyTypeObject binnormfield_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
static PyTypeObject binnormfield_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "
catacomb.BinNormField",
/* @tp_name@ */
+ "
BinNormField",
/* @tp_name@ */
sizeof(field_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
sizeof(field_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
@@
-958,7
+955,7
@@
static PyObject *meth__Field_parse(PyObject *me, PyObject *arg)
qd.p = p;
qd.e = 0;
if ((f = field_parse(&qd)) == 0)
qd.p = p;
qd.e = 0;
if ((f = field_parse(&qd)) == 0)
-
SYN
ERR(qd.e);
+
VAL
ERR(qd.e);
rc = Py_BuildValue("(Ns)", field_pywrap(f), qd.p);
end:
return (rc);
rc = Py_BuildValue("(Ns)", field_pywrap(f), qd.p);
end:
return (rc);