version 1.4, 2000/08/21 08:31:20 |
version 1.7, 2000/12/08 02:39:05 |
|
|
* shall be made on your publication or presentation in any form of the |
* shall be made on your publication or presentation in any form of the |
* results obtained by use of the SOFTWARE. |
* results obtained by use of the SOFTWARE. |
* (4) In the event that you modify the SOFTWARE, you shall notify FLL by |
* (4) In the event that you modify the SOFTWARE, you shall notify FLL by |
* e-mail at risa-admin@flab.fujitsu.co.jp of the detailed specification |
* e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification |
* for such modification or the source code of the modified part of the |
* for such modification or the source code of the modified part of the |
* SOFTWARE. |
* SOFTWARE. |
* |
* |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/int.c,v 1.3 2000/02/07 05:21:32 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/int.c,v 1.6 2000/12/05 01:24:50 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
MKNODE(n1,r,0); MKNODE(n0,q,n1); MKLIST(*rp,n0); |
MKNODE(n1,r,0); MKNODE(n0,q,n1); MKLIST(*rp,n0); |
} |
} |
|
|
|
/* |
|
* gcd = GCD(a,b), ca = a/g, cb = b/g |
|
*/ |
|
|
|
void igcd_cofactor(a,b,gcd,ca,cb) |
|
Q a,b; |
|
Q *gcd,*ca,*cb; |
|
{ |
|
N gn,tn; |
|
|
|
if ( !a ) { |
|
if ( !b ) |
|
error("igcd_cofactor : invalid input"); |
|
else { |
|
*ca = 0; |
|
*cb = ONE; |
|
*gcd = b; |
|
} |
|
} else if ( !b ) { |
|
*ca = ONE; |
|
*cb = 0; |
|
*gcd = a; |
|
} else { |
|
gcdn(NM(a),NM(b),&gn); NTOQ(gn,1,*gcd); |
|
divsn(NM(a),gn,&tn); NTOQ(tn,SGN(a),*ca); |
|
divsn(NM(b),gn,&tn); NTOQ(tn,SGN(b),*cb); |
|
} |
|
} |
|
|
void igcdv(a,rp) |
void igcdv(a,rp) |
VECT a; |
VECT a; |
Q *rp; |
Q *rp; |
|
|
UTOQ(r,*rp); |
UTOQ(r,*rp); |
} |
} |
|
|
#if defined(VISUAL) || defined(THINK_C) |
#if defined(VISUAL) |
void srandom(unsigned int); |
void srandom(unsigned int); |
|
|
static unsigned int R_Next; |
static unsigned int R_Next; |