
(/VERSIONCHECK 2) 

(DEFUN |GAUSSFAC;reduction| (|u| |p| $)
  (COND ((EQL |p| 0) |u|) ('T (SPADCALL |u| |p| (QREFELT $ 7))))) 

(DEFUN |GAUSSFAC;merge| (|p| |q| $)
  (COND ((EQL |p| |q|) (CONS 0 |p|)) ((EQL |p| 0) (CONS 0 |q|))
        ((EQL |q| 0) (CONS 0 |p|)) ('T (CONS 1 "failed")))) 

(DEFUN |GAUSSFAC;exactquo| (|u| |v| |p| $)
  (PROG (#1=#:G682)
    (RETURN
     (COND ((EQL |p| 0) (SPADCALL |u| |v| (QREFELT $ 9)))
           ((EQL (REMAINDER2 |v| |p|) 0) (CONS 1 "failed"))
           ('T
            (CONS 0
                  (SPADCALL
                   (QCAR
                    (PROG2
                        (LETT #1# (SPADCALL |v| |p| |u| (QREFELT $ 12))
                              |GAUSSFAC;exactquo|)
                        (QCDR #1#)
                      (|check-union| (QEQCAR #1# 0)
                                     (|Record| (|:| |coef1| (|Integer|))
                                               (|:| |coef2| (|Integer|)))
                                     #1#)))
                   |p| (QREFELT $ 7)))))))) 

(DEFUN |GAUSSFAC;findelt| (|q| $)
  (PROG (|t| |s| #1=#:G689 |i| |qq1| |r1| |r| #2=#:G670 |q1|)
    (RETURN
     (SEQ (LETT |q1| (- |q| 1) . #3=(|GAUSSFAC;findelt|)) (LETT |r| |q1| . #3#)
          (LETT |r1| (SPADCALL |r| 4 (QREFELT $ 9)) . #3#)
          (SEQ G190
               (COND
                ((NULL (COND ((QEQCAR |r1| 1) 'NIL) ('T 'T))) #4=(GO G191)))
               (SEQ
                (LETT |r|
                      (PROG2
                          (LETT #2# |r1| . #3#)
                          (QCDR #2#)
                        (|check-union| (QEQCAR #2# 0) (|Integer|) #2#))
                      . #3#)
                (EXIT (LETT |r1| (SPADCALL |r| 2 (QREFELT $ 9)) . #3#)))
               NIL #5=(GO G190) G191 (EXIT NIL))
          (LETT |s| (SPADCALL 1 |q| (QREFELT $ 18)) . #3#)
          (LETT |qq1| (SPADCALL |q1| |q| (QREFELT $ 18)) . #3#)
          (SEQ (LETT |i| 2 . #3#) G190
               (COND
                ((NULL
                  (COND
                   ((SPADCALL |s| (|spadConstant| $ 14) (QREFELT $ 20)) 'T)
                   ('T (SPADCALL |s| |qq1| (QREFELT $ 20)))))
                 #4#))
               (SEQ
                (EXIT
                 (LETT |s|
                       (SPADCALL (SPADCALL |i| |q| (QREFELT $ 18))
                                 (PROG1 (LETT #1# |r| . #3#)
                                   (|check-subtype| (>= #1# 0)
                                                    '(|NonNegativeInteger|)
                                                    #1#))
                                 (QREFELT $ 22))
                       . #3#)))
               (LETT |i| (QSADD1 |i|) . #3#) #5# G191 (EXIT NIL))
          (LETT |t| |s| . #3#)
          (SEQ G190
               (COND
                ((NULL
                  (COND ((SPADCALL |t| |qq1| (QREFELT $ 20)) 'NIL) ('T 'T)))
                 #4#))
               (SEQ (LETT |s| |t| . #3#)
                    (EXIT (LETT |t| (SPADCALL |t| 2 (QREFELT $ 24)) . #3#)))
               NIL #5# G191 (EXIT NIL))
          (EXIT (SPADCALL |s| (QREFELT $ 25))))))) 

(DEFUN |GAUSSFAC;sumsq1| (|p| $)
  (PROG (|s| |u| |w|)
    (RETURN
     (SEQ (LETT |s| (|GAUSSFAC;findelt| |p| $) . #1=(|GAUSSFAC;sumsq1|))
          (LETT |u| |p| . #1#)
          (SEQ G190
               (COND
                ((NULL (< |p| (SPADCALL |u| 2 (QREFELT $ 26)))) (GO G191)))
               (SEQ (LETT |w| (REMAINDER2 |u| |s|) . #1#) (LETT |u| |s| . #1#)
                    (EXIT (LETT |s| |w| . #1#)))
               NIL (GO G190) G191 (EXIT NIL))
          (EXIT (LIST |u| |s|)))))) 

(DEFUN |GAUSSFAC;intfactor| (|n| $)
  (PROG (|r| |z| |sz| |unity| #1=#:G714 |exp| #2=#:G724 |term| |lfn|)
    (RETURN
     (SEQ
      (LETT |lfn| (SPADCALL |n| (QREFELT $ 29)) . #3=(|GAUSSFAC;intfactor|))
      (LETT |r| NIL . #3#)
      (LETT |unity| (SPADCALL (SPADCALL |lfn| (QREFELT $ 30)) 0 (QREFELT $ 16))
            . #3#)
      (SEQ (LETT |term| NIL . #3#)
           (LETT #2# (SPADCALL |lfn| (QREFELT $ 34)) . #3#) G190
           (COND
            ((OR (ATOM #2#) (PROGN (LETT |term| (CAR #2#) . #3#) NIL))
             (GO G191)))
           (SEQ (LETT |n| (QVELT |term| 1) . #3#)
                (LETT |exp| (QVELT |term| 2) . #3#)
                (EXIT
                 (COND
                  ((EQL |n| 2)
                   (SEQ
                    (LETT |r|
                          (CONS
                           (VECTOR (CONS 3 "prime") (QREFELT $ 17)
                                   (SPADCALL 2 |exp| (QREFELT $ 35)))
                           |r|)
                          . #3#)
                    (EXIT
                     (LETT |unity|
                           (SPADCALL |unity|
                                     (SPADCALL (SPADCALL 0 -1 (QREFELT $ 16))
                                               (PROG1
                                                   (LETT #1#
                                                         (REMAINDER2 |exp| 4)
                                                         . #3#)
                                                 (|check-subtype| (>= #1# 0)
                                                                  '(|NonNegativeInteger|)
                                                                  #1#))
                                               (QREFELT $ 36))
                                     (QREFELT $ 37))
                           . #3#))))
                  ((EQL (REMAINDER2 |n| 4) 3)
                   (LETT |r|
                         (CONS
                          (VECTOR (CONS 3 "prime")
                                  (SPADCALL |n| 0 (QREFELT $ 16)) |exp|)
                          |r|)
                         . #3#))
                  ('T
                   (SEQ (LETT |sz| (|GAUSSFAC;sumsq1| |n| $) . #3#)
                        (LETT |z|
                              (SPADCALL (SPADCALL |sz| 1 (QREFELT $ 39))
                                        (SPADCALL |sz| 2 (QREFELT $ 39))
                                        (QREFELT $ 16))
                              . #3#)
                        (EXIT
                         (LETT |r|
                               (CONS (VECTOR (CONS 3 "prime") |z| |exp|)
                                     (CONS
                                      (VECTOR (CONS 3 "prime")
                                              (SPADCALL |z| (QREFELT $ 40))
                                              |exp|)
                                      |r|))
                               . #3#)))))))
           (LETT #2# (CDR #2#) . #3#) (GO G190) G191 (EXIT NIL))
      (EXIT (SPADCALL |unity| |r| (QREFELT $ 44))))))) 

(DEFUN |GAUSSFAC;factor;CF;7| (|m| $)
  (PROG (|unity| |result| |z| #1=#:G739 |part| |g0| #2=#:G735 |exp| |n|
         #3=#:G747 |term| |factn| |r| |b| #4=#:G670 |a| |d| |ris|)
    (RETURN
     (SEQ
      (COND
       ((SPADCALL |m| (|spadConstant| $ 46) (QREFELT $ 47))
        (SPADCALL (|spadConstant| $ 46) 1 (QREFELT $ 48)))
       (#5='T
        (SEQ
         (LETT |a| (SPADCALL |m| (QREFELT $ 49)) . #6=(|GAUSSFAC;factor;CF;7|))
         (LETT |b| (SPADCALL |m| (QREFELT $ 50)) . #6#)
         (EXIT
          (COND ((EQL |b| 0) (|GAUSSFAC;intfactor| |a| $))
                ((EQL |a| 0)
                 (SEQ (LETT |ris| (|GAUSSFAC;intfactor| |b| $) . #6#)
                      (LETT |unity|
                            (SPADCALL (SPADCALL |ris| (QREFELT $ 51))
                                      (SPADCALL 0 1 (QREFELT $ 16))
                                      (QREFELT $ 37))
                            . #6#)
                      (EXIT
                       (SPADCALL |unity| (SPADCALL |ris| (QREFELT $ 52))
                                 (QREFELT $ 44)))))
                (#5#
                 (SEQ (LETT |d| (GCD |a| |b|) . #6#) (LETT |result| NIL . #6#)
                      (LETT |unity| (|spadConstant| $ 53) . #6#)
                      (COND
                       ((NULL (EQL |d| 1))
                        (SEQ
                         (LETT |a|
                               (PROG2
                                   (LETT #4# (SPADCALL |a| |d| (QREFELT $ 9))
                                         . #6#)
                                   (QCDR #4#)
                                 (|check-union| (QEQCAR #4# 0) (|Integer|)
                                                #4#))
                               . #6#)
                         (LETT |b|
                               (PROG2
                                   (LETT #4# (SPADCALL |b| |d| (QREFELT $ 9))
                                         . #6#)
                                   (QCDR #4#)
                                 (|check-union| (QEQCAR #4# 0) (|Integer|)
                                                #4#))
                               . #6#)
                         (LETT |r| (|GAUSSFAC;intfactor| |d| $) . #6#)
                         (LETT |result| (SPADCALL |r| (QREFELT $ 52)) . #6#)
                         (LETT |unity| (SPADCALL |r| (QREFELT $ 51)) . #6#)
                         (EXIT
                          (LETT |m| (SPADCALL |a| |b| (QREFELT $ 16))
                                . #6#)))))
                      (LETT |n|
                            (+ (SPADCALL |a| 2 (QREFELT $ 26))
                               (SPADCALL |b| 2 (QREFELT $ 26)))
                            . #6#)
                      (LETT |factn|
                            (SPADCALL (SPADCALL |n| (QREFELT $ 29))
                                      (QREFELT $ 34))
                            . #6#)
                      (LETT |part|
                            (VECTOR (CONS 3 "prime") (|spadConstant| $ 46) 0)
                            . #6#)
                      (SEQ (LETT |term| NIL . #6#) (LETT #3# |factn| . #6#)
                           G190
                           (COND
                            ((OR (ATOM #3#)
                                 (PROGN (LETT |term| (CAR #3#) . #6#) NIL))
                             (GO G191)))
                           (SEQ (LETT |n| (QVELT |term| 1) . #6#)
                                (LETT |exp| (QVELT |term| 2) . #6#)
                                (EXIT
                                 (COND
                                  ((EQL |n| 2)
                                   (SEQ
                                    (LETT |part|
                                          (VECTOR (CONS 3 "prime")
                                                  (QREFELT $ 17) |exp|)
                                          . #6#)
                                    (LETT |m|
                                          (SPADCALL |m|
                                                    (SPADCALL (QREFELT $ 17)
                                                              (PROG1
                                                                  (LETT #2#
                                                                        |exp|
                                                                        . #6#)
                                                                (|check-subtype|
                                                                 (>= #2# 0)
                                                                 '(|NonNegativeInteger|)
                                                                 #2#))
                                                              (QREFELT $ 36))
                                                    (QREFELT $ 54))
                                          . #6#)
                                    (EXIT
                                     (LETT |result| (CONS |part| |result|)
                                           . #6#))))
                                  ((EQL (REMAINDER2 |n| 4) 3)
                                   (SEQ
                                    (LETT |g0| (SPADCALL |n| 0 (QREFELT $ 16))
                                          . #6#)
                                    (LETT |part|
                                          (VECTOR (CONS 3 "prime") |g0|
                                                  (QUOTIENT2 |exp| 2))
                                          . #6#)
                                    (LETT |m|
                                          (SPADCALL |m| |g0| (QREFELT $ 54))
                                          . #6#)
                                    (EXIT
                                     (LETT |result| (CONS |part| |result|)
                                           . #6#))))
                                  ('T
                                   (SEQ
                                    (LETT |z|
                                          (SPADCALL |m|
                                                    (SPADCALL |n| 0
                                                              (QREFELT $ 16))
                                                    (QREFELT $ 55))
                                          . #6#)
                                    (LETT |part|
                                          (VECTOR (CONS 3 "prime") |z| |exp|)
                                          . #6#)
                                    (LETT |z|
                                          (SPADCALL |z|
                                                    (PROG1
                                                        (LETT #1# |exp| . #6#)
                                                      (|check-subtype|
                                                       (>= #1# 0)
                                                       '(|NonNegativeInteger|)
                                                       #1#))
                                                    (QREFELT $ 36))
                                          . #6#)
                                    (LETT |m| (SPADCALL |m| |z| (QREFELT $ 54))
                                          . #6#)
                                    (EXIT
                                     (LETT |result| (CONS |part| |result|)
                                           . #6#)))))))
                           (LETT #3# (CDR #3#) . #6#) (GO G190) G191
                           (EXIT NIL))
                      (COND
                       ((NULL
                         (SPADCALL |m| (|spadConstant| $ 53) (QREFELT $ 47)))
                        (LETT |unity| (SPADCALL |unity| |m| (QREFELT $ 37))
                              . #6#)))
                      (EXIT
                       (SPADCALL |unity| |result| (QREFELT $ 44)))))))))))))) 

(DEFUN |GAUSSFAC;sumSquares;IL;8| (|p| $)
  (COND ((EQL |p| 2) (LIST 1 1))
        ((NULL (EQL (REMAINDER2 |p| 4) 1)) (|error| "no solutions"))
        ('T (|GAUSSFAC;sumsq1| |p| $)))) 

(DEFUN |GAUSSFAC;prime?;CB;9| (|a| $)
  (PROG (|p| |im| |re| |n|)
    (RETURN
     (SEQ
      (LETT |n| (SPADCALL |a| (QREFELT $ 58)) . #1=(|GAUSSFAC;prime?;CB;9|))
      (EXIT
       (COND ((OR (EQL |n| 0) (EQL |n| 1)) 'NIL)
             ((SPADCALL |n| (QREFELT $ 60)) 'T)
             ('T
              (SEQ (LETT |re| (SPADCALL |a| (QREFELT $ 49)) . #1#)
                   (LETT |im| (SPADCALL |a| (QREFELT $ 50)) . #1#)
                   (COND
                    ((NULL (EQL |re| 0))
                     (COND ((NULL (EQL |im| 0)) (EXIT 'NIL)))))
                   (LETT |p| (ABS (+ |re| |im|)) . #1#)
                   (COND ((NULL (EQL (REMAINDER2 |p| 4) 3)) (EXIT 'NIL)))
                   (EXIT (SPADCALL |p| (QREFELT $ 60))))))))))) 

(DEFUN |GaussianFactorizationPackage| #1=()
  (PROG #1#
    (RETURN
     (PROG (#2=#:G757)
       (RETURN
        (COND
         ((LETT #2# (HGET |$ConstructorCache| '|GaussianFactorizationPackage|)
                . #3=(|GaussianFactorizationPackage|))
          (|CDRwithIncrement| (CDAR #2#)))
         ('T
          (UNWIND-PROTECT
              (PROG1
                  (CDDAR
                   (HPUT |$ConstructorCache| '|GaussianFactorizationPackage|
                         (LIST
                          (CONS NIL
                                (CONS 1 (|GaussianFactorizationPackage;|))))))
                (LETT #2# T . #3#))
            (COND
             ((NOT #2#)
              (HREM |$ConstructorCache|
                    '|GaussianFactorizationPackage|))))))))))) 

(DEFUN |GaussianFactorizationPackage;| ()
  (PROG (|dv$| $ |pv$|)
    (RETURN
     (PROGN
      (LETT |dv$| '(|GaussianFactorizationPackage|)
            . #1=(|GaussianFactorizationPackage|))
      (LETT $ (GETREFV 62) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|haddProp| |$ConstructorCache| '|GaussianFactorizationPackage| NIL
                  (CONS 1 $))
      (|stuffDomainSlots| $)
      (QSETREFV $ 13
                (|ModularRing| (|Integer|) (|Integer|)
                               (CONS (|function| |GAUSSFAC;reduction|) $)
                               (CONS (|function| |GAUSSFAC;merge|) $)
                               (CONS (|function| |GAUSSFAC;exactquo|) $)))
      (QSETREFV $ 17 (SPADCALL 1 1 (QREFELT $ 16)))
      $)))) 

(MAKEPROP '|GaussianFactorizationPackage| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL (|Integer|) (0 . |positiveRemainder|)
              (|Union| $ '"failed") (6 . |exquo|)
              (|Record| (|:| |coef1| $) (|:| |coef2| $)) (|Union| 10 '"failed")
              (12 . |extendedEuclidean|) '|FMod| (19 . |One|) (|Complex| 6)
              (23 . |complex|) '|fact2| (29 . |reduce|) (|Boolean|) (35 . =)
              (|NonNegativeInteger|) (41 . ^) (|PositiveInteger|) (47 . ^)
              (53 . |coerce|) (58 . ^) (|Factored| 6)
              (|IntegerFactorizationPackage| 6) (64 . |factor|) (69 . |unit|)
              (|Union| '"nil" '"sqfr" '"irred" '"prime")
              (|Record| (|:| |flg| 31) (|:| |fctr| 6) (|:| |xpnt| 6))
              (|List| 32) (74 . |factorList|) (79 . *) (85 . ^) (91 . *)
              (|List| 6) (97 . |elt|) (103 . |conjugate|)
              (|Record| (|:| |flg| 31) (|:| |fctr| 15) (|:| |xpnt| 6))
              (|List| 41) (|Factored| 15) (108 . |makeFR|) (114 . |Zero|)
              (118 . |Zero|) (122 . =) (128 . |primeFactor|) (134 . |real|)
              (139 . |imag|) (144 . |unit|) (149 . |factorList|) (154 . |One|)
              (158 . |quo|) (164 . |gcd|) |GAUSSFAC;factor;CF;7|
              |GAUSSFAC;sumSquares;IL;8| (170 . |norm|)
              (|IntegerPrimesPackage| 6) (175 . |prime?|)
              |GAUSSFAC;prime?;CB;9|)
           '#(|sumSquares| 180 |prime?| 185 |factor| 190) 'NIL
           (CONS (|makeByteWordVec2| 1 'NIL)
                 (CONS '#()
                       (CONS '#()
                             (|makeByteWordVec2| 61
                                                 '(2 6 0 0 0 7 2 6 8 0 0 9 3 6
                                                   11 0 0 0 12 0 13 0 14 2 15 0
                                                   6 6 16 2 13 0 6 6 18 2 13 19
                                                   0 0 20 2 13 0 0 21 22 2 13 0
                                                   0 23 24 1 13 6 0 25 2 6 0 0
                                                   23 26 1 28 27 6 29 1 27 6 0
                                                   30 1 27 33 0 34 2 6 0 23 0
                                                   35 2 15 0 0 21 36 2 15 0 0 0
                                                   37 2 38 6 0 6 39 1 15 0 0 40
                                                   2 43 0 15 42 44 0 13 0 45 0
                                                   15 0 46 2 15 19 0 0 47 2 43
                                                   0 15 6 48 1 15 6 0 49 1 15 6
                                                   0 50 1 43 15 0 51 1 43 42 0
                                                   52 0 15 0 53 2 15 0 0 0 54 2
                                                   15 0 0 0 55 1 15 6 0 58 1 59
                                                   19 6 60 1 0 38 6 57 1 0 19
                                                   15 61 1 0 43 15 56)))))
           '|lookupComplete|)) 

(MAKEPROP '|GaussianFactorizationPackage| 'NILADIC T) 
