
(/VERSIONCHECK 2) 

(DEFUN |IBATOOL;diagonalProduct;MR;1| (|m| $)
  (PROG (|ans| #1=#:G675 |i| #2=#:G676 |j|)
    (RETURN
     (SEQ
      (LETT |ans| (|spadConstant| $ 9) . #3=(|IBATOOL;diagonalProduct;MR;1|))
      (SEQ (LETT |j| (SPADCALL |m| (QREFELT $ 14)) . #3#)
           (LETT #2# (SPADCALL |m| (QREFELT $ 15)) . #3#)
           (LETT |i| (SPADCALL |m| (QREFELT $ 12)) . #3#)
           (LETT #1# (SPADCALL |m| (QREFELT $ 13)) . #3#) G190
           (COND ((OR (> |i| #1#) (> |j| #2#)) (GO G191)))
           (SEQ
            (EXIT
             (LETT |ans|
                   (SPADCALL |ans| (SPADCALL |m| |i| |j| (QREFELT $ 16))
                             (QREFELT $ 17))
                   . #3#)))
           (LETT |i| (PROG1 (+ |i| 1) (LETT |j| (+ |j| 1) . #3#)) . #3#)
           (GO G190) G191 (EXIT NIL))
      (EXIT |ans|))))) 

(DEFUN |IBATOOL;matrixGcd;MRNniR;2| (|mat| |sing| |n| $)
  (PROG (#1=#:G682 |d| |mij| |j| |i|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ (LETT |d| |sing| . #2=(|IBATOOL;matrixGcd;MRNniR;2|))
            (SEQ (LETT |i| 1 . #2#) G190
                 (COND ((QSGREATERP |i| |n|) #3=(GO G191)))
                 (SEQ
                  (EXIT
                   (SEQ (LETT |j| |i| . #2#) G190 (COND ((> |j| |n|) #3#))
                        (SEQ
                         (COND
                          ((NULL
                            (SPADCALL
                             (LETT |mij|
                                   (SPADCALL |mat| |i| |j| (QREFELT $ 16))
                                   . #2#)
                             (QREFELT $ 20)))
                           (LETT |d| (SPADCALL |d| |mij| (QREFELT $ 21))
                                 . #2#)))
                         (EXIT
                          (COND
                           ((SPADCALL |d| (|spadConstant| $ 9) (QREFELT $ 23))
                            (PROGN (LETT #1# |d| . #2#) (GO #1#))))))
                        (LETT |j| (+ |j| 1) . #2#) #4=(GO G190) G191
                        (EXIT NIL))))
                 (LETT |i| (QSADD1 |i|) . #2#) #4# G191 (EXIT NIL))
            (EXIT |d|)))
      #1# (EXIT #1#))))) 

(DEFUN |IBATOOL;divideIfCan!;2MRIR;3| (|matrix| |matrixOut| |prime| |n| $)
  (PROG (#1=#:G693 |a| |j| |i|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (SEQ (LETT |i| 1 . #2=(|IBATOOL;divideIfCan!;2MRIR;3|)) G190
             (COND ((QSGREATERP |i| |n|) #3=(GO G191)))
             (SEQ
              (EXIT
               (SEQ (LETT |j| |i| . #2#) G190 (COND ((> |j| |n|) #3#))
                    (SEQ
                     (LETT |a|
                           (SPADCALL (SPADCALL |matrix| |i| |j| (QREFELT $ 16))
                                     |prime| (QREFELT $ 27))
                           . #2#)
                     (EXIT
                      (COND
                       ((QEQCAR |a| 1)
                        (PROGN (LETT #1# |prime| . #2#) (GO #1#)))
                       ('T
                        (SPADCALL |matrixOut| |i| |j| (QCDR |a|)
                                  (QREFELT $ 28))))))
                    (LETT |j| (+ |j| 1) . #2#) #4=(GO G190) G191 (EXIT NIL))))
             (LETT |i| (QSADD1 |i|) . #2#) #4# G191 (EXIT NIL))
        (EXIT (|spadConstant| $ 9))))
      #1# (EXIT #1#))))) 

(DEFUN |IBATOOL;leastPower;3Nni;4| (|p| |n| $)
  (PROG (|q| |e|)
    (RETURN
     (SEQ (LETT |e| 1 . #1=(|IBATOOL;leastPower;3Nni;4|)) (LETT |q| |p| . #1#)
          (SEQ G190 (COND ((NULL (< |q| |n|)) (GO G191)))
               (SEQ (LETT |e| (+ |e| 1) . #1#)
                    (EXIT (LETT |q| (* |q| |p|) . #1#)))
               NIL (GO G190) G191 (EXIT NIL))
          (EXIT |e|))))) 

(DEFUN |IBATOOL;idealiserMatrix;3M;5| (|ideal| |idealinv| $)
  (PROG (#1=#:G706 |k| #2=#:G705 |j| |m| |r| #3=#:G704 |i| |v| |mc| |mr| |bigm|
         |n|)
    (RETURN
     (SEQ
      (LETT |n| (SPADCALL (QREFELT $ 32))
            . #4=(|IBATOOL;idealiserMatrix;3M;5|))
      (LETT |bigm| (SPADCALL (* |n| |n|) |n| (QREFELT $ 33)) . #4#)
      (LETT |mr| (SPADCALL |bigm| (QREFELT $ 12)) . #4#)
      (LETT |mc| (SPADCALL |bigm| (QREFELT $ 14)) . #4#)
      (LETT |v| (SPADCALL (QREFELT $ 35)) . #4#)
      (SEQ (LETT |i| 0 . #4#) (LETT #3# (- |n| 1) . #4#) G190
           (COND ((QSGREATERP |i| #3#) #5=(GO G191)))
           (SEQ
            (LETT |r|
                  (SPADCALL
                   (SPADCALL |v| (+ |i| (SPADCALL |v| (QREFELT $ 37)))
                             (QREFELT $ 38))
                   (QREFELT $ 39))
                  . #4#)
            (LETT |m|
                  (SPADCALL (SPADCALL |ideal| |r| (QREFELT $ 40)) |idealinv|
                            (QREFELT $ 40))
                  . #4#)
            (EXIT
             (SEQ (LETT |j| 0 . #4#) (LETT #2# (- |n| 1) . #4#) G190
                  (COND ((QSGREATERP |j| #2#) #5#))
                  (SEQ
                   (EXIT
                    (SEQ (LETT |k| 0 . #4#) (LETT #1# (- |n| 1) . #4#) G190
                         (COND ((QSGREATERP |k| #1#) #5#))
                         (SEQ
                          (EXIT
                           (SPADCALL |bigm| (+ (+ (* |j| |n|) |k|) |mr|)
                                     (+ |i| |mc|)
                                     (SPADCALL |m| (+ |j| |mr|) (+ |k| |mc|)
                                               (QREFELT $ 16))
                                     (QREFELT $ 41))))
                         (LETT |k| (QSADD1 |k|) . #4#) #6=(GO G190) G191
                         (EXIT NIL))))
                  (LETT |j| (QSADD1 |j|) . #4#) #6# G191 (EXIT NIL))))
           (LETT |i| (QSADD1 |i|) . #4#) #6# G191 (EXIT NIL))
      (EXIT |bigm|))))) 

(DEFUN |IBATOOL;idealiser;3M;6| (|ideal| |idealinv| $)
  (PROG (|bigm|)
    (RETURN
     (SEQ
      (LETT |bigm| (SPADCALL |ideal| |idealinv| (QREFELT $ 42))
            |IBATOOL;idealiser;3M;6|)
      (EXIT
       (SPADCALL (SPADCALL (SPADCALL |bigm| (QREFELT $ 44)) (QREFELT $ 45))
                 (QREFELT $ 46))))))) 

(DEFUN |IBATOOL;idealiser;2MRM;7| (|ideal| |idealinv| |denom| $)
  (PROG (|bigm| #1=#:G710)
    (RETURN
     (SEQ
      (LETT |bigm|
            (PROG2
                (LETT #1#
                      (SPADCALL (SPADCALL |ideal| |idealinv| (QREFELT $ 42))
                                |denom| (QREFELT $ 48))
                      . #2=(|IBATOOL;idealiser;2MRM;7|))
                (QCDR #1#)
              (|check-union| (QEQCAR #1# 0) (|Matrix| (QREFELT $ 6)) #1#))
            . #2#)
      (EXIT
       (SPADCALL
        (SPADCALL (SPADCALL |bigm| |denom| (QREFELT $ 49)) (QREFELT $ 45))
        (QREFELT $ 46))))))) 

(DEFUN |IBATOOL;moduleSum;3R;8| (|mod1| |mod2| $)
  (PROG (|rbinv| |rb| |c2| |c1| |den| |n| |rbinv2| |rbden2| |rb2| |rbinv1|
         |rbden1| |rb1|)
    (RETURN
     (SEQ (LETT |rb1| (QVELT |mod1| 0) . #1=(|IBATOOL;moduleSum;3R;8|))
          (LETT |rbden1| (QVELT |mod1| 1) . #1#)
          (LETT |rbinv1| (QVELT |mod1| 2) . #1#)
          (LETT |rb2| (QVELT |mod2| 0) . #1#)
          (LETT |rbden2| (QVELT |mod2| 1) . #1#)
          (LETT |rbinv2| (QVELT |mod2| 2) . #1#)
          (COND
           ((SPADCALL |rb1| (QREFELT $ 51))
            (COND
             ((SPADCALL |rbinv1| (QREFELT $ 51))
              (COND
               ((SPADCALL |rb2| (QREFELT $ 51))
                (COND
                 ((NULL (SPADCALL |rbinv2| (QREFELT $ 51)))
                  (EXIT (|error| #2="moduleSum: matrices must be square")))))
               (#3='T (EXIT (|error| #2#)))))
             (#3# (EXIT (|error| #2#)))))
           (#3# (EXIT (|error| #2#))))
          (COND
           ((EQL (LETT |n| (SPADCALL |rb1| (QREFELT $ 52)) . #1#)
                 (SPADCALL |rbinv1| (QREFELT $ 52)))
            (COND
             ((EQL |n| (SPADCALL |rb2| (QREFELT $ 52)))
              (COND
               ((NULL (EQL |n| (SPADCALL |rbinv2| (QREFELT $ 52))))
                (EXIT
                 (|error|
                  #4="moduleSum: matrices of imcompatible dimensions")))))
             (#3# (EXIT (|error| #4#)))))
           (#3# (EXIT (|error| #4#))))
          (COND
           ((OR (SPADCALL |rbden1| (QREFELT $ 20))
                (SPADCALL |rbden2| (QREFELT $ 20)))
            (EXIT (|error| "moduleSum: denominator must be non-zero"))))
          (LETT |den| (SPADCALL |rbden1| |rbden2| (QREFELT $ 53)) . #1#)
          (LETT |c1| (SPADCALL |den| |rbden1| (QREFELT $ 54)) . #1#)
          (LETT |c2| (SPADCALL |den| |rbden2| (QREFELT $ 54)) . #1#)
          (LETT |rb|
                (SPADCALL
                 (SPADCALL
                  (SPADCALL (SPADCALL |c1| |rb1| (QREFELT $ 55))
                            (SPADCALL |c2| |rb2| (QREFELT $ 55))
                            (QREFELT $ 56))
                  |den| (QREFELT $ 49))
                 (QREFELT $ 45))
                . #1#)
          (LETT |rbinv| (SPADCALL |rb| |den| (QREFELT $ 58)) . #1#)
          (EXIT (VECTOR |rb| |den| |rbinv|)))))) 

(DEFUN |IntegralBasisTools| (&REST #1=#:G727)
  (PROG ()
    (RETURN
     (PROG (#2=#:G728)
       (RETURN
        (COND
         ((LETT #2#
                (|lassocShiftWithFunction| (|devaluateList| #1#)
                                           (HGET |$ConstructorCache|
                                                 '|IntegralBasisTools|)
                                           '|domainEqualList|)
                . #3=(|IntegralBasisTools|))
          (|CDRwithIncrement| #2#))
         ('T
          (UNWIND-PROTECT
              (PROG1 (APPLY (|function| |IntegralBasisTools;|) #1#)
                (LETT #2# T . #3#))
            (COND
             ((NOT #2#)
              (HREM |$ConstructorCache| '|IntegralBasisTools|))))))))))) 

(DEFUN |IntegralBasisTools;| (|#1| |#2| |#3|)
  (PROG (|pv$| $ |dv$| DV$3 DV$2 DV$1)
    (RETURN
     (PROGN
      (LETT DV$1 (|devaluate| |#1|) . #1=(|IntegralBasisTools|))
      (LETT DV$2 (|devaluate| |#2|) . #1#)
      (LETT DV$3 (|devaluate| |#3|) . #1#)
      (LETT |dv$| (LIST '|IntegralBasisTools| DV$1 DV$2 DV$3) . #1#)
      (LETT $ (GETREFV 61) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|haddProp| |$ConstructorCache| '|IntegralBasisTools|
                  (LIST DV$1 DV$2 DV$3) (CONS 1 $))
      (|stuffDomainSlots| $)
      (QSETREFV $ 6 |#1|)
      (QSETREFV $ 7 |#2|)
      (QSETREFV $ 8 |#3|)
      $)))) 

(MAKEPROP '|IntegralBasisTools| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) (|local| |#2|)
              (|local| |#3|) (0 . |One|) (|Integer|) (|Matrix| 6)
              (4 . |minRowIndex|) (9 . |maxRowIndex|) (14 . |minColIndex|)
              (19 . |maxColIndex|) (24 . |qelt|) (31 . *)
              |IBATOOL;diagonalProduct;MR;1| (|Boolean|) (37 . |zero?|)
              (42 . |gcd|) (48 . |One|) (52 . =) (|NonNegativeInteger|)
              |IBATOOL;matrixGcd;MRNniR;2| (|Union| $ '"failed") (58 . |exquo|)
              (64 . |qsetelt!|) |IBATOOL;divideIfCan!;2MRIR;3|
              |IBATOOL;leastPower;3Nni;4| (|PositiveInteger|) (72 . |rank|)
              (76 . |zero|) (|Vector| $) (82 . |basis|) (|Vector| 8)
              (86 . |minIndex|) (91 . |qelt|) (97 . |regularRepresentation|)
              (102 . *) (108 . |setelt|) |IBATOOL;idealiserMatrix;3M;5|
              (|ModularHermitianRowReduction| 6) (116 . |rowEch|)
              (121 . |squareTop|) (126 . |transpose|) |IBATOOL;idealiser;3M;6|
              (131 . |exquo|) (137 . |rowEchelon|) |IBATOOL;idealiser;2MRM;7|
              (143 . |square?|) (148 . |nrows|) (153 . |lcm|) (159 . |quo|)
              (165 . *) (171 . |vertConcat|)
              (|TriangularMatrixOperations| 6 (|Vector| 6) (|Vector| 6) 11)
              (177 . |UpTriBddDenomInv|)
              (|Record| (|:| |basis| 11) (|:| |basisDen| 6)
                        (|:| |basisInv| 11))
              |IBATOOL;moduleSum;3R;8|)
           '#(|moduleSum| 183 |matrixGcd| 189 |leastPower| 196
              |idealiserMatrix| 202 |idealiser| 208 |divideIfCan!| 221
              |diagonalProduct| 229)
           'NIL
           (CONS (|makeByteWordVec2| 1 'NIL)
                 (CONS '#()
                       (CONS '#()
                             (|makeByteWordVec2| 60
                                                 '(0 6 0 9 1 11 10 0 12 1 11 10
                                                   0 13 1 11 10 0 14 1 11 10 0
                                                   15 3 11 6 0 10 10 16 2 6 0 0
                                                   0 17 1 6 19 0 20 2 6 0 0 0
                                                   21 0 7 0 22 2 6 19 0 0 23 2
                                                   6 26 0 0 27 4 11 6 0 10 10 6
                                                   28 0 8 31 32 2 11 0 24 24 33
                                                   0 8 34 35 1 36 10 0 37 2 36
                                                   8 0 10 38 1 8 11 0 39 2 11 0
                                                   0 0 40 4 11 6 0 10 10 6 41 1
                                                   43 11 11 44 1 11 0 0 45 1 11
                                                   0 0 46 2 11 26 0 6 48 2 43
                                                   11 11 6 49 1 11 19 0 51 1 11
                                                   24 0 52 2 6 0 0 0 53 2 6 0 0
                                                   0 54 2 11 0 6 0 55 2 11 0 0
                                                   0 56 2 57 11 11 6 58 2 0 59
                                                   59 59 60 3 0 6 11 6 24 25 2
                                                   0 24 24 24 30 2 0 11 11 11
                                                   42 3 0 11 11 11 6 50 2 0 11
                                                   11 11 47 4 0 6 11 11 6 10 29
                                                   1 0 6 11 18)))))
           '|lookupComplete|)) 
