# ---?--- # # $Id$ # # Multiprecision interface # # (c) 2000 Straylight/Edgeware # #----- Licensing notice ----------------------------------------------------- # # This file is part of the Perl interface to Catacomb. # # Catacomb/Perl is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Catacomb/Perl is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Catacomb/Perl; if not, write to the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # MODULE = Catacomb PACKAGE = Catacomb::GF PREFIX = gf_ gf * new(me, sv = 0, radix = 0) SV *me SV *sv int radix CODE: RETVAL = sv ? mp_fromsv(sv, "sv", radix, 1) : MP_ZERO; OUTPUT: RETVAL gf * copy(x) gf *x CODE: RETVAL = MP_COPY(x); OUTPUT: RETVAL gf * loadb(me, sv) SV *me SV *sv PREINIT: char *p; STRLEN len; CODE: p = SvPV(sv, len); RETVAL = mp_loadb(MP_NEW, p, len); OUTPUT: RETVAL gf * loadl(me, sv) SV *me SV *sv PREINIT: char *p; STRLEN len; CODE: p = SvPV(sv, len); RETVAL = mp_loadl(MP_NEW, p, len); OUTPUT: RETVAL mp * gf_sqr(a) gf *a C_ARGS: MP_NEW, a INTERFACE_MACRO: XSINTERFACE_FUNC XSINTERFACE_FUNC_SETGF INTERFACE: sqr mp * binop(a, b) gf *a gf *b C_ARGS: MP_NEW, a, b INTERFACE_MACRO: XSINTERFACE_FUNC XSINTERFACE_FUNC_SETGF INTERFACE: add sub mul mp * logop(a, b) gf *a gf *b C_ARGS: MP_NEW, a, b INTERFACE_MACRO: XSINTERFACE_FUNC XSINTERFACE_FUNC_SETMP INTERFACE: and or xor nand nor mp * unop(a) gf *a C_ARGS: MP_NEW, a INTERFACE_MACRO: XSINTERFACE_FUNC XSINTERFACE_FUNC_SETMP INTERFACE: not gf * shiftop(a, n) gf *a int n C_ARGS: MP_NEW, a, n INTERFACE_MACRO: XSINTERFACE_FUNC XSINTERFACE_FUNC_SETMP INTERFACE: lsl lsr gf * flipbits(a, n) gf *a unsigned long n C_ARGS: MP_NEW, a, n INTERFACE_MACRO: XSINTERFACE_FUNC XSINTERFACE_FUNC_SETMP INTERFACE: setbit clearbit int gf_irreduciblep(a) gf *a void div(a, b) mp *a mp *b PREINIT: mp *q = MP_NEW, *r = MP_NEW; PPCODE: if (MP_EQ(b, MP_ZERO)) croak("Divide by zero in Catacomb::GF::div"); q = MP_NEW; switch (GIMME_V) { case G_ARRAY: r = MP_NEW; mp_div(&q, &r, a, b); EXTEND(SP, 2); PUSHs(RET_GF(q)); PUSHs(RET_GF(r)); break; case G_VOID: break; default: mp_div(&q, &r, a, b); EXTEND(SP, 1); PUSHs(RET_GF(q)); break; } void gcd(a, b) gf *a gf *b PREINIT: gf *g = MP_NEW, *x = MP_NEW, *y = MP_NEW; PPCODE: switch (GIMME_V) { case G_ARRAY: gf_gcd(&g, &x, &y, a, b); EXTEND(SP, 3); PUSHs(RET_GF(g)); PUSHs(RET_GF(x)); PUSHs(RET_GF(y)); break; case G_VOID: break; default: gf_gcd(&g, 0, 0, a, b); EXTEND(SP, 1); PUSHs(RET_GF(g)); break; } MODULE = Catacomb PACKAGE = Catacomb::GF::Reduce PREFIX = gfreduce_ GF_Reduce * new(me, x) gf *x CODE: RETVAL = CREATE(GF_Reduce); gfreduce_create(RETVAL, x); OUTPUT: RETVAL SV * DESTROY(r) GF_Reduce *r CODE: gfreduce_destroy(r); DESTROY(r); XSRETURN_UNDEF; gf * reduce(r, x) GF_Reduce *r gf *x CODE: RETVAL = gfreduce_do(r, MP_NEW, x); OUTPUT: RETVAL gf * sqrt(r, x) GF_Reduce *r gf *x CODE: if ((RETVAL = gfreduce_sqrt(r, MP_NEW, x)) == 0) XSRETURN_UNDEF; OUTPUT: RETVAL int gfreduce_trace(r, x) GF_Reduce *r gf *x gf * gfreduce_halftrace(r, x) GF_Reduce *r gf *x C_ARGS: r, MP_NEW, x gf * quadsolve(r, x) GF_Reduce *r gf *x CODE: if ((RETVAL = gfreduce_quadsolve(r, MP_NEW, x)) == 0) XSRETURN_UNDEF; OUTPUT: RETVAL gf * m(r) GF_Reduce *r CODE: RETVAL = MP_COPY(r->p); OUTPUT: RETVAL gf * gfreduce_exp(r, x, y) GF_Reduce *r gf *x gf *y C_ARGS: r, MP_NEW, x, y #----- That's all, folks ----------------------------------------------------