5 # Multiprecision interface
7 # (c) 2000 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.
29 MODULE = Catacomb PACKAGE = Catacomb::GF PREFIX = gf_
32 new(me, sv = 0, radix = 0)
37 RETVAL = sv ? mp_fromsv(sv, "sv", "Catacomb::GF", radix, 1) : MP_ZERO;
58 RETVAL = mp_loadb(MP_NEW, p, len);
71 RETVAL = mp_loadl(MP_NEW, p, len);
80 XSINTERFACE_FUNC_SETMP
91 sz = (i < 0) ? mp_octets(m) : i;
92 RETVAL = NEWSV(0, sz ? sz : 1);
93 mp_storeb(m, SvPVX(RETVAL), sz);
94 SvCUR_set(RETVAL, sz);
106 sz = (i < 0) ? mp_octets(m) : i;
107 RETVAL = NEWSV(0, sz ? sz : 1);
108 mp_storel(m, SvPVX(RETVAL), sz);
109 SvCUR_set(RETVAL, sz);
115 tostring(m, radix = 16)
119 RETVAL = NEWSV(0, 0);
120 mp_writesv(m, RETVAL, radix);
128 RETVAL = newSViv(mp_toiv(m));
146 XSINTERFACE_FUNC_SETGF
158 XSINTERFACE_FUNC_SETGF
170 XSINTERFACE_FUNC_SETMP
179 RETVAL = mp_eq(a, b);
192 mp *q = MP_NEW, *r = MP_NEW;
194 if (MP_EQ(b, MP_ZERO))
195 croak("Divide by zero in Catacomb::GF::div");
200 mp_div(&q, &r, a, b);
208 mp_div(&q, &r, a, b);
219 gf *g = MP_NEW, *x = MP_NEW, *y = MP_NEW;
223 gf_gcd(&g, &x, &y, a, b);
232 gf_gcd(&g, 0, 0, a, b);
242 RETVAL = CREATE(GF_Reduce);
243 gfreduce_create(RETVAL, x);
247 MODULE = Catacomb PACKAGE = Catacomb::GF::Reduce PREFIX = gfreduce_
253 RETVAL = CREATE(GF_Reduce);
254 gfreduce_create(RETVAL, x);
271 RETVAL = gfreduce_do(r, MP_NEW, x);
280 if ((RETVAL = gfreduce_sqrt(r, MP_NEW, x)) == 0)
291 gfreduce_halftrace(r, x)
302 if ((RETVAL = gfreduce_quadsolve(r, MP_NEW, x)) == 0)
311 RETVAL = MP_COPY(r->p);
316 gfreduce_exp(r, x, y)
323 #----- That's all, folks ----------------------------------------------------