
(/VERSIONCHECK 2) 

(DEFUN |IRREDFFX;qAdicExpansion| (|z| $)
  (PROG (|qr| |r|)
    (RETURN
      (SEQ (LETT |qr| (DIVIDE2 |z| (QREFELT $ 11))
                 . #0=(|IRREDFFX;qAdicExpansion|))
           (EXIT (COND
                   ((ZEROP (QCDR |qr|))
                    (SPADCALL
                        (SPADCALL (|spadConstant| $ 12) 1
                            (QREFELT $ 14))
                        (|IRREDFFX;qAdicExpansion| (QCAR |qr|) $)
                        (QREFELT $ 15)))
                   ('T
                    (SEQ (LETT |r|
                               (SPADCALL
                                   (SPADCALL (QCDR |qr|)
                                    (QREFELT $ 17))
                                   (QREFELT $ 18)) . #0#)
                         (EXIT (COND
                                 ((ZEROP (QCAR |qr|)) |r|)
                                 ('T
                                  (SPADCALL |r|
                                      (SPADCALL
                                       (SPADCALL (|spadConstant| $ 12)
                                        1 (QREFELT $ 14))
                                       (|IRREDFFX;qAdicExpansion|
                                        (QCAR |qr|) $)
                                       (QREFELT $ 15))
                                      (QREFELT $ 19))))))))))))) 

(DEFUN |IRREDFFX;getIrredPoly| (|start| |n| $)
  (PROG (|mon| |end| |pol| |found|)
    (RETURN
      (SEQ (LETT |mon|
                 (SPADCALL (|spadConstant| $ 12) |n| (QREFELT $ 14))
                 . #0=(|IRREDFFX;getIrredPoly|))
           (LETT |pol| (|spadConstant| $ 20) . #0#)
           (LETT |found| 'NIL . #0#)
           (LETT |end|
                 (- (SPADCALL (QREFELT $ 11) |n| (QREFELT $ 21)) 1) . #0#)
           (SEQ G190
                (COND
                  ((NULL (COND
                           ((OR (< |end| |start|) |found|) 'NIL)
                           ('T 'T)))
                   (GO G191)))
                (SEQ (COND
                       ((EQL (GCD |start| (QREFELT $ 9)) 1)
                        (COND
                          ((SPADCALL
                               (LETT |pol|
                                     (SPADCALL |mon|
                                      (|IRREDFFX;qAdicExpansion|
                                       |start| $)
                                      (QREFELT $ 19)) . #0#)
                               (QREFELT $ 24))
                           (LETT |found| 'T . #0#)))))
                     (EXIT (LETT |start| (+ |start| 1) . #0#)))
                NIL (GO G190) G191 (EXIT NIL))
           (EXIT (COND
                   ((SPADCALL |pol| (QREFELT $ 25))
                    (|error| "no irreducible poly found"))
                   ('T |pol|))))))) 

(DEFUN |IRREDFFX;generateIrredPoly;PiSup;3| (|n| $)
  (COND
    ((EQL |n| 1) (SPADCALL (|spadConstant| $ 12) 1 (QREFELT $ 14)))
    ((OR (EQL (GCD (QREFELT $ 9) |n|) 1) (< |n| (QREFELT $ 11)))
     (COND
       ((ODDP |n|) (|IRREDFFX;getIrredPoly| 2 |n| $))
       ('T (|IRREDFFX;getIrredPoly| 1 |n| $))))
    ('T (|IRREDFFX;getIrredPoly| (+ (QREFELT $ 11) 1) |n| $)))) 

(DEFUN |IrredPolyOverFiniteField| (#0=#:G1840)
  (PROG ()
    (RETURN
      (PROG (#1=#:G1841)
        (RETURN
          (COND
            ((LETT #1#
                   (|lassocShiftWithFunction| (LIST (|devaluate| #0#))
                       (HGET |$ConstructorCache|
                             '|IrredPolyOverFiniteField|)
                       '|domainEqualList|)
                   . #2=(|IrredPolyOverFiniteField|))
             (|CDRwithIncrement| #1#))
            ('T
             (UNWIND-PROTECT
               (PROG1 (|IrredPolyOverFiniteField;| #0#)
                 (LETT #1# T . #2#))
               (COND
                 ((NOT #1#)
                  (HREM |$ConstructorCache|
                        '|IrredPolyOverFiniteField|))))))))))) 

(DEFUN |IrredPolyOverFiniteField;| (|#1|)
  (PROG (DV$1 |dv$| $ |pv$| #0=#:G1823 #1=#:G1824)
    (RETURN
      (PROGN
        (LETT DV$1 (|devaluate| |#1|)
              . #2=(|IrredPolyOverFiniteField|))
        (LETT |dv$| (LIST '|IrredPolyOverFiniteField| DV$1) . #2#)
        (LETT $ (GETREFV 27) . #2#)
        (QSETREFV $ 0 |dv$|)
        (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #2#))
        (|haddProp| |$ConstructorCache| '|IrredPolyOverFiniteField|
            (LIST DV$1) (CONS 1 $))
        (|stuffDomainSlots| $)
        (QSETREFV $ 6 |#1|)
        (QSETREFV $ 9
            (PROG1 (LETT #0# (SPADCALL (QREFELT $ 8)) . #2#)
              (|check-subtype| (> #0# 0) '(|PositiveInteger|) #0#)))
        (QSETREFV $ 11
            (PROG1 (LETT #1# (SPADCALL (QREFELT $ 10)) . #2#)
              (|check-subtype| (> #1# 0) '(|PositiveInteger|) #1#)))
        $)))) 

(MAKEPROP '|IrredPolyOverFiniteField| '|infovec|
    (LIST '#(NIL NIL NIL NIL NIL NIL (|local| |#1|)
             (|NonNegativeInteger|) (0 . |characteristic|) '|p|
             (4 . |size|) '|q| (8 . |One|)
             (|SparseUnivariatePolynomial| 6) (12 . |monomial|)
             (18 . *) (|PositiveInteger|) (24 . |index|)
             (29 . |coerce|) (34 . +) (40 . |Zero|) (44 . **)
             (|Boolean|) (|DistinctDegreeFactorize| 6 13)
             (50 . |irreducible?|) (55 . |zero?|)
             |IRREDFFX;generateIrredPoly;PiSup;3|)
          '#(|generateIrredPoly| 60) 'NIL
          (CONS (|makeByteWordVec2| 1 'NIL)
                (CONS '#()
                      (CONS '#()
                            (|makeByteWordVec2| 26
                                '(0 6 7 8 0 6 7 10 0 6 0 12 2 13 0 6 7
                                  14 2 13 0 0 0 15 1 6 0 16 17 1 13 0 6
                                  18 2 13 0 0 0 19 0 13 0 20 2 16 0 0
                                  16 21 1 23 22 13 24 1 13 22 0 25 1 0
                                  13 16 26)))))
          '|lookupComplete|)) 
