7 # (c) 2001 Straylight/Edgeware
10 #----- Licensing notice -----------------------------------------------------
12 # This file is part of the Perl interface to Catacomb.
14 # Catacomb/Perl is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # Catacomb/Perl is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with Catacomb/Perl; if not, write to the Free Software Foundation,
26 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 MODULE = Catacomb PACKAGE = Catacomb::Field PREFIX = field_
38 field_niceprime(me, p)
52 field_binnorm(me, p, beta)
68 if ((RETVAL = field_parse(&qd)) == 0)
69 croak("bad field spec: %s", qd.e);
70 else if (!qd_eofp(&qd)) {
72 croak("junk at end of field spec");
88 RETVAL = (char *)F_NAME(f);
104 RETVAL = MP_COPY(f->zero);
112 RETVAL = MP_COPY(f->one);
120 RETVAL = MP_COPY(f->m);
128 RETVAL = MP_COPY(f->q);
149 _rand(f, r = &rand_global)
153 RETVAL = F_RAND(f, MP_NEW, r);
162 RETVAL = F_SAMEP(f, ff);
171 RETVAL = F_IN(f, MP_NEW, x);
180 RETVAL = F_OUT(f, MP_NEW, x);
189 RETVAL = F_ZEROP(f, x);
198 RETVAL = F_NEG(f, MP_NEW, x);
208 RETVAL = F_ADD(f, MP_NEW, x, y);
218 RETVAL = F_SUB(f, MP_NEW, x, y);
228 RETVAL = F_MUL(f, MP_NEW, x, y);
237 RETVAL = F_SQR(f, MP_NEW, x);
247 croak("division by zero");
248 RETVAL = F_INV(f, MP_NEW, x);
257 RETVAL = F_REDUCE(f, MP_NEW, x);
266 RETVAL = F_SQRT(f, MP_NEW, x);
275 if (F_TYPE(f) != FTY_BINARY)
276 croak("quadsolve only works on binary fields");
277 RETVAL = F_QUADSOLVE(f, MP_NEW, x);
286 if (F_TYPE(f) != FTY_PRIME)
287 croak("dbl only works on prime fields");
288 RETVAL = F_DBL(f, MP_NEW, x);
297 if (F_TYPE(f) != FTY_PRIME)
298 croak("tpl only works on prime fields");
299 RETVAL = F_TPL(f, MP_NEW, x);
308 if (F_TYPE(f) != FTY_PRIME)
309 croak("qdl only works on prime fields");
310 RETVAL = F_QDL(f, MP_NEW, x);
319 if (F_TYPE(f) != FTY_PRIME)
320 croak("hlv only works on prime fields");
321 RETVAL = F_HLV(f, MP_NEW, x);
329 RETVAL = info_field(f);