Go to the documentation of this file.
8 static char *
rcsid=
"@(#)$Id$";
18 extern int ffsl(
long int i);
50 else if (isint(
a)) {
if (x!=
a)
return(
NIL);}
52 else if (pisbignum(
a)) {
return(
NIL);}
55 else if (isratio(x)) {
71 if (fx!=fy)
return(
NIL);}
73 else if (pisbignum(x))
76 xv=bigvec(x); size=bigsize(x);
79 if (!isbignum(
a))
return(
NIL);
80 if (size != bigsize(
a))
return(
NIL);
82 for (i=0; i<size; i++)
if (xv[i]!=av[i])
return(
NIL);}
118 if (isint(right))
goto INTGT;
119 else if (isflt(right))
goto FLTGT;
120 else if (pisratio(right))
goto RATGT;
121 else if (pisbignum(right))
goto BIGGT;
129 else if (isflt(left)) { fright=
intval(right);
goto fltgt2;}
130 else if (isbignum(left)) {
132 right=left;
goto BIGGT; }
143 if (sign>=0)
return(
NIL);
146 else if (isflt(left)) {
150 else if (pisbignum(left)) {
152 if (comparison<=0)
return(
NIL);
155 else if (isratio(left))
goto RATGT; }
161 if (fleft<=fright)
return(
NIL);
182 if (isint(right))
goto INTLT;
183 else if (isflt(right))
goto FLTLT;
184 else if (pisratio(right))
goto RATLT;
185 else if (pisbignum(right))
goto BIGLT;
193 else if (isflt(left)) { fright=
intval(right);
goto FLTLT2;}
194 else if (isbignum(left)) {
196 right=left;
goto BIGLT; }
207 if (sign<0)
return(
NIL);
210 else if (isflt(left)) {
214 else if (pisbignum(left)) {
216 if (comparison>=0)
return(
NIL);
219 else if (isratio(left))
goto RATLT; }
225 if (fleft>=fright)
return(
NIL);
246 if (isint(right))
goto INTGE;
247 else if (isflt(right))
goto FLTGE;
248 else if (pisratio(right))
goto RATGE;
249 else if (pisbignum(right))
goto BIGGE;
257 else if (isflt(left)) { fright=
intval(right);
goto FLTGE2;}
258 else if (isbignum(left)) {
260 right=left;
goto BIGGE; }
271 if (sign>0)
return(
NIL);
274 else if (isflt(left)) {
278 else if (pisbignum(left)) {
280 if (comparison<0)
return(
NIL);
283 else if (isratio(left))
goto RATGE; }
289 if (fleft<fright)
return(
NIL);
310 if (isint(right))
goto INTLE;
311 else if (isflt(right))
goto FLTLE;
312 else if (pisratio(right))
goto RATLE;
313 else if (pisbignum(right))
goto BIGLE;
321 else if (isflt(left)) { fright=
intval(right);
goto FLTLE2;}
322 else if (isbignum(left)) {
324 right=left;
goto BIGLE; }
335 if (sign<0)
return(
NIL);
338 else if (isflt(left)) {
342 else if (pisbignum(left)) {
344 if (comparison > 0)
return(
NIL);
347 else if (isratio(left))
goto RATLE; }
353 if (fleft > fright)
return(
NIL);
365 if (isflt(argv[0]) || isflt(argv[1])) {
372 x=bigintval(argv[0]); y=bigintval(argv[1]);
373 return(mkbigint(x % y));}}
389 else if (isbignum(
a)) {
409 else if (isbignum(
a)) {
419 register eusinteger_t x_num, x_den, y_num, y_den, z_num, z_den, d1,d2,t;
421 x_num =
intval(x->c.ratio.numerator);
422 x_den =
intval(x->c.ratio.denominator);
423 y_num =
intval(y->c.ratio.numerator);
424 y_den =
intval(y->c.ratio.denominator);
428 z_num = x_num * y_den + x_den * y_num;
429 z_den = x_den * y_den;
432 t = x_num * (y_den / d1) + y_num * (x_den / d1);
436 z_den = (x_den / d1) * (y_den / d2);
443 register eusinteger_t x_num,x_den,y_num,y_den,z_num,z_den,d1,d2,t;
445 x_num =
intval(x->c.ratio.numerator);
446 x_den =
intval(x->c.ratio.denominator);
447 y_num =
intval(y->c.ratio.numerator);
448 y_den =
intval(y->c.ratio.denominator);
449 d1 =
gcd(x_den,y_den);
451 z_num = x_num * y_den - x_den * y_num;
452 z_den = x_den * y_den;
455 t = x_num * (y_den / d1) - y_num * (x_den / d1);
458 z_den = (x_den / d1) * (y_den / d2);
465 register eusinteger_t x_num,x_den,y_num,y_den,z_num,z_den,d1,d2;
467 x_num =
intval(x->c.ratio.numerator);
468 x_den =
intval(x->c.ratio.denominator);
469 y_num =
intval(y->c.ratio.numerator);
470 y_den =
intval(y->c.ratio.denominator);
474 z_num = (x_num / d1) * (y_num / d2);
475 z_den = (x_den / d2) * (y_den / d1);
483 register eusinteger_t x_num,x_den,y_num,y_den,z_num,z_den,d1,d2;
486 x_num =
intval(x->c.ratio.numerator);
487 x_den =
intval(x->c.ratio.denominator);
488 y_num =
intval(y->c.ratio.numerator);
489 y_den =
intval(y->c.ratio.denominator);
494 if(y_num >= 0) sign=1;
else sign=-1;
496 z_num = (x_num / d1) * (y_den / d2) * sign;
497 z_den =
abs((x_den / d2) * (y_num / d1));
512 if (isint(p)) num=
intval(p);
516 if (isint(q)) den=
intval(q);
525 else if (
intval(r->c.ratio.denominator)==1)
return(r->c.ratio.numerator);
545 if (((is >> 1) ^ is)&((
eusinteger_t)1<<(WORD_SIZE-3))) {
547 else if (isflt(
a)) { fs=is;
goto fplus;}
548 else if (pisratio(
a)) { rs=
makeratio(is,1);
goto rplus;}
549 else if (pisbignum(
a)) { b=
copy_big(
a);
goto bigplus;}
557 else if (isflt(
a)) { fs=
ratio2flt(rs);
goto fplus;}
580 else if (isbignum(
a)) {
598 register pointer a=argv[0], rs, b, z;
608 else if (isratio(
a)) {
610 intval(
a->c.ratio.denominator)));}
619 if (isint(
a)) { is=
intval(
a);
goto IMINUS;}
620 else if (isflt(
a)) { fs=
fltval(
a);
goto FMINUS;}
621 else if (pisratio(
a)) { rs=
a;
goto RMINUS;}
622 else if (isbignum(
a)) { b=
copy_big(
a);
goto BIGMINUS;}
630 if (((is >> 1) ^ is)&((
eusinteger_t)1<<(WORD_SIZE-3))) {
632 else if (isflt(
a)) { fs=is;
goto FMINUS1;}
633 else if (pisratio(
a)) { rs=
makeratio(is,1);
goto RMINUS1;}
634 else if (isbignum(
a)) {
640 if (isint(z)) { vpop(); is=
intval(z);}
641 else { b=z;
goto BIGMINUS1;} }
650 else if (isflt(
a)) { fs=
ratio2flt(rs);
goto FMINUS;}
673 if (isint(b)) { vpop(); is=
intval(b);
goto IMINUS;}
677 else if (isbignum(
a)) {
684 if (isint(b)) { vpop(); is=
intval(b);
goto IMINUS;}
708 if (isint(
a)) { is=
intval(
a);
goto ITIMES;}
709 else if (isflt(
a)) { fs=
fltval(
a);
goto FTIMES;}
710 else if (isratio(
a)) { rs=
a; vpush(rs);
goto RTIMES;}
711 else if (isbignum(
a)) { b=
copy_big(
a); vpush(b);
goto BIGTIMES;}
721 if (
s==0 || is==0) { is=0;
break;}
722 if (is<0) { sign= -1; is = -is;}
723 if (
s<0) { sign= -sign;
s = -
s;}
725 if( hi !=0 || (lo & ((
eusinteger_t)7 << (WORD_SIZE-3)))!=0) {
732 else if (isflt(
a)) { fs=is;
goto FTIMES1;}
733 else if (pisbignum(
a)) {
737 else if (pisratio(
a)) {
749 else if (isflt(
a)) { fs=
ratio2flt(rs);
goto FTIMES1;}
767 if (is<0) { sign = -sign; is= -is;}
771 if (isint(b)) { is=
intval(b); vpop();
goto ITIMES;}
775 else if (pisbignum(
a)) {
784 if (isint(b)) { is=
intval(b); vpop();
goto ITIMES;}
786 else if (pisratio(
a)) {
790 ctx->lastalloc= vpop();
814 else if (isflt(
a)) { fs=
fltval(
a);
goto fquo;}
815 else if (pisratio(
a)) {rs=
a;
goto rquo;}
816 else if (pisbignum(
a)) { rs=
copy_big(
a);
goto bquo;}
825 if (isflt(
a)) { fs=is;
goto fquo2;}
827 else if (pisratio(
a)) { rs=
makeratio(is,1);
goto rquo;}
828 else if (pisbignum(
a)) is = 0;
837 else if (isflt(
a)) { fs=
ratio2flt(rs);
goto fquo;}
860 return(mkbigint(rv));
863 if (is<0) { sign = - sign; is= -is;}
995 else if (pisbignum(
a)) {
1012 if (isint(
a))
return(
a);
1013 else if (isbignum(
a))
return(
a);
1029 if (isint(
a))
return(
a);
1030 else if (isbignum(
a))
return(
a);
1042 if (isint(
a))
return(
a);
1043 else if (isbignum(
a))
return(
a);
1056 if (isint(
a))
return(
a);
1057 else if (isbignum(
a))
return(
a);
1069 extern double frexp(
double,
int *);
1086 if (isflt(
a))
return(
a);
1113 if (
n==1)
return(
a);
1139 if (
n==1)
return(
a);
1159 {
int i=1,j,k,rsize,psize;
1164 r=
copy_big(r); rsize=bigsize(r); rbv=bigvec(r);
1171 if (isint(p)) k &=
intval(p);
1172 else if (isbignum(p)) {
1175 r=b; rsize=bigsize(r); rbv=bigvec(r);
1186 if (
intval(p)>=0)
for (j=1; j<rsize; j++) rbv[j]=0; }
1187 else if (isbignum(p)) {
1192 if (
big_sign(p)>0)
for (j=psize; j<rsize; j++) rbv[j]=0;}
1196 rsize=psize; rbv=bigvec(r);
1215 if (isbignum(p)) result |= bigintval(p);
1217 else result |=
intval(p);
1219 return(mkbigint(result));}
1229 else result ^=
intval(argv[i++]);
1251 else result &=
intval(argv[i++]);
1262 else result |=
intval(argv[i++]);
1292 index=ckintval(argv[0]);
1293 val=ckintval(argv[1]);
1295 if ((val>>
index) & 1)
return(
T);
else return(
NIL);}
1302 register int firstone;
1306 count=ckintval(argv[1]);
1307 if (isint(argv[0])) {
1311 #if (WORD_SIZE == 64)
1316 if ((firstone +
count)<WORD_SIZE-2) {
1317 sign=(val>=0)?1:(-1);
1319 if (sign>0)
return(
makeint(val));
1323 else if (isbignum(argv[0])) {
a=argv[0]; sign=
big_sign(
a);}
1327 {
int size=bigsize(
a);
1332 av=bigvec(
a); bv=bigvec(b);
1334 j=
count/(WORD_SIZE-1); k=
count % (WORD_SIZE-1);
1335 for (i=0; i<size; i++) {
1337 bv[i+j] |= (x << k);
1338 bv[i+j+1] = (x>>((WORD_SIZE-1)-k)); } }
1341 j=
count/(WORD_SIZE-1); k=
count % (WORD_SIZE-1);
1342 for (i=0; i<size-j-1; i++) {
1343 bv[i]=(av[j+i]>>k) | ((av[j+i+1]<<((WORD_SIZE-1)-k)) & MASK); }
1344 bv[size-j-1]=av[size-1]>>k;
1356 #if (WORD_SIZE == 64)
1357 register unsigned long val;
1359 register unsigned int val;
1362 val=ckintval(argv[0]); pos=ckintval(argv[1]);
1363 if (
n==3) width=ckintval(argv[2]);
1364 val=(val<<(WORD_SIZE-pos-width))>>(WORD_SIZE-width);
1372 #if (WORD_SIZE == 64)
1373 register unsigned long val,target,mask=~0L;
1375 register unsigned int val,target,mask=~0;
1378 val=ckintval(argv[0]);
1379 target=ckintval(argv[1]);
1380 pos=ckintval(argv[2]);
1381 width=ckintval(argv[3]);
1382 mask=mask<<(WORD_SIZE-(pos+width));
1383 mask=mask>>(WORD_SIZE-width);
1386 target=(target & ~mask) | (val<<pos);
1402 if (state==
NIL) {
goto MAKERANDSTATENIL; }
1403 else if (state==
T) {
1406 srand((
unsigned int)tm);
1407 randvec->
c.
ivec.
iv[0] = rand();
1408 randvec->
c.
ivec.
iv[1] = rand();
1415 if (state==UNBOUND) state=speval(
RANDSTATE); }
1442 if (state==UNBOUND) state=speval(
RANDSTATE);}
1447 randval=erand48((
unsigned short *)state->c.ivec.iv);
1448 #elif Win32 || Cygwin
1449 randval=((double)rand())/RAND_MAX;
1451 randval=erand48((
unsigned short *)(state->c.ivec.iv));
1456 irandval=randval*imax;
1458 else if (isflt(
a)) {
1460 frandval=randval*fmax;
pointer LOG(context *ctx, int n, argv)
void complement_big(pointer x)
pointer LOGIOR(context *ctx, int n, argv)
eusinteger_t big_sign(pointer)
pointer EUSFLOAT(context *ctx, int n, argv)
pointer RANDOM(context *ctx, int n, argv)
pointer SINH(context *ctx, int n, argv)
defun("ADR_TO_STRING", mod, ADR_TO_STRING)
pointer ratio_minus(pointer x, pointer y)
pointer TIMES(context *ctx, int n, argv)
pointer TRUNCATE(context *ctx, int n, argv)
pointer return_ratio(pointer r)
pointer FREXP(context *ctx, int n, argv)
pointer EXP(context *ctx, int n, argv)
pointer LOGAND(context *ctx, int n, pointer argv[])
pointer ratio_divide(pointer x, pointer y)
pointer makevector(pointer, int)
eusinteger_t div_int_big(eusinteger_t c, pointer x)
pointer LSEQP(context *ctx, int n, argv)
pointer MAKERANDOMSTATE(context *ctx, int n, argv)
pointer LOGNOR(context *ctx, int n, argv)
pointer GREATERP(context *ctx, int n, argv)
pointer TANH(context *ctx, int n, argv)
pointer COSH(context *ctx, int n, argv)
pointer FLOOR(context *ctx, int n, argv)
pointer eusfloat_to_big(float)
pointer MIN(context *ctx, int n, argv)
pointer MAX(context *ctx, int n, argv)
void arith(context *ctx, pointer mod)
pointer ABS(context *ctx, int n, argv)
pointer extend_big(pointer, int)
pointer ASH(context *ctx, int n, argv)
eusinteger_t div_big_big(pointer x, pointer y)
pointer ACOSH(context *ctx, int n, argv)
void mul_int_big(eusinteger_t c, pointer x)
eusfloat_t big_to_float(pointer)
pointer SUB1(context *ctx, int n, argv)
pointer LOGEQV(context *ctx, int n, argv)
pointer DECFLOAT(context *ctx, int n, argv)
pointer GREQP(context *ctx, int n, argv)
pointer LDB(context *ctx, int n, argv)
pointer LOGNAND(context *ctx, int n, argv)
pointer LOGNOT(context *ctx, int n, argv)
pointer NUMEQUAL(context *ctx, int n, argv)
pointer cons(context *, pointer, pointer)
eusfloat_t ratio2flt(pointer r)
pointer error(enum errorcode ec,...) pointer error(va_alist) va_dcl
pointer NUMNEQUAL(context *ctx, int n, argv)
pointer ratio_times(pointer x, pointer y)
pointer normalize_bignum()
pointer ATANH(context *ctx, int n, argv)
void extended_mul(eusinteger_t d, eusinteger_t q, eusinteger_t r, eusinteger_t *hp, eusinteger_t *lp)
pointer int2ratio(eusinteger_t i)
int big_compare(pointer x, pointer y)
pointer ASINH(context *ctx, int n, argv)
pointer TAN(context *ctx, int n, argv)
pointer COS(context *ctx, int n, argv)
pointer MINUS(context *ctx, int n, argv)
pointer ATAN(context *ctx, int n, argv)
pointer LESSP(context *ctx, int n, argv)
pointer DPB(context *ctx, int n, argv)
pointer LOGBITP(context *ctx, int n, argv)
pointer LOGXOR(context *ctx, int n, argv)
pointer SQRT(context *ctx, int n, argv)
pointer CEILING(context *ctx, int n, argv)
pointer QUOTIENT(context *ctx, int n, argv)
pointer ROUND(context *ctx, int n, argv)
pointer LOGTEST(context *ctx, int n, argv)
pointer MOD(context *ctx, int n, argv)
pointer PLUS(context *ctx, int n, argv)
pointer ratio_plus(pointer x, pointer y)
pointer SIN(context *ctx, int n, argv)
pointer ADD1(context *ctx, int n, argv)
euslisp
Author(s): Toshihiro Matsui
autogenerated on Thu Jun 15 2023 02:06:42