version 1.3, 2000/02/07 05:21:32 |
version 1.12, 2015/08/06 10:01:52 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/builtin/int.c,v 1.2 2000/01/11 06:43:35 noro Exp $ */ |
/* |
|
* Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED |
|
* All rights reserved. |
|
* |
|
* FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited, |
|
* non-exclusive and royalty-free license to use, copy, modify and |
|
* redistribute, solely for non-commercial and non-profit purposes, the |
|
* computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and |
|
* conditions of this Agreement. For the avoidance of doubt, you acquire |
|
* only a limited right to use the SOFTWARE hereunder, and FLL or any |
|
* third party developer retains all rights, including but not limited to |
|
* copyrights, in and to the SOFTWARE. |
|
* |
|
* (1) FLL does not grant you a license in any way for commercial |
|
* purposes. You may use the SOFTWARE only for non-commercial and |
|
* non-profit purposes only, such as academic, research and internal |
|
* business use. |
|
* (2) The SOFTWARE is protected by the Copyright Law of Japan and |
|
* international copyright treaties. If you make copies of the SOFTWARE, |
|
* with or without modification, as permitted hereunder, you shall affix |
|
* to all such copies of the SOFTWARE the above copyright notice. |
|
* (3) An explicit reference to this SOFTWARE and its copyright owner |
|
* shall be made on your publication or presentation in any form of the |
|
* results obtained by use of the SOFTWARE. |
|
* (4) In the event that you modify the SOFTWARE, you shall notify FLL by |
|
* 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 |
|
* SOFTWARE. |
|
* |
|
* THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL |
|
* MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND |
|
* EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS |
|
* FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES' |
|
* RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY |
|
* MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY. |
|
* UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT, |
|
* OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY |
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL |
|
* DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES |
|
* ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES |
|
* FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY |
|
* DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF |
|
* SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART |
|
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
|
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
|
* |
|
* $OpenXM: OpenXM_contrib2/asir2000/builtin/int.c,v 1.11 2013/09/26 08:55:11 noro Exp $ |
|
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
#include "base.h" |
#include "base.h" |
Line 9 void Pup2_init_eg(), Pup2_show_eg(); |
|
Line 57 void Pup2_init_eg(), Pup2_show_eg(); |
|
void Piqr(), Pprime(), Plprime(), Pinttorat(); |
void Piqr(), Pprime(), Plprime(), Pinttorat(); |
void Piand(), Pior(), Pixor(), Pishift(); |
void Piand(), Pior(), Pixor(), Pishift(); |
void Pisqrt(); |
void Pisqrt(); |
void iand(), ior(), ixor(); |
|
void isqrt(); |
|
void Plrandom(); |
void Plrandom(); |
void Pset_upkara(), Pset_uptkara(), Pset_up2kara(), Pset_upfft(); |
void Pset_upkara(), Pset_uptkara(), Pset_up2kara(), Pset_upfft(); |
void Pmt_save(), Pmt_load(); |
void Pmt_save(), Pmt_load(); |
Line 18 void Psmall_jacobi(); |
|
Line 64 void Psmall_jacobi(); |
|
void Pdp_set_mpi(); |
void Pdp_set_mpi(); |
void Pntoint32(),Pint32ton(); |
void Pntoint32(),Pint32ton(); |
|
|
#ifdef HMEXT |
|
void Pigcdbin(), Pigcdbmod(), PigcdEuc(), Pigcdacc(), Pigcdcntl(); |
void Pigcdbin(), Pigcdbmod(), PigcdEuc(), Pigcdacc(), Pigcdcntl(); |
|
|
void Pihex(); |
void Pihex(); |
void Pimaxrsh(), Pilen(); |
void Pimaxrsh(), Pilen(); |
void Ptype_t_NB(); |
void Ptype_t_NB(); |
|
|
#endif /* HMEXT */ |
|
|
|
struct ftab int_tab[] = { |
struct ftab int_tab[] = { |
{"dp_set_mpi",Pdp_set_mpi,-1}, |
{"dp_set_mpi",Pdp_set_mpi,-1}, |
{"isqrt",Pisqrt,1}, |
{"isqrt",Pisqrt,1}, |
Line 57 struct ftab int_tab[] = { |
|
Line 100 struct ftab int_tab[] = { |
|
{"ixor",Pixor,2}, |
{"ixor",Pixor,2}, |
{"ishift",Pishift,2}, |
{"ishift",Pishift,2}, |
{"small_jacobi",Psmall_jacobi,2}, |
{"small_jacobi",Psmall_jacobi,2}, |
#ifdef HMEXT |
|
{"igcdbin",Pigcdbin,2}, /* HM@CCUT extension */ |
{"igcdbin",Pigcdbin,2}, /* HM@CCUT extension */ |
{"igcdbmod",Pigcdbmod,2}, /* HM@CCUT extension */ |
{"igcdbmod",Pigcdbmod,2}, /* HM@CCUT extension */ |
{"igcdeuc",PigcdEuc,2}, /* HM@CCUT extension */ |
{"igcdeuc",PigcdEuc,2}, /* HM@CCUT extension */ |
{"igcdacc",Pigcdacc,2}, /* HM@CCUT extension */ |
{"igcdacc",Pigcdacc,2}, /* HM@CCUT extension */ |
{"igcdcntl",Pigcdcntl,-1}, /* HM@CCUT extension */ |
{"igcdcntl",Pigcdcntl,-1}, /* HM@CCUT extension */ |
{"ihex",Pihex,1}, /* HM@CCUT extension */ |
|
{"imaxrsh",Pimaxrsh,1}, /* HM@CCUT extension */ |
|
{"ilen",Pilen,1}, /* HM@CCUT extension */ |
|
#endif /* HMEXT */ |
|
{"mt_save",Pmt_save,1}, |
{"mt_save",Pmt_save,1}, |
{"mt_load",Pmt_load,1}, |
{"mt_load",Pmt_load,1}, |
{"ntoint32",Pntoint32,1}, |
{"ntoint32",Pntoint32,1}, |
Line 79 static unsigned int gcd_small(unsigned int,unsigned in |
|
Line 119 static unsigned int gcd_small(unsigned int,unsigned in |
|
int TypeT_NB_check(unsigned int, unsigned int); |
int TypeT_NB_check(unsigned int, unsigned int); |
int mpi_mag; |
int mpi_mag; |
|
|
void Pntoint32(arg,rp) |
void Pntoint32(NODE arg,USINT *rp) |
NODE arg; |
|
USINT *rp; |
|
{ |
{ |
Q q; |
Q q; |
unsigned int t; |
unsigned int t; |
|
|
error("ntoint32 : invalid argument"); |
error("ntoint32 : invalid argument"); |
t = BD(NM(q))[0]; |
t = BD(NM(q))[0]; |
if ( SGN(q) < 0 ) |
if ( SGN(q) < 0 ) |
t = -t; |
t = -(int)t; |
MKUSINT(*rp,t); |
MKUSINT(*rp,t); |
} |
} |
|
|
void Pint32ton(arg,rp) |
void Pint32ton(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
int t; |
int t; |
|
|
|
|
STOQ(t,*rp); |
STOQ(t,*rp); |
} |
} |
|
|
void Pdp_set_mpi(arg,rp) |
void Pdp_set_mpi(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
if ( arg ) { |
if ( arg ) { |
asir_assert(ARG0(arg),O_N,"dp_set_mpi"); |
asir_assert(ARG0(arg),O_N,"dp_set_mpi"); |
|
|
STOQ(mpi_mag,*rp); |
STOQ(mpi_mag,*rp); |
} |
} |
|
|
void Psmall_jacobi(arg,rp) |
void Psmall_jacobi(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
Q a,m; |
Q a,m; |
int a0,m0,s; |
int a0,m0,s; |
|
|
} |
} |
} |
} |
|
|
int small_jacobi(a,m) |
int small_jacobi(int a,int m) |
int a,m; |
|
{ |
{ |
int m4,m8,a4,j1,i,s; |
int m4,m8,a4,j1,i,s; |
|
|
|
|
} |
} |
} |
} |
|
|
void Ptype_t_NB(arg,rp) |
void Ptype_t_NB(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
if ( TypeT_NB_check(QTOS((Q)ARG0(arg)),QTOS((Q)ARG1(arg)))) |
if ( TypeT_NB_check(QTOS((Q)ARG0(arg)),QTOS((Q)ARG1(arg)))) |
*rp = ONE; |
*rp = ONE; |
Line 245 static unsigned int gcd_small(unsigned int a,unsigned |
|
Line 274 static unsigned int gcd_small(unsigned int a,unsigned |
|
} |
} |
} |
} |
|
|
void Pmt_save(arg,rp) |
void Pmt_save(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
int ret; |
int ret; |
|
|
|
|
STOQ(ret,*rp); |
STOQ(ret,*rp); |
} |
} |
|
|
void Pmt_load(arg,rp) |
void Pmt_load(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
int ret; |
int ret; |
|
|
|
|
STOQ(ret,*rp); |
STOQ(ret,*rp); |
} |
} |
|
|
void Pisqrt(arg,rp) |
void Pisqrt(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
Q a; |
Q a; |
N r; |
N r; |
|
|
} |
} |
} |
} |
|
|
void Pidiv(arg,rp) |
void Pidiv(NODE arg,Obj *rp) |
NODE arg; |
|
Obj *rp; |
|
{ |
{ |
N q,r; |
N q,r; |
Q a; |
Q a; |
|
|
} |
} |
} |
} |
|
|
void Pirem(arg,rp) |
void Pirem(NODE arg,Obj *rp) |
NODE arg; |
|
Obj *rp; |
|
{ |
{ |
N q,r; |
N q,r; |
Q a; |
Q a; |
|
|
} |
} |
} |
} |
|
|
void Piqr(arg,rp) |
void Piqr(NODE arg,LIST *rp) |
NODE arg; |
|
LIST *rp; |
|
{ |
{ |
N q,r; |
N q,r; |
Q a,b; |
Q a,b; |
|
|
MKNODE(node2,b,0); MKNODE(node1,a,node2); MKLIST(*rp,node1); |
MKNODE(node2,b,0); MKNODE(node1,a,node2); MKLIST(*rp,node1); |
} |
} |
|
|
void Pinttorat(arg,rp) |
void Pinttorat(NODE arg,LIST *rp) |
NODE arg; |
|
LIST *rp; |
|
{ |
{ |
Q cq,qq,t,u1,v1,r1,nm; |
Q cq,qq,t,u1,v1,r1,nm; |
N m,b,q,r,c,u2,v2,r2; |
N m,b,q,r,c,u2,v2,r2; |
|
|
} |
} |
} |
} |
|
|
void Pigcd(arg,rp) |
void Pigcd(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
N g; |
N g; |
Q n1,n2,a; |
Q n1,n2,a; |
|
|
} |
} |
} |
} |
|
|
int comp_n(a,b) |
int comp_n(N *a,N *b) |
N *a,*b; |
|
{ |
{ |
return cmpn(*a,*b); |
return cmpn(*a,*b); |
} |
} |
|
|
void iqrv(a,dvr,rp) |
void iqrv(VECT a,Q dvr,LIST *rp) |
VECT a; |
|
Q dvr; |
|
LIST *rp; |
|
{ |
{ |
int i,n; |
int i,n; |
VECT q,r; |
VECT q,r; |
|
|
MKNODE(n1,r,0); MKNODE(n0,q,n1); MKLIST(*rp,n0); |
MKNODE(n1,r,0); MKNODE(n0,q,n1); MKLIST(*rp,n0); |
} |
} |
|
|
void igcdv(a,rp) |
/* |
VECT a; |
* gcd = GCD(a,b), ca = a/g, cb = b/g |
Q *rp; |
*/ |
|
|
|
void igcd_cofactor(Q a,Q b,Q *gcd,Q *ca,Q *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(VECT a,Q *rp) |
|
{ |
int i,j,n,nz; |
int i,j,n,nz; |
N g,gt,q,r; |
N g,gt,q,r; |
N *c; |
N *c; |
|
|
NTOQ(*c,1,*rp); return; |
NTOQ(*c,1,*rp); return; |
} |
} |
gcdn(c[0],c[1],&g); |
gcdn(c[0],c[1],&g); |
|
#if 0 |
for ( i = 2; i < n; i++ ) { |
for ( i = 2; i < n; i++ ) { |
divn(c[i],g,&q,&r); |
divn(c[i],g,&q,&r); |
gcdn(g,r,>); |
gcdn(g,r,>); |
|
|
} else |
} else |
g = gt; |
g = gt; |
} |
} |
|
#else |
|
for ( i = 2; i < n; i++ ) { |
|
gcdn(g,c[i],>); g = gt; |
|
} |
|
#endif |
NTOQ(g,1,*rp); |
NTOQ(g,1,*rp); |
} |
} |
|
|
void igcdv_estimate(a,rp) |
void igcdv_estimate(VECT a,Q *rp) |
VECT a; |
|
Q *rp; |
|
{ |
{ |
int n,i,m; |
int n,i,m; |
N s,t,u,g; |
N s,t,u,g; |
|
|
gcdn(s,t,&g); NTOQ(g,1,*rp); |
gcdn(s,t,&g); NTOQ(g,1,*rp); |
} |
} |
|
|
void Pilcm(arg,rp) |
void Pilcm(NODE arg,Obj *rp) |
NODE arg; |
|
Obj *rp; |
|
{ |
{ |
N g,q,r,l; |
N g,q,r,l; |
Q n1,n2,a; |
Q n1,n2,a; |
|
|
} |
} |
} |
} |
|
|
void Piand(arg,rp) |
void Piand(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
N g; |
N g; |
Q n1,n2,a; |
Q n1,n2,a; |
|
|
} |
} |
} |
} |
|
|
void Pior(arg,rp) |
void Pior(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
N g; |
N g; |
Q n1,n2,a; |
Q n1,n2,a; |
|
|
} |
} |
} |
} |
|
|
void Pixor(arg,rp) |
void Pixor(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
N g; |
N g; |
Q n1,n2,a; |
Q n1,n2,a; |
|
|
} |
} |
} |
} |
|
|
void Pishift(arg,rp) |
void Pishift(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
N g; |
N g; |
Q n1,s,a; |
Q n1,s,a; |
|
|
} |
} |
} |
} |
|
|
void isqrt(a,r) |
void isqrt(N a,N *r) |
N a,*r; |
|
{ |
{ |
int k; |
int k; |
N x,t,x2,xh,quo,rem; |
N x,t,x2,xh,quo,rem; |
|
|
} |
} |
} |
} |
|
|
void iand(n1,n2,r) |
void iand(N n1,N n2,N *r) |
N n1,n2,*r; |
|
{ |
{ |
int d1,d2,d,i; |
int d1,d2,d,i; |
N nr; |
N nr; |
|
|
} |
} |
} |
} |
|
|
void ior(n1,n2,r) |
void ior(N n1,N n2,N *r) |
N n1,n2,*r; |
|
{ |
{ |
int d1,d2,i; |
int d1,d2,i; |
N nr; |
N nr; |
|
|
} |
} |
} |
} |
|
|
void ixor(n1,n2,r) |
void ixor(N n1,N n2,N *r) |
N n1,n2,*r; |
|
{ |
{ |
int d1,d2,i; |
int d1,d2,i; |
N nr; |
N nr; |
|
|
} |
} |
} |
} |
|
|
void Pup2_init_eg(rp) |
void Pup2_init_eg(Obj *rp) |
Obj *rp; |
|
{ |
{ |
up2_init_eg(); |
up2_init_eg(); |
*rp = 0; |
*rp = 0; |
} |
} |
|
|
void Pup2_show_eg(rp) |
void Pup2_show_eg(Obj *rp) |
Obj *rp; |
|
{ |
{ |
up2_show_eg(); |
up2_show_eg(); |
*rp = 0; |
*rp = 0; |
} |
} |
|
|
void Pgf2nton(arg,rp) |
void Pgf2nton(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
if ( !ARG0(arg) ) |
if ( !ARG0(arg) ) |
*rp = 0; |
*rp = 0; |
|
|
up2ton(((GF2N)ARG0(arg))->body,rp); |
up2ton(((GF2N)ARG0(arg))->body,rp); |
} |
} |
|
|
void Pntogf2n(arg,rp) |
void Pntogf2n(NODE arg,GF2N *rp) |
NODE arg; |
|
GF2N *rp; |
|
{ |
{ |
UP2 t; |
UP2 t; |
|
|
|
|
MKGF2N(t,*rp); |
MKGF2N(t,*rp); |
} |
} |
|
|
void Pup2_inv(arg,rp) |
void Pup2_inv(NODE arg,P *rp) |
NODE arg; |
|
P *rp; |
|
{ |
{ |
UP2 a,b,t; |
UP2 a,b,t; |
|
|
|
|
up2top(t,rp); |
up2top(t,rp); |
} |
} |
|
|
void Pinv(arg,rp) |
void Pinv(NODE arg,Num *rp) |
NODE arg; |
|
Num *rp; |
|
{ |
{ |
Num n; |
Num n; |
Q mod; |
Q mod; |
|
|
} |
} |
} |
} |
|
|
void Pfac(arg,rp) |
void Pfac(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
asir_assert(ARG0(arg),O_N,"fac"); |
asir_assert(ARG0(arg),O_N,"fac"); |
factorial(QTOS((Q)ARG0(arg)),rp); |
factorial(QTOS((Q)ARG0(arg)),rp); |
} |
} |
|
|
void Plrandom(arg,rp) |
void Plrandom(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
N r; |
N r; |
|
|
|
|
NTOQ(r,1,*rp); |
NTOQ(r,1,*rp); |
} |
} |
|
|
void Prandom(arg,rp) |
void Prandom(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
unsigned int r; |
unsigned int r; |
|
|
|
|
UTOQ(r,*rp); |
UTOQ(r,*rp); |
} |
} |
|
|
#if defined(VISUAL) || defined(THINK_C) |
#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) |
void srandom(unsigned int); |
void srandom(unsigned int); |
|
|
static unsigned int R_Next; |
static unsigned int R_Next; |
Line 831 unsigned int random() { |
|
Line 839 unsigned int random() { |
|
return R_Next = (R_Next * 1103515245 + 12345); |
return R_Next = (R_Next * 1103515245 + 12345); |
} |
} |
|
|
void srandom(s) |
void srandom(unsigned int s) |
unsigned int s; |
|
{ |
{ |
if ( s ) |
if ( s ) |
R_Next = s; |
R_Next = s; |
|
|
} |
} |
#endif |
#endif |
|
|
void Pprime(arg,rp) |
void Pprime(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
int i; |
int i; |
|
|
|
|
STOQ(sprime[i],*rp); |
STOQ(sprime[i],*rp); |
} |
} |
|
|
void Plprime(arg,rp) |
void Plprime(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
int i; |
int i,p; |
|
|
asir_assert(ARG0(arg),O_N,"lprime"); |
asir_assert(ARG0(arg),O_N,"lprime"); |
i = QTOS((Q)ARG0(arg)); |
i = QTOS((Q)ARG0(arg)); |
if ( i < 0 || i >= 1000 ) |
if ( i < 0 ) |
*rp = 0; |
*rp = 0; |
else |
else |
STOQ(lprime[i],*rp); |
p = get_lprime(i); |
|
STOQ(p,*rp); |
} |
} |
|
|
extern int up_kara_mag, up_tkara_mag, up_fft_mag; |
extern int up_kara_mag, up_tkara_mag, up_fft_mag; |
|
|
void Pset_upfft(arg,rp) |
void Pset_upfft(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
if ( arg ) { |
if ( arg ) { |
asir_assert(ARG0(arg),O_N,"set_upfft"); |
asir_assert(ARG0(arg),O_N,"set_upfft"); |
|
|
STOQ(up_fft_mag,*rp); |
STOQ(up_fft_mag,*rp); |
} |
} |
|
|
void Pset_upkara(arg,rp) |
void Pset_upkara(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
if ( arg ) { |
if ( arg ) { |
asir_assert(ARG0(arg),O_N,"set_upkara"); |
asir_assert(ARG0(arg),O_N,"set_upkara"); |
|
|
STOQ(up_kara_mag,*rp); |
STOQ(up_kara_mag,*rp); |
} |
} |
|
|
void Pset_uptkara(arg,rp) |
void Pset_uptkara(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
if ( arg ) { |
if ( arg ) { |
asir_assert(ARG0(arg),O_N,"set_uptkara"); |
asir_assert(ARG0(arg),O_N,"set_uptkara"); |
|
|
|
|
extern int up2_kara_mag; |
extern int up2_kara_mag; |
|
|
void Pset_up2kara(arg,rp) |
void Pset_up2kara(NODE arg,Q *rp) |
NODE arg; |
|
Q *rp; |
|
{ |
{ |
if ( arg ) { |
if ( arg ) { |
asir_assert(ARG0(arg),O_N,"set_up2kara"); |
asir_assert(ARG0(arg),O_N,"set_up2kara"); |
|
|
STOQ(up2_kara_mag,*rp); |
STOQ(up2_kara_mag,*rp); |
} |
} |
|
|
#ifdef HMEXT |
void Pigcdbin(NODE arg,Obj *rp) |
void Pigcdbin(arg,rp) |
|
NODE arg; |
|
Obj *rp; |
|
{ |
{ |
N g; |
N g; |
Q n1,n2,a; |
Q n1,n2,a; |
|
|
} |
} |
} |
} |
|
|
void Pigcdbmod(arg,rp) |
void Pigcdbmod(NODE arg,Obj *rp) |
NODE arg; |
|
Obj *rp; |
|
{ |
{ |
N g; |
N g; |
Q n1,n2,a; |
Q n1,n2,a; |
|
|
} |
} |
} |
} |
|
|
void Pigcdacc(arg,rp) |
void Pigcdacc(NODE arg,Obj *rp) |
NODE arg; |
|
Obj *rp; |
|
{ |
{ |
N g; |
N g; |
Q n1,n2,a; |
Q n1,n2,a; |
|
|
} |
} |
} |
} |
|
|
void PigcdEuc(arg,rp) |
void PigcdEuc(NODE arg,Obj *rp) |
NODE arg; |
|
Obj *rp; |
|
{ |
{ |
N g; |
N g; |
Q n1,n2,a; |
Q n1,n2,a; |
Line 1017 extern int igcdacc_thre; |
|
Line 1004 extern int igcdacc_thre; |
|
* > igcdacc_thre, "bmod" reduction is done. |
* > igcdacc_thre, "bmod" reduction is done. |
*/ |
*/ |
|
|
void Pigcdcntl(arg,rp) |
void Pigcdcntl(NODE arg,Obj *rp) |
NODE arg; |
|
Obj *rp; |
|
{ |
{ |
Obj p; |
Obj p; |
Q a; |
Q a; |
|
|
*rp = (Obj)a; |
*rp = (Obj)a; |
return; |
return; |
} |
} |
|
|
|
|
void Pimaxrsh(arg,rp) |
|
NODE arg; |
|
LIST *rp; |
|
{ |
|
N n1, n2; |
|
Q q; |
|
NODE node1, node2; |
|
int bits; |
|
N maxrshn(); |
|
|
|
q = (Q)ARG0(arg); |
|
asir_assert(q,O_N,"imaxrsh"); |
|
if ( !q ) n1 = n2 = 0; |
|
else { |
|
n1 = maxrshn( NM(q), &bits ); |
|
STON( bits, n2 ); |
|
} |
|
NTOQ( n2, 1, q ); |
|
MKNODE( node2, q, 0 ); |
|
NTOQ( n1, 1, q ); |
|
MKNODE( node1, q, node2 ); |
|
MKLIST( *rp, node1 ); |
|
} |
|
void Pilen(arg,rp) |
|
NODE arg; |
|
Obj *rp; |
|
{ |
|
Q q; |
|
int l; |
|
|
|
q = (Q)ARG0(arg); |
|
asir_assert(q,O_N,"ilenh"); |
|
if ( !q ) l = 0; |
|
else l = PL(NM(q)); |
|
STOQ(l,q); |
|
*rp = (Obj)q; |
|
} |
|
|
|
void Pihex(arg,rp) |
|
NODE arg; |
|
Obj *rp; |
|
{ |
|
Q n1; |
|
|
|
n1 = (Q)ARG0(arg); |
|
asir_assert(n1,O_N,"ihex"); |
|
if ( n1 ) { |
|
int i, l = PL(NM(n1)), *p = BD(NM(n1)); |
|
|
|
for ( i = 0; i < l; i++ ) printf( " 0x%08x", p[i] ); |
|
printf( "\n" ); |
|
} else printf( " 0x%08x\n", 0 ); |
|
*rp = (Obj)n1; |
|
} |
|
#endif /* HMEXT */ |
|