
(/VERSIONCHECK 2) 

(DEFUN |CARTEN;sample;$;1| ($) (SPADCALL (QREFELT $ 16))) 

(DEFUN |CARTEN;int2index| (|n| |indv| $)
  (PROG (|qr| |i| |rnk|)
    (RETURN
     (SEQ
      (COND ((< |n| 0) (|error| "Index error (too small)"))
            (#1='T
             (SEQ (LETT |rnk| (QVSIZE |indv|) . #2=(|CARTEN;int2index|))
                  (SEQ (LETT |i| 1 . #2#) G190
                       (COND ((QSGREATERP |i| |rnk|) (GO G191)))
                       (SEQ (LETT |qr| (DIVIDE2 |n| (QREFELT $ 7)) . #2#)
                            (LETT |n| (QCAR |qr|) . #2#)
                            (EXIT
                             (SPADCALL |indv| (+ (- |rnk| |i|) 1)
                                       (+ (QCDR |qr|) (QREFELT $ 6))
                                       (QREFELT $ 20))))
                       (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191 (EXIT NIL))
                  (EXIT
                   (COND ((EQL |n| 0) |indv|)
                         (#1# (|error| "Index error (too big)"))))))))))) 

(DEFUN |CARTEN;index2int| (|indv| $)
  (PROG (|n| |ix| #1=#:G696 |i|)
    (RETURN
     (SEQ (LETT |n| 0 . #2=(|CARTEN;index2int|))
          (SEQ (LETT |i| 1 . #2#) (LETT #1# (QVSIZE |indv|) . #2#) G190
               (COND ((QSGREATERP |i| #1#) (GO G191)))
               (SEQ
                (LETT |ix|
                      (- (SPADCALL |indv| |i| (QREFELT $ 21)) (QREFELT $ 6))
                      . #2#)
                (COND
                 ((OR (< |ix| 0) (< (- (QREFELT $ 7) 1) |ix|))
                  (EXIT (|error| "Index error (out of range)"))))
                (EXIT
                 (LETT |n| (+ (SPADCALL (QREFELT $ 7) |n| (QREFELT $ 22)) |ix|)
                       . #2#)))
               (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191 (EXIT NIL))
          (EXIT |n|))))) 

(DEFUN |CARTEN;lengthRankOrElse| (|v| $)
  (PROG (|rx| |qr|)
    (RETURN
     (SEQ
      (COND ((EQL |v| 1) 0) ((EQL |v| (QREFELT $ 7)) 1)
            ((EQL |v| (QREFELT $ 13)) 2) ((EQL |v| (QREFELT $ 14)) 3)
            ((EQL |v| (QREFELT $ 15)) 4)
            ('T
             (SEQ (LETT |rx| 0 . #1=(|CARTEN;lengthRankOrElse|))
                  (SEQ G190
                       (COND
                        ((NULL (COND ((EQL |v| 0) 'NIL) ('T 'T))) (GO G191)))
                       (SEQ (LETT |qr| (DIVIDE2 |v| (QREFELT $ 7)) . #1#)
                            (LETT |v| (QCAR |qr|) . #1#)
                            (EXIT
                             (COND
                              ((NULL (EQL |v| 0))
                               (COND
                                ((NULL (EQL (QCDR |qr|) 0))
                                 (|error| "Rank is not a whole number"))
                                ('T (LETT |rx| (+ |rx| 1) . #1#)))))))
                       NIL (GO G190) G191 (EXIT NIL))
                  (EXIT |rx|)))))))) 

(DEFUN |CARTEN;mkPerm| (|n| |l| $)
  (PROG (#1=#:G708 |e| |i| #2=#:G711 |seen| |p|)
    (RETURN
     (SEQ
      (COND
       ((NULL (EQL (LENGTH |l|) |n|))
        (|error| "The list is not a permutation."))
       ('T
        (SEQ (LETT |p| (SPADCALL |n| 0 (QREFELT $ 23)) . #3=(|CARTEN;mkPerm|))
             (LETT |seen| (SPADCALL |n| 'NIL (QREFELT $ 26)) . #3#)
             (SEQ (LETT |e| NIL . #3#) (LETT #2# |l| . #3#) (LETT |i| 1 . #3#)
                  G190
                  (COND
                   ((OR (QSGREATERP |i| |n|) (ATOM #2#)
                        (PROGN (LETT |e| (CAR #2#) . #3#) NIL))
                    #4=(GO G191)))
                  (SEQ
                   (EXIT
                    (COND
                     ((OR (< |e| 1) (< |n| |e|))
                      (|error| "The list is not a permutation."))
                     ('T
                      (SEQ (SPADCALL |p| |i| |e| (QREFELT $ 20))
                           (EXIT (SPADCALL |seen| |e| 'T (QREFELT $ 27))))))))
                  (LETT |i| (PROG1 (QSADD1 |i|) (LETT #2# (CDR #2#) . #3#))
                        . #3#)
                  #5=(GO G190) G191 (EXIT NIL))
             (SEQ
              (EXIT
               (SEQ (LETT |e| 1 . #3#) G190 (COND ((QSGREATERP |e| |n|) #4#))
                    (SEQ
                     (EXIT
                      (COND
                       ((NULL (SPADCALL |seen| |e| (QREFELT $ 28)))
                        (PROGN
                         (LETT #1# (|error| "The list is not a permutation.")
                               . #3#)
                         (GO #1#))))))
                    (LETT |e| (QSADD1 |e|) . #3#) #5# G191 (EXIT NIL)))
              #1# (EXIT #1#))
             (EXIT |p|)))))))) 

(DEFUN |CARTEN;permute!| (|t| |s| |p| $)
  (PROG (#1=#:G715 |i|)
    (RETURN
     (SEQ
      (SEQ (LETT |i| 1 . #2=(|CARTEN;permute!|)) (LETT #1# (QVSIZE |p|) . #2#)
           G190 (COND ((QSGREATERP |i| #1#) (GO G191)))
           (SEQ
            (EXIT
             (SPADCALL |t| |i|
                       (SPADCALL |s| (SPADCALL |p| |i| (QREFELT $ 21))
                                 (QREFELT $ 21))
                       (QREFELT $ 20))))
           (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191 (EXIT NIL))
      (EXIT |t|))))) 

(DEFUN |CARTEN;permsign!| (|v| $)
  (PROG (#1=#:G732 #2=#:G736 |i| |totTrans| |e| |nTrans| #3=#:G734 #4=#:G735
         |j| |n| #5=#:G733 |psum| #6=#:G720 |maxix|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (LETT |maxix| (- (+ (QREFELT $ 6) (QVSIZE |v|)) 1)
              . #7=(|CARTEN;permsign!|))
        (LETT |psum|
              (PROG2
                  (LETT #6#
                        (SPADCALL
                         (- (* (+ |maxix| 1) |maxix|)
                            (* (QREFELT $ 6) (- (QREFELT $ 6) 1)))
                         2 (QREFELT $ 30))
                        . #7#)
                  (QCDR #6#)
                (|check-union| (QEQCAR #6# 0) (|Integer|) #6#))
              . #7#)
        (LETT |n| 0 . #7#)
        (SEQ (LETT |i| 1 . #7#) (LETT #5# (QVSIZE |v|) . #7#) G190
             (COND ((QSGREATERP |i| #5#) #8=(GO G191)))
             (SEQ
              (EXIT
               (LETT |n| (+ |n| (SPADCALL |v| |i| (QREFELT $ 21))) . #7#)))
             (LETT |i| (QSADD1 |i|) . #7#) #9=(GO G190) G191 (EXIT NIL))
        (EXIT
         (COND
          ((EQL |n| |psum|)
           (SEQ (LETT |totTrans| 0 . #7#) (LETT |nTrans| 1 . #7#)
                (SEQ G190
                     (COND ((NULL (COND ((EQL |nTrans| 0) 'NIL) ('T 'T))) #8#))
                     (SEQ (LETT |nTrans| 0 . #7#)
                          (SEQ (LETT |j| 2 . #7#) (LETT #4# (QVSIZE |v|) . #7#)
                               (LETT |i| 1 . #7#)
                               (LETT #3# (- (QVSIZE |v|) 1) . #7#) G190
                               (COND
                                ((OR (QSGREATERP |i| #3#) (QSGREATERP |j| #4#))
                                 #8#))
                               (SEQ
                                (EXIT
                                 (COND
                                  ((< (SPADCALL |v| |j| (QREFELT $ 21))
                                      (SPADCALL |v| |i| (QREFELT $ 21)))
                                   (SEQ (LETT |nTrans| (+ |nTrans| 1) . #7#)
                                        (LETT |e|
                                              (SPADCALL |v| |i| (QREFELT $ 21))
                                              . #7#)
                                        (SPADCALL |v| |i|
                                                  (SPADCALL |v| |j|
                                                            (QREFELT $ 21))
                                                  (QREFELT $ 20))
                                        (EXIT
                                         (SPADCALL |v| |j| |e|
                                                   (QREFELT $ 20))))))))
                               (LETT |i|
                                     (PROG1 (QSADD1 |i|)
                                       (LETT |j| (QSADD1 |j|) . #7#))
                                     . #7#)
                               #9# G191 (EXIT NIL))
                          (EXIT
                           (LETT |totTrans| (+ |totTrans| |nTrans|) . #7#)))
                     NIL #9# G191 (EXIT NIL))
                (SEQ (LETT |i| 1 . #7#) (LETT #2# (QREFELT $ 7) . #7#) G190
                     (COND ((QSGREATERP |i| #2#) #8#))
                     (SEQ
                      (EXIT
                       (COND
                        ((NULL
                          (EQL (SPADCALL |v| |i| (QREFELT $ 21))
                               (- (+ (QREFELT $ 6) |i|) 1)))
                         (PROGN (LETT #1# 0 . #7#) (GO #1#))))))
                     (LETT |i| (QSADD1 |i|) . #7#) #9# G191 (EXIT NIL))
                (EXIT (COND ((ODDP |totTrans|) -1) (#10='T 1)))))
          (#10# 0)))))
      #1# (EXIT #1#))))) 

(DEFUN |CARTEN;ravel;$L;8| (|x| $)
  (PROG (#1=#:G740 |i| #2=#:G739)
    (RETURN
     (SEQ
      (PROGN
       (LETT #2# NIL . #3=(|CARTEN;ravel;$L;8|))
       (SEQ (LETT |i| 0 . #3#)
            (LETT #1# (- (SPADCALL |x| (QREFELT $ 31)) 1) . #3#) G190
            (COND ((QSGREATERP |i| #1#) (GO G191)))
            (SEQ
             (EXIT
              (LETT #2# (CONS (SPADCALL |x| |i| (QREFELT $ 32)) #2#) . #3#)))
            (LETT |i| (QSADD1 |i|) . #3#) (GO G190) G191
            (EXIT (NREVERSE0 #2#)))))))) 

(DEFUN |CARTEN;unravel;L$;9| (|l| $)
  (PROG (#1=#:G744 |i| #2=#:G745 |r| |z| |nz|)
    (RETURN
     (SEQ (LETT |nz| (LENGTH |l|) . #3=(|CARTEN;unravel;L$;9|))
          (|CARTEN;lengthRankOrElse| |nz| $)
          (LETT |z| (SPADCALL |nz| (|spadConstant| $ 35) (QREFELT $ 36)) . #3#)
          (SEQ (LETT |r| NIL . #3#) (LETT #2# |l| . #3#) (LETT |i| 0 . #3#)
               (LETT #1# (- |nz| 1) . #3#) G190
               (COND
                ((OR (QSGREATERP |i| #1#) (ATOM #2#)
                     (PROGN (LETT |r| (CAR #2#) . #3#) NIL))
                 (GO G191)))
               (SEQ (EXIT (SPADCALL |z| |i| |r| (QREFELT $ 37))))
               (LETT |i| (PROG1 (QSADD1 |i|) (LETT #2# (CDR #2#) . #3#)) . #3#)
               (GO G190) G191 (EXIT NIL))
          (EXIT |z|))))) 

(DEFUN |CARTEN;kroneckerDelta;$;10| ($)
  (PROG (#1=#:G749 |i| #2=#:G750 |zi| |z|)
    (RETURN
     (SEQ
      (LETT |z| (SPADCALL (QREFELT $ 13) (|spadConstant| $ 35) (QREFELT $ 36))
            . #3=(|CARTEN;kroneckerDelta;$;10|))
      (SEQ (LETT |zi| 0 . #3#) (LETT #2# (+ (QREFELT $ 7) 1) . #3#)
           (LETT |i| 1 . #3#) (LETT #1# (QREFELT $ 7) . #3#) G190
           (COND ((QSGREATERP |i| #1#) (GO G191)))
           (SEQ
            (EXIT (SPADCALL |z| |zi| (|spadConstant| $ 39) (QREFELT $ 37))))
           (LETT |i| (PROG1 (QSADD1 |i|) (LETT |zi| (QSPLUS |zi| #2#) . #3#))
                 . #3#)
           (GO G190) G191 (EXIT NIL))
      (EXIT |z|))))) 

(DEFUN |CARTEN;leviCivitaSymbol;$;11| ($)
  (PROG (#1=#:G754 |i| |indv| |z| |nz|)
    (RETURN
     (SEQ
      (LETT |nz| (EXPT (QREFELT $ 7) (QREFELT $ 7))
            . #2=(|CARTEN;leviCivitaSymbol;$;11|))
      (LETT |z| (SPADCALL |nz| (|spadConstant| $ 35) (QREFELT $ 36)) . #2#)
      (LETT |indv| (SPADCALL (QREFELT $ 7) 0 (QREFELT $ 23)) . #2#)
      (SEQ (LETT |i| 0 . #2#) (LETT #1# (- |nz| 1) . #2#) G190
           (COND ((QSGREATERP |i| #1#) (GO G191)))
           (SEQ
            (EXIT
             (SPADCALL |z| |i|
                       (SPADCALL
                        (|CARTEN;permsign!| (|CARTEN;int2index| |i| |indv| $)
                         $)
                        (QREFELT $ 40))
                       (QREFELT $ 37))))
           (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191 (EXIT NIL))
      (EXIT |z|))))) 

(DEFUN |CARTEN;degree;$Nni;12| (|x| $) (SPADCALL |x| (QREFELT $ 42))) 

(DEFUN |CARTEN;rank;$Nni;13| (|x| $)
  (PROG (|n|)
    (RETURN
     (SEQ (LETT |n| (SPADCALL |x| (QREFELT $ 31)) |CARTEN;rank;$Nni;13|)
          (EXIT (|CARTEN;lengthRankOrElse| |n| $)))))) 

(DEFUN |CARTEN;elt;$R;14| (|x| $)
  (COND
   ((NULL (EQL (SPADCALL |x| (QREFELT $ 31)) 1))
    (|error| "Index error (the rank is not 0)"))
   ('T (SPADCALL |x| 0 (QREFELT $ 32))))) 

(DEFUN |CARTEN;elt;$IR;15| (|x| |i| $)
  (COND
   ((NULL (EQL (SPADCALL |x| (QREFELT $ 31)) (QREFELT $ 7)))
    (|error| "Index error (the rank is not 1)"))
   ('T (SPADCALL |x| (- |i| (QREFELT $ 6)) (QREFELT $ 32))))) 

(DEFUN |CARTEN;elt;$2IR;16| (|x| |i| |j| $)
  (COND
   ((NULL (EQL (SPADCALL |x| (QREFELT $ 31)) (QREFELT $ 13)))
    (|error| "Index error (the rank is not 2)"))
   ('T
    (SPADCALL |x|
              (+ (SPADCALL (QREFELT $ 7) (- |i| (QREFELT $ 6)) (QREFELT $ 22))
                 (- |j| (QREFELT $ 6)))
              (QREFELT $ 32))))) 

(DEFUN |CARTEN;elt;$3IR;17| (|x| |i| |j| |k| $)
  (COND
   ((NULL (EQL (SPADCALL |x| (QREFELT $ 31)) (QREFELT $ 14)))
    (|error| "Index error (the rank is not 3)"))
   ('T
    (SPADCALL |x|
              (+
               (+
                (SPADCALL (QREFELT $ 13) (- |i| (QREFELT $ 6)) (QREFELT $ 22))
                (SPADCALL (QREFELT $ 7) (- |j| (QREFELT $ 6)) (QREFELT $ 22)))
               (- |k| (QREFELT $ 6)))
              (QREFELT $ 32))))) 

(DEFUN |CARTEN;elt;$4IR;18| (|x| |i| |j| |k| |l| $)
  (COND
   ((NULL (EQL (SPADCALL |x| (QREFELT $ 31)) (QREFELT $ 15)))
    (|error| "Index error (the rank is not 4)"))
   ('T
    (SPADCALL |x|
              (+
               (+
                (+
                 (SPADCALL (QREFELT $ 14) (- |i| (QREFELT $ 6)) (QREFELT $ 22))
                 (SPADCALL (QREFELT $ 13) (- |j| (QREFELT $ 6))
                           (QREFELT $ 22)))
                (SPADCALL (QREFELT $ 7) (- |k| (QREFELT $ 6)) (QREFELT $ 22)))
               (- |l| (QREFELT $ 6)))
              (QREFELT $ 32))))) 

(DEFUN |CARTEN;elt;$LR;19| (|x| |i| $)
  (PROG (|n| |ix| #1=#:G779 |ii|)
    (RETURN
     (SEQ
      (COND
       ((NULL (EQL (LENGTH |i|) (SPADCALL |x| (QREFELT $ 42))))
        (|error| "Index error (wrong rank)"))
       ('T
        (SEQ (LETT |n| 0 . #2=(|CARTEN;elt;$LR;19|))
             (SEQ (LETT |ii| NIL . #2#) (LETT #1# |i| . #2#) G190
                  (COND
                   ((OR (ATOM #1#) (PROGN (LETT |ii| (CAR #1#) . #2#) NIL))
                    (GO G191)))
                  (SEQ (LETT |ix| (- |ii| (QREFELT $ 6)) . #2#)
                       (COND
                        ((OR (< |ix| 0) (< (- (QREFELT $ 7) 1) |ix|))
                         (EXIT (|error| "Index error (out of range)"))))
                       (EXIT
                        (LETT |n|
                              (+ (SPADCALL (QREFELT $ 7) |n| (QREFELT $ 22))
                                 |ix|)
                              . #2#)))
                  (LETT #1# (CDR #1#) . #2#) (GO G190) G191 (EXIT NIL))
             (EXIT (SPADCALL |x| |n| (QREFELT $ 32)))))))))) 

(DEFUN |CARTEN;coerce;L$;20| (|lr| $)
  (PROG (#1=#:G784 |r| #2=#:G785 |i| |z|)
    (RETURN
     (SEQ
      (COND
       ((NULL (EQL (LENGTH |lr|) (QREFELT $ 7)))
        (|error| "Incorrect number of components"))
       ('T
        (SEQ
         (LETT |z|
               (SPADCALL (QREFELT $ 7) (|spadConstant| $ 35) (QREFELT $ 36))
               . #3=(|CARTEN;coerce;L$;20|))
         (SEQ (LETT |i| 0 . #3#) (LETT #2# (- (QREFELT $ 7) 1) . #3#)
              (LETT |r| NIL . #3#) (LETT #1# |lr| . #3#) G190
              (COND
               ((OR (ATOM #1#) (PROGN (LETT |r| (CAR #1#) . #3#) NIL)
                    (QSGREATERP |i| #2#))
                (GO G191)))
              (SEQ (EXIT (SPADCALL |z| |i| |r| (QREFELT $ 37))))
              (LETT #1# (PROG1 (CDR #1#) (LETT |i| (QSADD1 |i|) . #3#)) . #3#)
              (GO G190) G191 (EXIT NIL))
         (EXIT |z|)))))))) 

(DEFUN |CARTEN;coerce;L$;21| (|lx| $)
  (PROG (#1=#:G795 |i| #2=#:G794 |x| |offz| |z| |nx| #3=#:G788 #4=#:G793 |rx|)
    (RETURN
     (SEQ
      (COND
       ((NULL (EQL (SPADCALL |lx| (QREFELT $ 53)) (QREFELT $ 7)))
        (|error| "Incorrect number of slices"))
       ('T
        (SEQ
         (LETT |rx| (SPADCALL (SPADCALL |lx| (QREFELT $ 54)) (QREFELT $ 42))
               . #5=(|CARTEN;coerce;L$;21|))
         (SEQ
          (EXIT
           (SEQ (LETT |x| NIL . #5#) (LETT #4# |lx| . #5#) G190
                (COND
                 ((OR (ATOM #4#) (PROGN (LETT |x| (CAR #4#) . #5#) NIL))
                  #6=(GO G191)))
                (SEQ
                 (EXIT
                  (COND
                   ((NULL (EQL (SPADCALL |x| (QREFELT $ 42)) |rx|))
                    (PROGN
                     (LETT #3# (|error| "Inhomogeneous slice ranks") . #5#)
                     (GO #3#))))))
                (LETT #4# (CDR #4#) . #5#) #7=(GO G190) G191 (EXIT NIL)))
          #3# (EXIT #3#))
         (LETT |nx| (SPADCALL (SPADCALL |lx| (QREFELT $ 54)) (QREFELT $ 31))
               . #5#)
         (LETT |z|
               (SPADCALL (* (QREFELT $ 7) |nx|) (|spadConstant| $ 35)
                         (QREFELT $ 36))
               . #5#)
         (SEQ (LETT |offz| 0 . #5#) (LETT |x| NIL . #5#) (LETT #2# |lx| . #5#)
              G190
              (COND
               ((OR (ATOM #2#) (PROGN (LETT |x| (CAR #2#) . #5#) NIL)) #6#))
              (SEQ
               (EXIT
                (SEQ (LETT |i| 0 . #5#) (LETT #1# (- |nx| 1) . #5#) G190
                     (COND ((QSGREATERP |i| #1#) #6#))
                     (SEQ
                      (EXIT
                       (SPADCALL |z| (+ |offz| |i|)
                                 (SPADCALL |x| |i| (QREFELT $ 32))
                                 (QREFELT $ 37))))
                     (LETT |i| (QSADD1 |i|) . #5#) #7# G191 (EXIT NIL))))
              (LETT #2#
                    (PROG1 (CDR #2#) (LETT |offz| (QSPLUS |offz| |nx|) . #5#))
                    . #5#)
              #7# G191 (EXIT NIL))
         (EXIT |z|)))))))) 

(DEFUN |CARTEN;retractIfCan;$U;22| (|x| $)
  (COND
   ((ZEROP (SPADCALL |x| (QREFELT $ 42)))
    (CONS 0 (SPADCALL |x| (QREFELT $ 44))))
   ('T (CONS 1 "failed")))) 

(DEFUN |CARTEN;mkOutf| (|x| |i0| |rnk| $)
  (PROG (#1=#:G816 |j| #2=#:G815 #3=#:G814 |i| #4=#:G813 |nskip| |rnk1|
         #5=#:G812 #6=#:G811)
    (RETURN
     (SEQ
      (COND
       ((ODDP |rnk|)
        (SEQ (LETT |rnk1| (- |rnk| 1) . #7=(|CARTEN;mkOutf|))
             (LETT |nskip| (EXPT (QREFELT $ 7) |rnk1|) . #7#)
             (EXIT
              (SPADCALL
               (PROGN
                (LETT #6# NIL . #7#)
                (SEQ (LETT |i| 0 . #7#) (LETT #5# (- (QREFELT $ 7) 1) . #7#)
                     G190 (COND ((QSGREATERP |i| #5#) #8=(GO G191)))
                     (SEQ
                      (EXIT
                       (LETT #6#
                             (CONS
                              (|CARTEN;mkOutf| |x| (+ |i0| (* |nskip| |i|))
                               |rnk1| $)
                              #6#)
                             . #7#)))
                     (LETT |i| (QSADD1 |i|) . #7#) #9=(GO G190) G191
                     (EXIT (NREVERSE0 #6#))))
               (QREFELT $ 61)))))
       ((EQL |rnk| 0)
        (SPADCALL (SPADCALL |x| |i0| (QREFELT $ 32)) (QREFELT $ 62)))
       ('T
        (SEQ (LETT |rnk1| (- |rnk| 2) . #7#)
             (LETT |nskip| (EXPT (QREFELT $ 7) |rnk1|) . #7#)
             (EXIT
              (SPADCALL
               (PROGN
                (LETT #4# NIL . #7#)
                (SEQ (LETT |i| 0 . #7#) (LETT #3# (- (QREFELT $ 7) 1) . #7#)
                     G190 (COND ((QSGREATERP |i| #3#) #8#))
                     (SEQ
                      (EXIT
                       (LETT #4#
                             (CONS
                              (PROGN
                               (LETT #2# NIL . #7#)
                               (SEQ (LETT |j| 0 . #7#)
                                    (LETT #1# (- (QREFELT $ 7) 1) . #7#) G190
                                    (COND ((QSGREATERP |j| #1#) #8#))
                                    (SEQ
                                     (EXIT
                                      (LETT #2#
                                            (CONS
                                             (|CARTEN;mkOutf| |x|
                                              (+ |i0|
                                                 (* |nskip|
                                                    (+ (* (QREFELT $ 7) |i|)
                                                       |j|)))
                                              |rnk1| $)
                                             #2#)
                                            . #7#)))
                                    (LETT |j| (QSADD1 |j|) . #7#) #9# G191
                                    (EXIT (NREVERSE0 #2#))))
                              #4#)
                             . #7#)))
                     (LETT |i| (QSADD1 |i|) . #7#) #9# G191
                     (EXIT (NREVERSE0 #4#))))
               (QREFELT $ 64)))))))))) 

(DEFUN |CARTEN;coerce;$Of;24| (|x| $)
  (|CARTEN;mkOutf| |x| 0 (SPADCALL |x| (QREFELT $ 42)) $)) 

(DEFUN |CARTEN;Zero;$;25| ($) (SPADCALL (|spadConstant| $ 35) (QREFELT $ 66))) 

(DEFUN |CARTEN;One;$;26| ($) (SPADCALL (|spadConstant| $ 39) (QREFELT $ 66))) 

(DEFUN |CARTEN;coerce;R$;27| (|r| $) (SPADCALL 1 |r| (QREFELT $ 36))) 

(DEFUN |CARTEN;coerce;Dp$;28| (|v| $)
  (PROG (#1=#:G824 |i| #2=#:G825 |j| |z|)
    (RETURN
     (SEQ
      (LETT |z| (SPADCALL (QREFELT $ 7) (|spadConstant| $ 35) (QREFELT $ 36))
            . #3=(|CARTEN;coerce;Dp$;28|))
      (SEQ (LETT |j| (SPADCALL |v| (QREFELT $ 70)) . #3#)
           (LETT #2# (SPADCALL |v| (QREFELT $ 71)) . #3#) (LETT |i| 0 . #3#)
           (LETT #1# (- (QREFELT $ 7) 1) . #3#) G190
           (COND ((OR (QSGREATERP |i| #1#) (> |j| #2#)) (GO G191)))
           (SEQ
            (EXIT
             (SPADCALL |z| |i| (SPADCALL |v| |j| (QREFELT $ 72))
                       (QREFELT $ 37))))
           (LETT |i| (PROG1 (QSADD1 |i|) (LETT |j| (+ |j| 1) . #3#)) . #3#)
           (GO G190) G191 (EXIT NIL))
      (EXIT |z|))))) 

(DEFUN |CARTEN;coerce;Sm$;29| (|m| $)
  (PROG (|offz| #1=#:G832 |j| #2=#:G831 |i| |z|)
    (RETURN
     (SEQ
      (LETT |z|
            (SPADCALL (SPADCALL (QREFELT $ 7) 2 (QREFELT $ 12))
                      (|spadConstant| $ 35) (QREFELT $ 36))
            . #3=(|CARTEN;coerce;Sm$;29|))
      (LETT |offz| 0 . #3#)
      (SEQ (LETT |i| 0 . #3#) (LETT #2# (- (QREFELT $ 7) 1) . #3#) G190
           (COND ((QSGREATERP |i| #2#) #4=(GO G191)))
           (SEQ
            (SEQ (LETT |j| 0 . #3#) (LETT #1# (- (QREFELT $ 7) 1) . #3#) G190
                 (COND ((QSGREATERP |j| #1#) #4#))
                 (SEQ
                  (EXIT
                   (SPADCALL |z| (+ |offz| |j|)
                             (SPADCALL |m| (+ |i| 1) (+ |j| 1) (QREFELT $ 75))
                             (QREFELT $ 37))))
                 (LETT |j| (QSADD1 |j|) . #3#) #5=(GO G190) G191 (EXIT NIL))
            (EXIT (LETT |offz| (+ |offz| (QREFELT $ 7)) . #3#)))
           (LETT |i| (QSADD1 |i|) . #3#) #5# G191 (EXIT NIL))
      (EXIT |z|))))) 

(DEFUN |CARTEN;=;2$B;30| (|x| |y| $)
  (PROG (#1=#:G837 #2=#:G838 |i|)
    (RETURN
     (SEQ
      (EXIT
       (COND
        ((NULL
          (EQL (SPADCALL |x| (QREFELT $ 31)) (SPADCALL |y| (QREFELT $ 31))))
         'NIL)
        ('T
         (SEQ
          (SEQ (LETT |i| 0 . #3=(|CARTEN;=;2$B;30|))
               (LETT #2# (- (SPADCALL |x| (QREFELT $ 31)) 1) . #3#) G190
               (COND ((QSGREATERP |i| #2#) (GO G191)))
               (SEQ
                (EXIT
                 (COND
                  ((NULL
                    (SPADCALL (SPADCALL |x| |i| (QREFELT $ 32))
                              (SPADCALL |y| |i| (QREFELT $ 32))
                              (QREFELT $ 77)))
                   (PROGN (LETT #1# 'NIL . #3#) (GO #1#))))))
               (LETT |i| (QSADD1 |i|) . #3#) (GO G190) G191 (EXIT NIL))
          (EXIT 'T)))))
      #1# (EXIT #1#))))) 

(DEFUN |CARTEN;+;3$;31| (|x| |y| $)
  (PROG (#1=#:G843 |i| |z|)
    (RETURN
     (SEQ
      (COND
       ((NULL
         (EQL (SPADCALL |x| (QREFELT $ 31)) (SPADCALL |y| (QREFELT $ 31))))
        (|error| "Rank mismatch"))
       ('T
        (SEQ
         (LETT |z|
               (SPADCALL (SPADCALL |x| (QREFELT $ 31)) (|spadConstant| $ 35)
                         (QREFELT $ 36))
               . #2=(|CARTEN;+;3$;31|))
         (SEQ (LETT |i| 0 . #2#)
              (LETT #1# (- (SPADCALL |x| (QREFELT $ 31)) 1) . #2#) G190
              (COND ((QSGREATERP |i| #1#) (GO G191)))
              (SEQ
               (EXIT
                (SPADCALL |z| |i|
                          (SPADCALL (SPADCALL |x| |i| (QREFELT $ 32))
                                    (SPADCALL |y| |i| (QREFELT $ 32))
                                    (QREFELT $ 79))
                          (QREFELT $ 37))))
              (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191 (EXIT NIL))
         (EXIT |z|)))))))) 

(DEFUN |CARTEN;-;3$;32| (|x| |y| $)
  (PROG (#1=#:G848 |i| |z|)
    (RETURN
     (SEQ
      (COND
       ((NULL
         (EQL (SPADCALL |x| (QREFELT $ 31)) (SPADCALL |y| (QREFELT $ 31))))
        (|error| "Rank mismatch"))
       ('T
        (SEQ
         (LETT |z|
               (SPADCALL (SPADCALL |x| (QREFELT $ 31)) (|spadConstant| $ 35)
                         (QREFELT $ 36))
               . #2=(|CARTEN;-;3$;32|))
         (SEQ (LETT |i| 0 . #2#)
              (LETT #1# (- (SPADCALL |x| (QREFELT $ 31)) 1) . #2#) G190
              (COND ((QSGREATERP |i| #1#) (GO G191)))
              (SEQ
               (EXIT
                (SPADCALL |z| |i|
                          (SPADCALL (SPADCALL |x| |i| (QREFELT $ 32))
                                    (SPADCALL |y| |i| (QREFELT $ 32))
                                    (QREFELT $ 81))
                          (QREFELT $ 37))))
              (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191 (EXIT NIL))
         (EXIT |z|)))))))) 

(DEFUN |CARTEN;-;2$;33| (|x| $)
  (PROG (#1=#:G852 |i| |z|)
    (RETURN
     (SEQ
      (LETT |z|
            (SPADCALL (SPADCALL |x| (QREFELT $ 31)) (|spadConstant| $ 35)
                      (QREFELT $ 36))
            . #2=(|CARTEN;-;2$;33|))
      (SEQ (LETT |i| 0 . #2#)
           (LETT #1# (- (SPADCALL |x| (QREFELT $ 31)) 1) . #2#) G190
           (COND ((QSGREATERP |i| #1#) (GO G191)))
           (SEQ
            (EXIT
             (SPADCALL |z| |i|
                       (SPADCALL (SPADCALL |x| |i| (QREFELT $ 32))
                                 (QREFELT $ 83))
                       (QREFELT $ 37))))
           (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191 (EXIT NIL))
      (EXIT |z|))))) 

(DEFUN |CARTEN;*;I2$;34| (|n| |x| $)
  (PROG (#1=#:G856 |i| |z|)
    (RETURN
     (SEQ
      (LETT |z|
            (SPADCALL (SPADCALL |x| (QREFELT $ 31)) (|spadConstant| $ 35)
                      (QREFELT $ 36))
            . #2=(|CARTEN;*;I2$;34|))
      (SEQ (LETT |i| 0 . #2#)
           (LETT #1# (- (SPADCALL |x| (QREFELT $ 31)) 1) . #2#) G190
           (COND ((QSGREATERP |i| #1#) (GO G191)))
           (SEQ
            (EXIT
             (SPADCALL |z| |i|
                       (SPADCALL |n| (SPADCALL |x| |i| (QREFELT $ 32))
                                 (QREFELT $ 85))
                       (QREFELT $ 37))))
           (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191 (EXIT NIL))
      (EXIT |z|))))) 

(DEFUN |CARTEN;*;$I$;35| (|x| |n| $)
  (PROG (#1=#:G860 |i| |z|)
    (RETURN
     (SEQ
      (LETT |z|
            (SPADCALL (SPADCALL |x| (QREFELT $ 31)) (|spadConstant| $ 35)
                      (QREFELT $ 36))
            . #2=(|CARTEN;*;$I$;35|))
      (SEQ (LETT |i| 0 . #2#)
           (LETT #1# (- (SPADCALL |x| (QREFELT $ 31)) 1) . #2#) G190
           (COND ((QSGREATERP |i| #1#) (GO G191)))
           (SEQ
            (EXIT
             (SPADCALL |z| |i|
                       (SPADCALL |n| (SPADCALL |x| |i| (QREFELT $ 32))
                                 (QREFELT $ 85))
                       (QREFELT $ 37))))
           (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191 (EXIT NIL))
      (EXIT |z|))))) 

(DEFUN |CARTEN;*;R2$;36| (|r| |x| $)
  (PROG (#1=#:G864 |i| |z|)
    (RETURN
     (SEQ
      (LETT |z|
            (SPADCALL (SPADCALL |x| (QREFELT $ 31)) (|spadConstant| $ 35)
                      (QREFELT $ 36))
            . #2=(|CARTEN;*;R2$;36|))
      (SEQ (LETT |i| 0 . #2#)
           (LETT #1# (- (SPADCALL |x| (QREFELT $ 31)) 1) . #2#) G190
           (COND ((QSGREATERP |i| #1#) (GO G191)))
           (SEQ
            (EXIT
             (SPADCALL |z| |i|
                       (SPADCALL |r| (SPADCALL |x| |i| (QREFELT $ 32))
                                 (QREFELT $ 88))
                       (QREFELT $ 37))))
           (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191 (EXIT NIL))
      (EXIT |z|))))) 

(DEFUN |CARTEN;*;$R$;37| (|x| |r| $)
  (PROG (#1=#:G868 |i| |z|)
    (RETURN
     (SEQ
      (LETT |z|
            (SPADCALL (SPADCALL |x| (QREFELT $ 31)) (|spadConstant| $ 35)
                      (QREFELT $ 36))
            . #2=(|CARTEN;*;$R$;37|))
      (SEQ (LETT |i| 0 . #2#)
           (LETT #1# (- (SPADCALL |x| (QREFELT $ 31)) 1) . #2#) G190
           (COND ((QSGREATERP |i| #1#) (GO G191)))
           (SEQ
            (EXIT
             (SPADCALL |z| |i|
                       (SPADCALL |r| (SPADCALL |x| |i| (QREFELT $ 32))
                                 (QREFELT $ 88))
                       (QREFELT $ 37))))
           (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191 (EXIT NIL))
      (EXIT |z|))))) 

(DEFUN |CARTEN;product;3$;38| (|x| |y| $)
  (PROG (#1=#:G874 |j| #2=#:G873 |i| |ioff| |z| |ny| |nx|)
    (RETURN
     (SEQ
      (LETT |nx| (SPADCALL |x| (QREFELT $ 31)) . #3=(|CARTEN;product;3$;38|))
      (LETT |ny| (SPADCALL |y| (QREFELT $ 31)) . #3#)
      (LETT |z| (SPADCALL (* |nx| |ny|) (|spadConstant| $ 35) (QREFELT $ 36))
            . #3#)
      (SEQ (LETT |ioff| 0 . #3#) (LETT |i| 0 . #3#) (LETT #2# (- |nx| 1) . #3#)
           G190 (COND ((QSGREATERP |i| #2#) #4=(GO G191)))
           (SEQ
            (EXIT
             (SEQ (LETT |j| 0 . #3#) (LETT #1# (- |ny| 1) . #3#) G190
                  (COND ((QSGREATERP |j| #1#) #4#))
                  (SEQ
                   (EXIT
                    (SPADCALL |z| (+ |ioff| |j|)
                              (SPADCALL (SPADCALL |x| |i| (QREFELT $ 32))
                                        (SPADCALL |y| |j| (QREFELT $ 32))
                                        (QREFELT $ 88))
                              (QREFELT $ 37))))
                  (LETT |j| (QSADD1 |j|) . #3#) #5=(GO G190) G191 (EXIT NIL))))
           (LETT |i|
                 (PROG1 (QSADD1 |i|) (LETT |ioff| (QSPLUS |ioff| |ny|) . #3#))
                 . #3#)
           #5# G191 (EXIT NIL))
      (EXIT |z|))))) 

(DEFUN |CARTEN;*;3$;39| (|x| |y| $)
  (PROG (|ry| |rx|)
    (RETURN
     (SEQ (LETT |rx| (SPADCALL |x| (QREFELT $ 42)) . #1=(|CARTEN;*;3$;39|))
          (LETT |ry| (SPADCALL |y| (QREFELT $ 42)) . #1#)
          (EXIT
           (COND
            ((EQL |rx| 0)
             (SPADCALL (SPADCALL |x| 0 (QREFELT $ 32)) |y| (QREFELT $ 89)))
            ((EQL |ry| 0)
             (SPADCALL |x| (SPADCALL |y| 0 (QREFELT $ 32)) (QREFELT $ 90)))
            ('T (SPADCALL |x| |rx| |y| 1 (QREFELT $ 92))))))))) 

(DEFUN |CARTEN;contract;$2I$;40| (|x| |i| |j| $)
  (PROG (#1=#:G884 |k| |xk| |l| |xl| |zl| |m| |xm| |zm| |h| |xh| |zh| |z| |xok|
         |xoh| |zoh| |nh| |rh| |xom| |zom| |nm| |rm| |xol| |zol| |nl| |rl|
         |#G111| |#G110| |rx|)
    (RETURN
     (SEQ
      (LETT |rx| (SPADCALL |x| (QREFELT $ 42))
            . #2=(|CARTEN;contract;$2I$;40|))
      (COND
       ((OR (OR (OR (OR (< |i| 1) (< |rx| |i|)) (< |j| 1)) (< |rx| |j|))
            (EQL |i| |j|))
        (EXIT (|error| "Improper index for contraction"))))
      (COND
       ((< |j| |i|)
        (PROGN
         (LETT |#G110| |j| . #2#)
         (LETT |#G111| |i| . #2#)
         (LETT |i| |#G110| . #2#)
         (LETT |j| |#G111| . #2#))))
      (LETT |rl| (- |rx| |j|) . #2#)
      (LETT |nl| (EXPT (QREFELT $ 7) |rl|) . #2#) (LETT |zol| 1 . #2#)
      (LETT |xol| |zol| . #2#) (LETT |rm| (- (- |j| |i|) 1) . #2#)
      (LETT |nm| (EXPT (QREFELT $ 7) |rm|) . #2#) (LETT |zom| |nl| . #2#)
      (LETT |xom| (* |zom| (QREFELT $ 7)) . #2#) (LETT |rh| (- |i| 1) . #2#)
      (LETT |nh| (EXPT (QREFELT $ 7) |rh|) . #2#)
      (LETT |zoh| (* |nl| |nm|) . #2#)
      (LETT |xoh| (* |zoh| (SPADCALL (QREFELT $ 7) 2 (QREFELT $ 12))) . #2#)
      (LETT |xok| (* |nl| (+ 1 (* |nm| (QREFELT $ 7)))) . #2#)
      (LETT |z|
            (SPADCALL (* (* |nl| |nm|) |nh|) (|spadConstant| $ 35)
                      (QREFELT $ 36))
            . #2#)
      (SEQ (LETT |zh| 0 . #2#) (LETT |xh| 0 . #2#) (LETT |h| 1 . #2#) G190
           (COND ((QSGREATERP |h| |nh|) #3=(GO G191)))
           (SEQ
            (EXIT
             (SEQ (LETT |zm| |zh| . #2#) (LETT |xm| |xh| . #2#)
                  (LETT |m| 1 . #2#) G190 (COND ((QSGREATERP |m| |nm|) #3#))
                  (SEQ
                   (EXIT
                    (SEQ (LETT |zl| |zm| . #2#) (LETT |xl| |xm| . #2#)
                         (LETT |l| 1 . #2#) G190
                         (COND ((QSGREATERP |l| |nl|) #3#))
                         (SEQ
                          (SPADCALL |z| |zl| (|spadConstant| $ 35)
                                    (QREFELT $ 37))
                          (EXIT
                           (SEQ (LETT |xk| |xl| . #2#) (LETT |k| 1 . #2#)
                                (LETT #1# (QREFELT $ 7) . #2#) G190
                                (COND ((QSGREATERP |k| #1#) #3#))
                                (SEQ
                                 (EXIT
                                  (SPADCALL |z| |zl|
                                            (SPADCALL
                                             (SPADCALL |z| |zl| (QREFELT $ 32))
                                             (SPADCALL |x| |xk| (QREFELT $ 32))
                                             (QREFELT $ 79))
                                            (QREFELT $ 37))))
                                (LETT |k|
                                      (PROG1 (QSADD1 |k|)
                                        (LETT |xk| (+ |xk| |xok|) . #2#))
                                      . #2#)
                                #4=(GO G190) G191 (EXIT NIL))))
                         (LETT |l|
                               (PROG1 (QSADD1 |l|)
                                 (LETT |xl|
                                       (PROG1 (+ |xl| |xol|)
                                         (LETT |zl| (+ |zl| |zol|) . #2#))
                                       . #2#))
                               . #2#)
                         #4# G191 (EXIT NIL))))
                  (LETT |m|
                        (PROG1 (QSADD1 |m|)
                          (LETT |xm|
                                (PROG1 (+ |xm| |xom|)
                                  (LETT |zm| (+ |zm| |zom|) . #2#))
                                . #2#))
                        . #2#)
                  #4# G191 (EXIT NIL))))
           (LETT |h|
                 (PROG1 (QSADD1 |h|)
                   (LETT |xh|
                         (PROG1 (QSPLUS |xh| |xoh|)
                           (LETT |zh| (QSPLUS |zh| |zoh|) . #2#))
                         . #2#))
                 . #2#)
           #4# G191 (EXIT NIL))
      (EXIT |z|))))) 

(DEFUN |CARTEN;contract;$I$I$;41| (|x| |i| |y| |j| $)
  (PROG (#1=#:G893 |k| |xk| |yk| |dyl| |yl| |zly| |dyh| |yh| |zhy| |dxl| |xl|
         |zlx| |dxh| |xh| |zhx| |z| |zohx| |ohx| |nhx| |rhx| |zolx| |olx| |nlx|
         |rlx| |zohy| |ohy| |nhy| |rhy| |zoly| |oly| |nly| |rly| |ry| |rx|)
    (RETURN
     (SEQ
      (LETT |rx| (SPADCALL |x| (QREFELT $ 42))
            . #2=(|CARTEN;contract;$I$I$;41|))
      (LETT |ry| (SPADCALL |y| (QREFELT $ 42)) . #2#)
      (COND
       ((OR (OR (OR (< |i| 1) (< |rx| |i|)) (< |j| 1)) (< |ry| |j|))
        (EXIT (|error| "Improper index for contraction"))))
      (LETT |rly| (- |ry| |j|) . #2#)
      (LETT |nly| (EXPT (QREFELT $ 7) |rly|) . #2#) (LETT |oly| 1 . #2#)
      (LETT |zoly| 1 . #2#) (LETT |rhy| (- |j| 1) . #2#)
      (LETT |nhy| (EXPT (QREFELT $ 7) |rhy|) . #2#)
      (LETT |ohy| (* |nly| (QREFELT $ 7)) . #2#)
      (LETT |zohy| (SPADCALL |zoly| |nly| (QREFELT $ 95)) . #2#)
      (LETT |rlx| (- |rx| |i|) . #2#)
      (LETT |nlx| (EXPT (QREFELT $ 7) |rlx|) . #2#) (LETT |olx| 1 . #2#)
      (LETT |zolx| (* |zohy| |nhy|) . #2#) (LETT |rhx| (- |i| 1) . #2#)
      (LETT |nhx| (EXPT (QREFELT $ 7) |rhx|) . #2#)
      (LETT |ohx| (* |nlx| (QREFELT $ 7)) . #2#)
      (LETT |zohx| (* |zolx| |nlx|) . #2#)
      (LETT |z|
            (SPADCALL (* (* (* |nlx| |nhx|) |nly|) |nhy|) (|spadConstant| $ 35)
                      (QREFELT $ 36))
            . #2#)
      (SEQ (LETT |zhx| 0 . #2#) (LETT |xh| 0 . #2#) (LETT |dxh| 1 . #2#) G190
           (COND ((QSGREATERP |dxh| |nhx|) #3=(GO G191)))
           (SEQ
            (EXIT
             (SEQ (LETT |zlx| |zhx| . #2#) (LETT |xl| |xh| . #2#)
                  (LETT |dxl| 1 . #2#) G190
                  (COND ((QSGREATERP |dxl| |nlx|) #3#))
                  (SEQ
                   (EXIT
                    (SEQ (LETT |zhy| |zlx| . #2#) (LETT |yh| 0 . #2#)
                         (LETT |dyh| 1 . #2#) G190
                         (COND ((QSGREATERP |dyh| |nhy|) #3#))
                         (SEQ
                          (EXIT
                           (SEQ (LETT |zly| |zhy| . #2#) (LETT |yl| |yh| . #2#)
                                (LETT |dyl| 1 . #2#) G190
                                (COND ((QSGREATERP |dyl| |nly|) #3#))
                                (SEQ
                                 (SPADCALL |z| |zly| (|spadConstant| $ 35)
                                           (QREFELT $ 37))
                                 (EXIT
                                  (SEQ (LETT |yk| |yl| . #2#)
                                       (LETT |xk| |xl| . #2#)
                                       (LETT |k| 1 . #2#)
                                       (LETT #1# (QREFELT $ 7) . #2#) G190
                                       (COND ((QSGREATERP |k| #1#) #3#))
                                       (SEQ
                                        (EXIT
                                         (SPADCALL |z| |zly|
                                                   (SPADCALL
                                                    (SPADCALL |z| |zly|
                                                              (QREFELT $ 32))
                                                    (SPADCALL
                                                     (SPADCALL |x| |xk|
                                                               (QREFELT $ 32))
                                                     (SPADCALL |y| |yk|
                                                               (QREFELT $ 32))
                                                     (QREFELT $ 88))
                                                    (QREFELT $ 79))
                                                   (QREFELT $ 37))))
                                       (LETT |k|
                                             (PROG1 (QSADD1 |k|)
                                               (LETT |xk|
                                                     (PROG1 (+ |xk| |nlx|)
                                                       (LETT |yk|
                                                             (+ |yk| |nly|)
                                                             . #2#))
                                                     . #2#))
                                             . #2#)
                                       #4=(GO G190) G191 (EXIT NIL))))
                                (LETT |dyl|
                                      (PROG1 (QSADD1 |dyl|)
                                        (LETT |yl|
                                              (PROG1 (+ |yl| |oly|)
                                                (LETT |zly| (+ |zly| |zoly|)
                                                      . #2#))
                                              . #2#))
                                      . #2#)
                                #4# G191 (EXIT NIL))))
                         (LETT |dyh|
                               (PROG1 (QSADD1 |dyh|)
                                 (LETT |yh|
                                       (PROG1 (QSPLUS |yh| |ohy|)
                                         (LETT |zhy| (+ |zhy| |zohy|) . #2#))
                                       . #2#))
                               . #2#)
                         #4# G191 (EXIT NIL))))
                  (LETT |dxl|
                        (PROG1 (QSADD1 |dxl|)
                          (LETT |xl|
                                (PROG1 (+ |xl| |olx|)
                                  (LETT |zlx| (+ |zlx| |zolx|) . #2#))
                                . #2#))
                        . #2#)
                  #4# G191 (EXIT NIL))))
           (LETT |dxh|
                 (PROG1 (QSADD1 |dxh|)
                   (LETT |xh|
                         (PROG1 (QSPLUS |xh| |ohx|)
                           (LETT |zhx| (QSPLUS |zhx| |zohx|) . #2#))
                         . #2#))
                 . #2#)
           #4# G191 (EXIT NIL))
      (EXIT |z|))))) 

(DEFUN |CARTEN;transpose;2$;42| (|x| $)
  (SPADCALL |x| 1 (SPADCALL |x| (QREFELT $ 42)) (QREFELT $ 96))) 

(DEFUN |CARTEN;transpose;$2I$;43| (|x| |i| |j| $)
  (PROG (#1=#:G903 |q| |zq| |xq| #2=#:G902 |p| |zp| |xp| |l| |zl| |m| |zm| |h|
         |zh| |z| |zoh| |nh| |rh| |zoj| |zom| |nm| |rm| |zoi| |zol| |nl| |rl|
         |#G147| |#G146| |rx|)
    (RETURN
     (SEQ
      (LETT |rx| (SPADCALL |x| (QREFELT $ 42))
            . #3=(|CARTEN;transpose;$2I$;43|))
      (COND
       ((OR (OR (OR (OR (< |i| 1) (< |rx| |i|)) (< |j| 1)) (< |rx| |j|))
            (EQL |i| |j|))
        (EXIT (|error| "Improper indicies for transposition"))))
      (COND
       ((< |j| |i|)
        (PROGN
         (LETT |#G146| |j| . #3#)
         (LETT |#G147| |i| . #3#)
         (LETT |i| |#G146| . #3#)
         (LETT |j| |#G147| . #3#))))
      (LETT |rl| (- |rx| |j|) . #3#)
      (LETT |nl| (EXPT (QREFELT $ 7) |rl|) . #3#) (LETT |zol| 1 . #3#)
      (LETT |zoi| (SPADCALL |zol| |nl| (QREFELT $ 95)) . #3#)
      (LETT |rm| (- (- |j| |i|) 1) . #3#)
      (LETT |nm| (EXPT (QREFELT $ 7) |rm|) . #3#)
      (LETT |zom| (* |nl| (QREFELT $ 7)) . #3#)
      (LETT |zoj| (* |zom| |nm|) . #3#) (LETT |rh| (- |i| 1) . #3#)
      (LETT |nh| (EXPT (QREFELT $ 7) |rh|) . #3#)
      (LETT |zoh| (* (* |nl| |nm|) (SPADCALL (QREFELT $ 7) 2 (QREFELT $ 12)))
            . #3#)
      (LETT |z|
            (SPADCALL (SPADCALL |x| (QREFELT $ 31)) (|spadConstant| $ 35)
                      (QREFELT $ 36))
            . #3#)
      (SEQ (LETT |zh| 0 . #3#) (LETT |h| 1 . #3#) G190
           (COND ((QSGREATERP |h| |nh|) #4=(GO G191)))
           (SEQ
            (EXIT
             (SEQ (LETT |zm| |zh| . #3#) (LETT |m| 1 . #3#) G190
                  (COND ((QSGREATERP |m| |nm|) #4#))
                  (SEQ
                   (EXIT
                    (SEQ (LETT |zl| |zm| . #3#) (LETT |l| 1 . #3#) G190
                         (COND ((QSGREATERP |l| |nl|) #4#))
                         (SEQ
                          (EXIT
                           (SEQ (LETT |xp| |zl| . #3#) (LETT |zp| |zl| . #3#)
                                (LETT |p| 1 . #3#)
                                (LETT #2# (QREFELT $ 7) . #3#) G190
                                (COND ((QSGREATERP |p| #2#) #4#))
                                (SEQ
                                 (EXIT
                                  (SEQ (LETT |xq| |xp| . #3#)
                                       (LETT |zq| |zp| . #3#)
                                       (LETT |q| 1 . #3#)
                                       (LETT #1# (QREFELT $ 7) . #3#) G190
                                       (COND ((QSGREATERP |q| #1#) #4#))
                                       (SEQ
                                        (EXIT
                                         (SPADCALL |z| |zq|
                                                   (SPADCALL |x| |xq|
                                                             (QREFELT $ 32))
                                                   (QREFELT $ 37))))
                                       (LETT |q|
                                             (PROG1 (QSADD1 |q|)
                                               (LETT |zq|
                                                     (PROG1 (+ |zq| |zoj|)
                                                       (LETT |xq|
                                                             (+ |xq| |zoi|)
                                                             . #3#))
                                                     . #3#))
                                             . #3#)
                                       #5=(GO G190) G191 (EXIT NIL))))
                                (LETT |p|
                                      (PROG1 (QSADD1 |p|)
                                        (LETT |zp|
                                              (PROG1 (+ |zp| |zoi|)
                                                (LETT |xp| (+ |xp| |zoj|)
                                                      . #3#))
                                              . #3#))
                                      . #3#)
                                #5# G191 (EXIT NIL))))
                         (LETT |l|
                               (PROG1 (QSADD1 |l|)
                                 (LETT |zl| (+ |zl| |zol|) . #3#))
                               . #3#)
                         #5# G191 (EXIT NIL))))
                  (LETT |m|
                        (PROG1 (QSADD1 |m|) (LETT |zm| (+ |zm| |zom|) . #3#))
                        . #3#)
                  #5# G191 (EXIT NIL))))
           (LETT |h| (PROG1 (QSADD1 |h|) (LETT |zh| (QSPLUS |zh| |zoh|) . #3#))
                 . #3#)
           #5# G191 (EXIT NIL))
      (EXIT |z|))))) 

(DEFUN |CARTEN;reindex;$L$;44| (|x| |l| $)
  (PROG (|pi| #1=#:G908 |i| |ziv| |xiv| |p| |rx| |z| |nx|)
    (RETURN
     (SEQ
      (LETT |nx| (SPADCALL |x| (QREFELT $ 31)) . #2=(|CARTEN;reindex;$L$;44|))
      (LETT |z| (SPADCALL |nx| (|spadConstant| $ 35) (QREFELT $ 36)) . #2#)
      (LETT |rx| (SPADCALL |x| (QREFELT $ 42)) . #2#)
      (LETT |p| (|CARTEN;mkPerm| |rx| |l| $) . #2#)
      (LETT |xiv| (SPADCALL |rx| 0 (QREFELT $ 23)) . #2#)
      (LETT |ziv| (SPADCALL |rx| 0 (QREFELT $ 23)) . #2#)
      (SEQ (LETT |i| 0 . #2#)
           (LETT #1# (- (SPADCALL |x| (QREFELT $ 31)) 1) . #2#) G190
           (COND ((QSGREATERP |i| #1#) (GO G191)))
           (SEQ
            (LETT |pi|
                  (|CARTEN;index2int|
                   (|CARTEN;permute!| |ziv| (|CARTEN;int2index| |i| |xiv| $)
                    |p| $)
                   $)
                  . #2#)
            (EXIT
             (SPADCALL |z| |pi| (SPADCALL |x| |i| (QREFELT $ 32))
                       (QREFELT $ 37))))
           (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191 (EXIT NIL))
      (EXIT |z|))))) 

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

(DEFUN |CartesianTensor;| (|#1| |#2| |#3|)
  (PROG (|pv$| $ |dv$| DV$3 DV$2 DV$1)
    (RETURN
     (PROGN
      (LETT DV$1 (|devaluate| |#1|) . #1=(|CartesianTensor|))
      (LETT DV$2 (|devaluate| |#2|) . #1#)
      (LETT DV$3 (|devaluate| |#3|) . #1#)
      (LETT |dv$| (LIST '|CartesianTensor| DV$1 DV$2 DV$3) . #1#)
      (LETT $ (GETREFV 101) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|haddProp| |$ConstructorCache| '|CartesianTensor| (LIST DV$1 DV$2 DV$3)
                  (CONS 1 $))
      (|stuffDomainSlots| $)
      (QSETREFV $ 6 |#1|)
      (QSETREFV $ 7 |#2|)
      (QSETREFV $ 8 |#3|)
      (QSETREFV $ 9 (|IndexedVector| |#3| 0))
      (QSETREFV $ 13 (SPADCALL |#2| 2 (QREFELT $ 12)))
      (QSETREFV $ 14 (SPADCALL |#2| 3 (QREFELT $ 12)))
      (QSETREFV $ 15 (SPADCALL |#2| 4 (QREFELT $ 12)))
      $)))) 

(MAKEPROP '|CartesianTensor| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) (|local| |#2|)
              (|local| |#3|) '|Rep| (|PositiveInteger|) (|NonNegativeInteger|)
              (0 . ^) '|dim2| '|dim3| '|dim4| |CARTEN;kroneckerDelta;$;10|
              |CARTEN;sample;$;1| (|Integer|) (|Vector| 18) (6 . |setelt|)
              (13 . |elt|) (19 . *) (25 . |new|) (|Boolean|) (|Vector| 24)
              (31 . |new|) (37 . |setelt|) (44 . |elt|) (|Union| $ '"failed")
              (50 . |exquo|) (56 . |#|) (61 . |elt|) (|List| 8)
              |CARTEN;ravel;$L;8| (67 . |Zero|) (71 . |new|) (77 . |setelt|)
              |CARTEN;unravel;L$;9| (84 . |One|) (88 . |coerce|)
              |CARTEN;leviCivitaSymbol;$;11| |CARTEN;rank;$Nni;13|
              |CARTEN;degree;$Nni;12| |CARTEN;elt;$R;14| |CARTEN;elt;$IR;15|
              |CARTEN;elt;$2IR;16| |CARTEN;elt;$3IR;17| |CARTEN;elt;$4IR;18|
              (|List| 18) |CARTEN;elt;$LR;19| |CARTEN;coerce;L$;20| (|List| $$)
              (93 . |#|) (98 . |first|) (|List| $) |CARTEN;coerce;L$;21|
              (|Union| 8 '"failed") |CARTEN;retractIfCan;$U;22| (|OutputForm|)
              (|List| 59) (103 . |coerce|) (108 . |coerce|) (|List| 55)
              (113 . |matrix|) |CARTEN;coerce;$Of;24| |CARTEN;coerce;R$;27|
              (CONS IDENTITY
                    (FUNCALL (|dispatchFunction| |CARTEN;Zero;$;25|) $))
              (CONS IDENTITY
                    (FUNCALL (|dispatchFunction| |CARTEN;One;$;26|) $))
              (|DirectProduct| 7 8) (118 . |minIndex|) (123 . |maxIndex|)
              (128 . |elt|) |CARTEN;coerce;Dp$;28| (|SquareMatrix| 7 8)
              (134 . |elt|) |CARTEN;coerce;Sm$;29| (141 . =) |CARTEN;=;2$B;30|
              (147 . +) |CARTEN;+;3$;31| (153 . -) |CARTEN;-;3$;32| (159 . -)
              |CARTEN;-;2$;33| (164 . *) |CARTEN;*;I2$;34| |CARTEN;*;$I$;35|
              (170 . *) |CARTEN;*;R2$;36| |CARTEN;*;$R$;37|
              |CARTEN;product;3$;38| |CARTEN;contract;$I$I$;41|
              |CARTEN;*;3$;39| |CARTEN;contract;$2I$;40| (176 . *)
              |CARTEN;transpose;$2I$;43| |CARTEN;transpose;2$;42|
              |CARTEN;reindex;$L$;44| (|SingleInteger|) (|String|))
           '#(~= 182 |unravel| 188 |transpose| 193 |sample| 205 |retractIfCan|
              209 |retract| 214 |reindex| 219 |ravel| 225 |rank| 230 |product|
              235 |leviCivitaSymbol| 241 |latex| 245 |kroneckerDelta| 250
              |hash| 254 |elt| 259 |degree| 300 |contract| 305 |coerce| 320
              |Zero| 350 |One| 354 = 358 - 364 + 375 * 381)
           'NIL
           (CONS (|makeByteWordVec2| 1 '(0 0 0 0 0 0 0))
                 (CONS
                  '#(|GradedAlgebra&| |GradedModule&| |GradedModule&|
                     |SetCategory&| |BasicType&| |RetractableTo&| NIL)
                  (CONS
                   '#((|GradedAlgebra| 8 11) (|GradedModule| 8 11)
                      (|GradedModule| 18 11) (|SetCategory|) (|BasicType|)
                      (|RetractableTo| 8) (|CoercibleTo| 59))
                   (|makeByteWordVec2| 100
                                       '(2 11 0 0 10 12 3 19 18 0 18 18 20 2 19
                                         18 0 18 21 2 18 0 11 0 22 2 19 0 11 18
                                         23 2 25 0 11 24 26 3 25 24 0 18 24 27
                                         2 25 24 0 18 28 2 18 29 0 0 30 1 9 11
                                         0 31 2 9 8 0 18 32 0 8 0 35 2 9 0 11 8
                                         36 3 9 8 0 18 8 37 0 8 0 39 1 8 0 18
                                         40 1 52 11 0 53 1 52 2 0 54 1 60 59 0
                                         61 1 8 59 0 62 1 59 0 63 64 1 69 18 0
                                         70 1 69 18 0 71 2 69 8 0 18 72 3 74 8
                                         0 18 18 75 2 8 24 0 0 77 2 8 0 0 0 79
                                         2 8 0 0 0 81 1 8 0 0 83 2 8 0 18 0 85
                                         2 8 0 0 0 88 2 11 0 10 0 95 2 0 24 0 0
                                         1 1 0 0 33 38 3 0 0 0 18 18 96 1 0 0 0
                                         97 0 0 0 17 1 0 57 0 58 1 0 8 0 1 2 0
                                         0 0 49 98 1 0 33 0 34 1 0 11 0 42 2 0
                                         0 0 0 91 0 0 0 41 1 0 100 0 1 0 0 0 16
                                         1 0 99 0 1 2 0 8 0 49 50 5 0 8 0 18 18
                                         18 18 48 3 0 8 0 18 18 46 4 0 8 0 18
                                         18 18 47 1 0 8 0 44 2 0 8 0 18 45 1 0
                                         11 0 43 4 0 0 0 18 0 18 92 3 0 0 0 18
                                         18 94 1 0 0 33 51 1 0 0 55 56 1 0 0 69
                                         73 1 0 0 74 76 1 0 0 8 66 1 0 59 0 65
                                         0 0 0 67 0 0 0 68 2 0 24 0 0 78 2 0 0
                                         0 0 82 1 0 0 0 84 2 0 0 0 0 80 2 0 0 0
                                         0 93 2 0 0 18 0 86 2 0 0 0 18 87 2 0 0
                                         0 8 90 2 0 0 8 0 89)))))
           '|lookupComplete|)) 
