|
601 | 601 | (or (numberp u) (alg u))) |
602 | 602 | (t (quick-sqfr-check u var)))) |
603 | 603 |
|
604 | | -(declare-top (special p)) |
| 604 | +(declare-top (special *p*)) |
| 605 | + |
| 606 | +;; Note: *P* used to be P. In some functions below, *P* can probably be |
| 607 | +;; renamed back to P (lexical variable), but some do really need a special |
| 608 | +;; variable because they use it to transport state from one function to |
| 609 | +;; another. |
605 | 610 |
|
606 | 611 | (defun fixvl0 (l1 l2 ov) |
607 | 612 | (prog (a b c) |
|
633 | 638 |
|
634 | 639 | (defun multfact (poly) |
635 | 640 | (prog (*inl3 *i* *min* *mx* nn* *odr* lc elm listelm plim origenvar ne var valist val1 |
636 | | - ovarlist p subvar subvar1 subval1 subval dlp) |
637 | | - ;; (declare (special p)) |
| 641 | + ovarlist *p* subvar subvar1 subval1 subval dlp) |
| 642 | + ;; (declare (special *p*)) |
638 | 643 | (setq var (car poly) elm (listovars poly) |
639 | 644 | origenvar genvar |
640 | 645 | genvar (intersect genvar (if algfac* |
|
652 | 657 | (> (cadddr subval) 1)) |
653 | 658 | (degvector nil 1 (car subval))))))) |
654 | 659 | (setq subval nil) |
655 | | - (setq p poly) |
| 660 | + (setq *p* poly) |
656 | 661 | (when (null val1) |
657 | 662 | (setq subvar1 ovarlist) |
658 | 663 | (setq subval1 (polysubst (make-list (length subvar1) :initial-element 0) subvar1)) |
|
665 | 670 | (setq subval1 nil subvar1 nil) |
666 | 671 | (fixvl0 subvar subval (reverse ovarlist)) |
667 | 672 | (when algfac* (push (car *alpha*) genvar)) |
668 | | - (setq poly (cpber3 poly p)) |
| 673 | + (setq poly (cpber3 poly *p*)) |
669 | 674 | (setq genvar origenvar) |
670 | 675 | (return poly))) |
671 | 676 |
|
672 | 677 | (defun polysubst (a b) |
673 | 678 | (prog (lc *inl3 d n modulus) |
674 | 679 | (when modulu* (setq modulus modulu*)) |
675 | | - (setq *inl3 t lc (caddr p) n (length a)) |
| 680 | + (setq *inl3 t lc (caddr *p*) n (length a)) |
676 | 681 | loop (setq d (pcsubsty a b lc)) |
677 | 682 | (when (equal 0 d) (go inl)) |
678 | 683 | (let ((modulus nil)) |
679 | | - (setq d (pcsubsty a b p))) |
| 684 | + (setq d (pcsubsty a b *p*))) |
680 | 685 | (when (sqfrp (pmod d) (car d)) |
681 | | - (setq p d) (return a)) |
| 686 | + (setq *p* d) (return a)) |
682 | 687 | inl (setq a (increaselist a n)) |
683 | 688 | (go loop))) |
684 | 689 |
|
|
706 | 711 | (setq r (cdr r)) |
707 | 712 | (go loop))) |
708 | 713 |
|
709 | | -(defun maxcoef (p) |
710 | | - (maxcoefficient p)) |
| 714 | +(defun maxcoef (*p*) |
| 715 | + (maxcoefficient *p*)) |
711 | 716 |
|
712 | | -(defun incrlimk (p) |
| 717 | +(defun incrlimk (*p*) |
713 | 718 | (prog (v min-plim) |
714 | 719 | (cond (modulu* (setq plim modulu* *prime modulu* limk -1) (return nil)) |
715 | 720 | ((null limk)(setq plim *alpha *prime *alpha limk -1)(return nil))) |
716 | | - (setq v (butlast (pdegreevector p))) |
| 721 | + (setq v (butlast (pdegreevector *p*))) |
717 | 722 | (setq v |
718 | 723 | (apply |
719 | 724 | '* |
|
727 | 732 | (expt b a))))) |
728 | 733 | v |
729 | 734 | valist))) |
730 | | - (setq min-plim (* (max (maxcoef p) plim) v)) |
| 735 | + (setq min-plim (* (max (maxcoef *p*) plim) v)) |
731 | 736 | loop (cond ((< min-plim plim) (return nil))) |
732 | 737 | (incf limk) |
733 | 738 | (setq plim (* plim plim)) |
|
798 | 803 | (go test) |
799 | 804 | out (return ans))) |
800 | 805 |
|
801 | | -(defun multideg (p) |
| 806 | +(defun multideg (*p*) |
802 | 807 | (prog (m d) |
803 | | - (cond ((numberp p) (return 0)) ((onevarp p) (return (cadr p)))) |
804 | | - (setq p (cdr p) m (car p)) |
805 | | - loop (cond ((null p) (return m))) |
806 | | - (setq d (+ (car p) (multideg (cadr p))) p (cddr p) m (max d m)) |
| 808 | + (cond ((numberp *p*) (return 0)) ((onevarp *p*) (return (cadr *p*)))) |
| 809 | + (setq *p* (cdr *p*) m (car *p*)) |
| 810 | + loop (cond ((null *p*) (return m))) |
| 811 | + (setq d (+ (car *p*) (multideg (cadr *p*))) *p* (cddr *p*) m (max d m)) |
807 | 812 | (go loop))) |
808 | 813 |
|
809 | 814 | (defun oddelm (list) |
|
1083 | 1088 |
|
1084 | 1089 |
|
1085 | 1090 | (defun fact2z (u f g limk) |
1086 | | - (prog (a a1 w pk mpk b c r p ql qlp h (k 0) b1) |
| 1091 | + (prog (a a1 w pk mpk b c r *p* ql qlp h (k 0) b1) |
1087 | 1092 | (declare (fixnum k)) |
1088 | | - (setq p modulus) |
| 1093 | + (setq *p* modulus) |
1089 | 1094 | (setq r (ppprog f g)) |
1090 | 1095 | (setq a (car r)) |
1091 | 1096 | (setq b (cadr r)) |
|
1119 | 1124 | (setq b (pplus b (npctimes mpk b1))) |
1120 | 1125 | (setq h nil b1 nil qlp nil) |
1121 | 1126 | (go sharp) |
1122 | | - on (set-modulus p) |
| 1127 | + on (set-modulus *p*) |
1123 | 1128 | (return (list f g)))) |
1124 | 1129 |
|
1125 | 1130 |
|
1126 | 1131 |
|
1127 | | -(defun npctimes (c p) |
1128 | | - (setq p (npctimes1 c p)) |
1129 | | - (if (and (not (atom p)) (null (cdr p))) |
| 1132 | +(defun npctimes (c *p*) |
| 1133 | + (setq *p* (npctimes1 c *p*)) |
| 1134 | + (if (and (not (atom *p*)) (null (cdr *p*))) |
1130 | 1135 | 0 |
1131 | | - p)) |
| 1136 | + *p*)) |
1132 | 1137 |
|
1133 | | -(defun npquo (p c) |
| 1138 | +(defun npquo (*p* c) |
1134 | 1139 | (prog (u modulus) |
1135 | | - (cond ((equal c 1) (return p)) |
1136 | | - ((pcoefp p) (return (quotient p c)))) |
1137 | | - (setq u p) |
1138 | | - loop (cond ((null (cdr u)) (return p))) |
| 1140 | + (cond ((equal c 1) (return *p*)) |
| 1141 | + ((pcoefp *p*) (return (quotient *p* c)))) |
| 1142 | + (setq u *p*) |
| 1143 | + loop (cond ((null (cdr u)) (return *p*))) |
1139 | 1144 | (setq u (cddr u)) |
1140 | 1145 | (rplaca u (cond ((pcoefp (car u)) |
1141 | 1146 | (quotient (car u) c)) |
1142 | 1147 | (t (npquo (copy-list (car u)) c)))) |
1143 | 1148 | (go loop))) |
1144 | 1149 |
|
1145 | | -(defun npctimes1 (c p) |
| 1150 | +(defun npctimes1 (c *p*) |
1146 | 1151 | (prog (u a) |
1147 | | - (cond((equal c 1)(return p)) |
1148 | | - ((pcoefp p)(return (ctimes c p)))) |
1149 | | - (setq u p) |
1150 | | - loop (cond ((null (cdr u))(return p))) |
| 1152 | + (cond((equal c 1)(return *p*)) |
| 1153 | + ((pcoefp *p*)(return (ctimes c *p*)))) |
| 1154 | + (setq u *p*) |
| 1155 | + loop (cond ((null (cdr u))(return *p*))) |
1151 | 1156 | (setq a (cond ((pcoefp (caddr u)) (ctimes c (caddr u))) |
1152 | 1157 | (t (npctimes c (copy-list (caddr u)))))) |
1153 | 1158 | (cond ((equal a 0) (rplacd u (cdddr u))) |
1154 | 1159 | (t (setq u (cddr u)) |
1155 | 1160 | (rplaca u a))) |
1156 | 1161 | (go loop))) |
1157 | 1162 |
|
1158 | | -(defun x**q1 (term u m p) |
| 1163 | +(defun x**q1 (term u m *p*) |
1159 | 1164 | (declare (fixnum m)) |
1160 | 1165 | (prog ((i 1)) |
1161 | 1166 | (declare (fixnum i)) |
1162 | 1167 | (setq trl* (list term)) |
1163 | | - loop (when (= i m) (return (pexptmod term p u))) |
1164 | | - (setq term (pexptmod term p u)) |
| 1168 | + loop (when (= i m) (return (pexptmod term *p* u))) |
| 1169 | + (setq term (pexptmod term *p* u)) |
1165 | 1170 | (setq trl* (cons term trl*)) |
1166 | 1171 | (incf i) |
1167 | 1172 | (go loop))) |
1168 | 1173 |
|
1169 | | -(defun cptomf (p u n) |
1170 | | - (declare (fixnum n p)) |
| 1174 | +(defun cptomf (*p* u n) |
| 1175 | + (declare (fixnum n *p*)) |
1171 | 1176 | (prog (l s *xn (j 0) (i 0) ind (n-1 (1- n)) ) |
1172 | 1177 | (declare (fixnum i j)) |
1173 | 1178 | loop (incf j) |
1174 | 1179 | (cond ((= j n) (return nil)) |
1175 | 1180 | (ind (go sa)) |
1176 | | - ((> (* p j) n-1) |
| 1181 | + ((> (* *p* j) n-1) |
1177 | 1182 | (setq *xn (mapcar #'- (p2cpol (cddr u) n-1)) |
1178 | 1183 | s (copy-tree *xn) |
1179 | 1184 | ind t) |
1180 | | - (setq i (- (* p j) n)) |
| 1185 | + (setq i (- (* *p* j) n)) |
1181 | 1186 | (go sa1))) |
1182 | | - (setq s (p2cpol (list var (* p j) 1) n-1)) |
| 1187 | + (setq s (p2cpol (list var (* *p* j) 1) n-1)) |
1183 | 1188 | (go st) |
1184 | | - sa (setq i p) |
| 1189 | + sa (setq i *p*) |
1185 | 1190 | sa1 (cond ((= i 0) (go st))) |
1186 | 1191 | (cptimesx s) |
1187 | 1192 | (decf i) |
|
1200 | 1205 | on (decf (aref *afixn* j j)) |
1201 | 1206 | (go loop))) |
1202 | 1207 |
|
1203 | | -(defun p2cpol (p n) |
| 1208 | +(defun p2cpol (*p* n) |
1204 | 1209 | (declare (fixnum n)) |
1205 | 1210 | (prog (l) |
1206 | | - (setq p (cdr p)) |
| 1211 | + (setq *p* (cdr *p*)) |
1207 | 1212 | loop (cond ((= n -1) (return (nreverse l))) |
1208 | | - ((or (null p) (> n (car p))) (setq l (cons 0 l))) |
1209 | | - ((= n (car p)) |
1210 | | - (setq l (cons (cadr p) l)) |
1211 | | - (setq p (cddr p)))) |
| 1213 | + ((or (null *p*) (> n (car *p*))) (setq l (cons 0 l))) |
| 1214 | + ((= n (car *p*)) |
| 1215 | + (setq l (cons (cadr *p*) l)) |
| 1216 | + (setq *p* (cddr *p*)))) |
1212 | 1217 | (decf n) |
1213 | 1218 | (go loop))) |
1214 | 1219 |
|
1215 | | -(defun cptimesx (p) |
| 1220 | +(defun cptimesx (*p*) |
1216 | 1221 | (prog (xn q lc) |
1217 | | - (setq xn *xn q p lc (car p)) |
| 1222 | + (setq xn *xn q *p* lc (car *p*)) |
1218 | 1223 | loop (cond ((cdr q) |
1219 | 1224 | (rplaca q (cplus (cadr q) (ctimes lc (car xn)))) |
1220 | 1225 | (setq q (cdr q) xn (cdr xn))) |
1221 | | - (t (rplaca q (ctimes lc (car xn))) (return p))) |
| 1226 | + (t (rplaca q (ctimes lc (car xn))) (return *p*))) |
1222 | 1227 | (go loop))) |
1223 | 1228 |
|
1224 | 1229 |
|
|
1339 | 1344 | (return (list linfac (cpbq1 u (cadr u)) u)))) |
1340 | 1345 |
|
1341 | 1346 |
|
1342 | | -(defun factor1972 (p) |
| 1347 | +(defun factor1972 (*p*) |
1343 | 1348 | (let ((modulu* modulus) many* *stop* modulus mcflag *negflag*) |
1344 | | - (if (or (atom p) (numberp p) (and algfac* (alg p))) |
1345 | | - (list p) |
1346 | | - (factor72 p)))) |
| 1349 | + (if (or (atom *p*) (numberp *p*) (and algfac* (alg *p*))) |
| 1350 | + (list *p*) |
| 1351 | + (factor72 *p*)))) |
1347 | 1352 |
|
1348 | | -(defun factor72 (p) |
| 1353 | +(defun factor72 (*p*) |
1349 | 1354 | (let ((sharpcont 1) plim) |
1350 | | - (setq p (cond ((onevarp p) |
1351 | | - (mapcar #'posize (fact5 p))) |
| 1355 | + (setq *p* (cond ((onevarp *p*) |
| 1356 | + (mapcar #'posize (fact5 *p*))) |
1352 | 1357 | (t |
1353 | 1358 | (setq many* t) |
1354 | | - (multfact p)))) |
| 1359 | + (multfact *p*)))) |
1355 | 1360 | (if *negflag* |
1356 | | - (cons (pminus (car p)) (cdr p)) |
1357 | | - p))) |
| 1361 | + (cons (pminus (car *p*)) (cdr *p*)) |
| 1362 | + *p*))) |
1358 | 1363 |
|
1359 | | -(defun posize (p) |
1360 | | - (cond ((pminusp p) |
| 1364 | +(defun posize (*p*) |
| 1365 | + (cond ((pminusp *p*) |
1361 | 1366 | (setq *negflag* (not *negflag*)) |
1362 | | - (pminus p)) |
1363 | | - (t p))) |
| 1367 | + (pminus *p*)) |
| 1368 | + (t *p*))) |
0 commit comments