
(/VERSIONCHECK 2) 

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

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

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

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

(DEFUN |IBATOOL;idealiserMatrix;3M;5| (|ideal| |idealinv| $)
  (PROG (|n| |bigm| |mr| |mc| |v| |i| #0=#:G1858 |r| |m| |j| #1=#:G1859
             |k| #2=#:G1860)
    (RETURN
      (SEQ (LETT |n| (SPADCALL (QREFELT $ 32))
                 . #3=(|IBATOOL;idealiserMatrix;3M;5|))
           (LETT |bigm|
                 (SPADCALL (* |n| |n|) |n| (QREFELT $ 33)) . #3#)
           (LETT |mr| (SPADCALL |bigm| (QREFELT $ 12)) . #3#)
           (LETT |mc| (SPADCALL |bigm| (QREFELT $ 14)) . #3#)
           (LETT |v| (SPADCALL (QREFELT $ 35)) . #3#)
           (SEQ (LETT |i| 0 . #3#) (LETT #0# (- |n| 1) . #3#) G190
                (COND ((QSGREATERP |i| #0#) #4=(GO G191)))
                (SEQ (LETT |r|
                           (SPADCALL
                               (SPADCALL |v|
                                   (+ |i|
                                    (SPADCALL |v| (QREFELT $ 37)))
                                   (QREFELT $ 38))
                               (QREFELT $ 39)) . #3#)
                     (LETT |m|
                           (SPADCALL
                               (SPADCALL |ideal| |r| (QREFELT $ 40))
                               |idealinv| (QREFELT $ 40)) . #3#)
                     (EXIT (SEQ (LETT |j| 0 . #3#)
                                (LETT #1# (- |n| 1) . #3#) G190
                                (COND ((QSGREATERP |j| #1#) #4#))
                                (SEQ (EXIT
                                      (SEQ (LETT |k| 0 . #3#)
                                       (LETT #2# (- |n| 1) . #3#) G190
                                       (COND
                                         ((QSGREATERP |k| #2#) #4#))
                                       (SEQ
                                        (EXIT
                                         (SPADCALL |bigm|
                                          (+ (+ (* |j| |n|) |k|) |mr|)
                                          (+ |i| |mc|)
                                          (SPADCALL |m| (+ |j| |mr|)
                                           (+ |k| |mc|) (QREFELT $ 16))
                                          (QREFELT $ 41))))
                                       (LETT |k| (QSADD1 |k|) . #3#)
                                       #5=(GO G190) G191 (EXIT NIL))))
                                (LETT |j| (QSADD1 |j|) . #3#) #5# G191
                                (EXIT NIL))))
                (LETT |i| (QSADD1 |i|) . #3#) #5# 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 (#0=#:G1864 |bigm|)
    (RETURN
      (SEQ (LETT |bigm|
                 (PROG2 (LETT #0#
                              (SPADCALL
                                  (SPADCALL |ideal| |idealinv|
                                      (QREFELT $ 42))
                                  |denom| (QREFELT $ 48))
                              . #1=(|IBATOOL;idealiser;2MRM;7|))
                        (QCDR #0#)
                   (|check-union| (QEQCAR #0# 0)
                       (|Matrix| (QREFELT $ 6)) #0#)) . #1#)
           (EXIT (SPADCALL
                     (SPADCALL (SPADCALL |bigm| |denom| (QREFELT $ 49))
                         (QREFELT $ 45))
                     (QREFELT $ 46))))))) 

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

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

(DEFUN |IntegralBasisTools;| (|#1| |#2| |#3|)
  (PROG (DV$1 DV$2 DV$3 |dv$| $ |pv$|)
    (RETURN
      (PROGN
        (LETT DV$1 (|devaluate| |#1|) . #0=(|IntegralBasisTools|))
        (LETT DV$2 (|devaluate| |#2|) . #0#)
        (LETT DV$3 (|devaluate| |#3|) . #0#)
        (LETT |dv$| (LIST '|IntegralBasisTools| DV$1 DV$2 DV$3) . #0#)
        (LETT $ (GETREFV 61) . #0#)
        (QSETREFV $ 0 |dv$|)
        (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #0#))
        (|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|)) 
