
(/VERSIONCHECK 2) 

(PUT '|MATSTOR;rep| '|SPADreplace| '(XLAM (|m|) |m|)) 

(DEFUN |MATSTOR;rep| (|m| $) |m|) 

(DEFUN |MATSTOR;copy!;3M;2| (|c| |a| $)
  (PROG (#1=#:G698 |j| |cRow| |aRow| #2=#:G697 |i| |cc| |aa| |n| |m|)
    (RETURN
     (SEQ (LETT |m| (SPADCALL |a| (QREFELT $ 9)) . #3=(|MATSTOR;copy!;3M;2|))
          (LETT |n| (SPADCALL |a| (QREFELT $ 10)) . #3#)
          (COND
           ((EQL (SPADCALL |c| (QREFELT $ 9)) |m|)
            (COND
             ((NULL (EQL (SPADCALL |c| (QREFELT $ 10)) |n|))
              (EXIT
               (|error| #4="copy!: matrices of incompatible dimensions")))))
           ('T (EXIT (|error| #4#))))
          (LETT |aa| (|MATSTOR;rep| |a| $) . #3#)
          (LETT |cc| (|MATSTOR;rep| |c| $) . #3#)
          (SEQ (LETT |i| 0 . #3#) (LETT #2# (- |m| 1) . #3#) G190
               (COND ((QSGREATERP |i| #2#) #5=(GO G191)))
               (SEQ (LETT |aRow| (ELT |aa| |i|) . #3#)
                    (LETT |cRow| (ELT |cc| |i|) . #3#)
                    (EXIT
                     (SEQ (LETT |j| 0 . #3#) (LETT #1# (- |n| 1) . #3#) G190
                          (COND ((QSGREATERP |j| #1#) #5#))
                          (SEQ (EXIT (SETELT |cRow| |j| (ELT |aRow| |j|))))
                          (LETT |j| (QSADD1 |j|) . #3#) #6=(GO G190) G191
                          (EXIT NIL))))
               (LETT |i| (QSADD1 |i|) . #3#) #6# G191 (EXIT NIL))
          (EXIT |c|))))) 

(DEFUN |MATSTOR;plus!;4M;3| (|c| |a| |b| $)
  (PROG (#1=#:G709 |j| |cRow| |bRow| |aRow| #2=#:G708 |i| |cc| |bb| |aa| |n|
         |m|)
    (RETURN
     (SEQ (LETT |m| (SPADCALL |a| (QREFELT $ 9)) . #3=(|MATSTOR;plus!;4M;3|))
          (LETT |n| (SPADCALL |a| (QREFELT $ 10)) . #3#)
          (COND
           ((EQL (SPADCALL |b| (QREFELT $ 9)) |m|)
            (COND
             ((NULL (EQL (SPADCALL |b| (QREFELT $ 10)) |n|))
              (EXIT
               (|error| #4="plus!: matrices of incompatible dimensions")))))
           (#5='T (EXIT (|error| #4#))))
          (COND
           ((EQL (SPADCALL |c| (QREFELT $ 9)) |m|)
            (COND
             ((NULL (EQL (SPADCALL |c| (QREFELT $ 10)) |n|))
              (EXIT
               (|error| #6="plus!: matrices of incompatible dimensions")))))
           (#5# (EXIT (|error| #6#))))
          (LETT |aa| (|MATSTOR;rep| |a| $) . #3#)
          (LETT |bb| (|MATSTOR;rep| |b| $) . #3#)
          (LETT |cc| (|MATSTOR;rep| |c| $) . #3#)
          (SEQ (LETT |i| 0 . #3#) (LETT #2# (- |m| 1) . #3#) G190
               (COND ((QSGREATERP |i| #2#) #7=(GO G191)))
               (SEQ (LETT |aRow| (ELT |aa| |i|) . #3#)
                    (LETT |bRow| (ELT |bb| |i|) . #3#)
                    (LETT |cRow| (ELT |cc| |i|) . #3#)
                    (EXIT
                     (SEQ (LETT |j| 0 . #3#) (LETT #1# (- |n| 1) . #3#) G190
                          (COND ((QSGREATERP |j| #1#) #7#))
                          (SEQ
                           (EXIT
                            (SETELT |cRow| |j|
                                    (SPADCALL (ELT |aRow| |j|) (ELT |bRow| |j|)
                                              (QREFELT $ 13)))))
                          (LETT |j| (QSADD1 |j|) . #3#) #8=(GO G190) G191
                          (EXIT NIL))))
               (LETT |i| (QSADD1 |i|) . #3#) #8# G191 (EXIT NIL))
          (EXIT |c|))))) 

(DEFUN |MATSTOR;minus!;3M;4| (|c| |a| $)
  (PROG (#1=#:G718 |j| |cRow| |aRow| #2=#:G717 |i| |cc| |aa| |n| |m|)
    (RETURN
     (SEQ (LETT |m| (SPADCALL |a| (QREFELT $ 9)) . #3=(|MATSTOR;minus!;3M;4|))
          (LETT |n| (SPADCALL |a| (QREFELT $ 10)) . #3#)
          (COND
           ((EQL (SPADCALL |c| (QREFELT $ 9)) |m|)
            (COND
             ((NULL (EQL (SPADCALL |c| (QREFELT $ 10)) |n|))
              (EXIT
               (|error| #4="minus!: matrices of incompatible dimensions")))))
           ('T (EXIT (|error| #4#))))
          (LETT |aa| (|MATSTOR;rep| |a| $) . #3#)
          (LETT |cc| (|MATSTOR;rep| |c| $) . #3#)
          (SEQ (LETT |i| 0 . #3#) (LETT #2# (- |m| 1) . #3#) G190
               (COND ((QSGREATERP |i| #2#) #5=(GO G191)))
               (SEQ (LETT |aRow| (ELT |aa| |i|) . #3#)
                    (LETT |cRow| (ELT |cc| |i|) . #3#)
                    (EXIT
                     (SEQ (LETT |j| 0 . #3#) (LETT #1# (- |n| 1) . #3#) G190
                          (COND ((QSGREATERP |j| #1#) #5#))
                          (SEQ
                           (EXIT
                            (SETELT |cRow| |j|
                                    (SPADCALL (ELT |aRow| |j|)
                                              (QREFELT $ 15)))))
                          (LETT |j| (QSADD1 |j|) . #3#) #6=(GO G190) G191
                          (EXIT NIL))))
               (LETT |i| (QSADD1 |i|) . #3#) #6# G191 (EXIT NIL))
          (EXIT |c|))))) 

(DEFUN |MATSTOR;minus!;4M;5| (|c| |a| |b| $)
  (PROG (#1=#:G729 |j| |cRow| |bRow| |aRow| #2=#:G728 |i| |cc| |bb| |aa| |n|
         |m|)
    (RETURN
     (SEQ (LETT |m| (SPADCALL |a| (QREFELT $ 9)) . #3=(|MATSTOR;minus!;4M;5|))
          (LETT |n| (SPADCALL |a| (QREFELT $ 10)) . #3#)
          (COND
           ((EQL (SPADCALL |b| (QREFELT $ 9)) |m|)
            (COND
             ((NULL (EQL (SPADCALL |b| (QREFELT $ 10)) |n|))
              (EXIT
               (|error| #4="minus!: matrices of incompatible dimensions")))))
           (#5='T (EXIT (|error| #4#))))
          (COND
           ((EQL (SPADCALL |c| (QREFELT $ 9)) |m|)
            (COND
             ((NULL (EQL (SPADCALL |c| (QREFELT $ 10)) |n|))
              (EXIT
               (|error| #6="minus!: matrices of incompatible dimensions")))))
           (#5# (EXIT (|error| #6#))))
          (LETT |aa| (|MATSTOR;rep| |a| $) . #3#)
          (LETT |bb| (|MATSTOR;rep| |b| $) . #3#)
          (LETT |cc| (|MATSTOR;rep| |c| $) . #3#)
          (SEQ (LETT |i| 0 . #3#) (LETT #2# (- |m| 1) . #3#) G190
               (COND ((QSGREATERP |i| #2#) #7=(GO G191)))
               (SEQ (LETT |aRow| (ELT |aa| |i|) . #3#)
                    (LETT |bRow| (ELT |bb| |i|) . #3#)
                    (LETT |cRow| (ELT |cc| |i|) . #3#)
                    (EXIT
                     (SEQ (LETT |j| 0 . #3#) (LETT #1# (- |n| 1) . #3#) G190
                          (COND ((QSGREATERP |j| #1#) #7#))
                          (SEQ
                           (EXIT
                            (SETELT |cRow| |j|
                                    (SPADCALL (ELT |aRow| |j|) (ELT |bRow| |j|)
                                              (QREFELT $ 17)))))
                          (LETT |j| (QSADD1 |j|) . #3#) #8=(GO G190) G191
                          (EXIT NIL))))
               (LETT |i| (QSADD1 |i|) . #3#) #8# G191 (EXIT NIL))
          (EXIT |c|))))) 

(DEFUN |MATSTOR;leftScalarTimes!;MR2M;6| (|c| |r| |a| $)
  (PROG (#1=#:G738 |j| |cRow| |aRow| #2=#:G737 |i| |cc| |aa| |n| |m|)
    (RETURN
     (SEQ
      (LETT |m| (SPADCALL |a| (QREFELT $ 9))
            . #3=(|MATSTOR;leftScalarTimes!;MR2M;6|))
      (LETT |n| (SPADCALL |a| (QREFELT $ 10)) . #3#)
      (COND
       ((EQL (SPADCALL |c| (QREFELT $ 9)) |m|)
        (COND
         ((NULL (EQL (SPADCALL |c| (QREFELT $ 10)) |n|))
          (EXIT
           (|error|
            #4="leftScalarTimes!: matrices of incompatible dimensions")))))
       ('T (EXIT (|error| #4#))))
      (LETT |aa| (|MATSTOR;rep| |a| $) . #3#)
      (LETT |cc| (|MATSTOR;rep| |c| $) . #3#)
      (SEQ (LETT |i| 0 . #3#) (LETT #2# (- |m| 1) . #3#) G190
           (COND ((QSGREATERP |i| #2#) #5=(GO G191)))
           (SEQ (LETT |aRow| (ELT |aa| |i|) . #3#)
                (LETT |cRow| (ELT |cc| |i|) . #3#)
                (EXIT
                 (SEQ (LETT |j| 0 . #3#) (LETT #1# (- |n| 1) . #3#) G190
                      (COND ((QSGREATERP |j| #1#) #5#))
                      (SEQ
                       (EXIT
                        (SETELT |cRow| |j|
                                (SPADCALL |r| (ELT |aRow| |j|)
                                          (QREFELT $ 19)))))
                      (LETT |j| (QSADD1 |j|) . #3#) #6=(GO G190) G191
                      (EXIT NIL))))
           (LETT |i| (QSADD1 |i|) . #3#) #6# G191 (EXIT NIL))
      (EXIT |c|))))) 

(DEFUN |MATSTOR;rightScalarTimes!;2MRM;7| (|c| |a| |r| $)
  (PROG (#1=#:G747 |j| |cRow| |aRow| #2=#:G746 |i| |cc| |aa| |n| |m|)
    (RETURN
     (SEQ
      (LETT |m| (SPADCALL |a| (QREFELT $ 9))
            . #3=(|MATSTOR;rightScalarTimes!;2MRM;7|))
      (LETT |n| (SPADCALL |a| (QREFELT $ 10)) . #3#)
      (COND
       ((EQL (SPADCALL |c| (QREFELT $ 9)) |m|)
        (COND
         ((NULL (EQL (SPADCALL |c| (QREFELT $ 10)) |n|))
          (EXIT
           (|error|
            #4="rightScalarTimes!: matrices of incompatible dimensions")))))
       ('T (EXIT (|error| #4#))))
      (LETT |aa| (|MATSTOR;rep| |a| $) . #3#)
      (LETT |cc| (|MATSTOR;rep| |c| $) . #3#)
      (SEQ (LETT |i| 0 . #3#) (LETT #2# (- |m| 1) . #3#) G190
           (COND ((QSGREATERP |i| #2#) #5=(GO G191)))
           (SEQ (LETT |aRow| (ELT |aa| |i|) . #3#)
                (LETT |cRow| (ELT |cc| |i|) . #3#)
                (EXIT
                 (SEQ (LETT |j| 0 . #3#) (LETT #1# (- |n| 1) . #3#) G190
                      (COND ((QSGREATERP |j| #1#) #5#))
                      (SEQ
                       (EXIT
                        (SETELT |cRow| |j|
                                (SPADCALL (ELT |aRow| |j|) |r|
                                          (QREFELT $ 19)))))
                      (LETT |j| (QSADD1 |j|) . #3#) #6=(GO G190) G191
                      (EXIT NIL))))
           (LETT |i| (QSADD1 |i|) . #3#) #6# G191 (EXIT NIL))
      (EXIT |c|))))) 

(DEFUN |MATSTOR;copyCol!| (|bCol| |bb| |j| |n1| $)
  (PROG (|i|)
    (RETURN
     (SEQ (LETT |i| 0 . #1=(|MATSTOR;copyCol!|)) G190
          (COND ((QSGREATERP |i| |n1|) (GO G191)))
          (SEQ (EXIT (SETELT |bCol| |i| (ELT (ELT |bb| |i|) |j|))))
          (LETT |i| (QSADD1 |i|) . #1#) (GO G190) G191 (EXIT NIL))))) 

(DEFUN |MATSTOR;times!;4M;9| (|c| |a| |b| $)
  (PROG (|sum| |k| |cRow| |aRow| |i| #1=#:G760 |j| |n1| |m1| |bCol| |cc| |bb|
         |aa| |p| |n| |m|)
    (RETURN
     (SEQ (LETT |m| (SPADCALL |a| (QREFELT $ 9)) . #2=(|MATSTOR;times!;4M;9|))
          (LETT |n| (SPADCALL |a| (QREFELT $ 10)) . #2#)
          (LETT |p| (SPADCALL |b| (QREFELT $ 10)) . #2#)
          (COND
           ((EQL (SPADCALL |b| (QREFELT $ 9)) |n|)
            (COND
             ((EQL (SPADCALL |c| (QREFELT $ 9)) |m|)
              (COND
               ((NULL (EQL (SPADCALL |c| (QREFELT $ 10)) |p|))
                (EXIT
                 (|error| #3="times!: matrices of incompatible dimensions")))))
             (#4='T (EXIT (|error| #3#)))))
           (#4# (EXIT (|error| #3#))))
          (LETT |aa| (|MATSTOR;rep| |a| $) . #2#)
          (LETT |bb| (|MATSTOR;rep| |b| $) . #2#)
          (LETT |cc| (|MATSTOR;rep| |c| $) . #2#)
          (LETT |bCol| (SPADCALL |n| (|spadConstant| $ 22) (QREFELT $ 24))
                . #2#)
          (LETT |m1| (- |m| 1) . #2#) (LETT |n1| (- |n| 1) . #2#)
          (SEQ (LETT |j| 0 . #2#) (LETT #1# (- |p| 1) . #2#) G190
               (COND ((QSGREATERP |j| #1#) #5=(GO G191)))
               (SEQ (|MATSTOR;copyCol!| |bCol| |bb| |j| |n1| $)
                    (EXIT
                     (SEQ (LETT |i| 0 . #2#) G190
                          (COND ((QSGREATERP |i| |m1|) #5#))
                          (SEQ (LETT |aRow| (ELT |aa| |i|) . #2#)
                               (LETT |cRow| (ELT |cc| |i|) . #2#)
                               (LETT |sum| (|spadConstant| $ 22) . #2#)
                               (SEQ (LETT |k| 0 . #2#) G190
                                    (COND ((QSGREATERP |k| |n1|) #5#))
                                    (SEQ
                                     (EXIT
                                      (LETT |sum|
                                            (SPADCALL |sum|
                                                      (SPADCALL
                                                       (ELT |aRow| |k|)
                                                       (ELT |bCol| |k|)
                                                       (QREFELT $ 19))
                                                      (QREFELT $ 13))
                                            . #2#)))
                                    (LETT |k| (QSADD1 |k|) . #2#) #6=(GO G190)
                                    G191 (EXIT NIL))
                               (EXIT (SETELT |cRow| |j| |sum|)))
                          (LETT |i| (QSADD1 |i|) . #2#) #6# G191 (EXIT NIL))))
               (LETT |j| (QSADD1 |j|) . #2#) #6# G191 (EXIT NIL))
          (EXIT |c|))))) 

(DEFUN |MATSTOR;power!;4MNniM;10| (|a| |b| |c| |m| |p| $)
  (PROG (#1=#:G775 |flag| |nn| |mm|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (LETT |mm| (SPADCALL |a| (QREFELT $ 9))
              . #2=(|MATSTOR;power!;4MNniM;10|))
        (LETT |nn| (SPADCALL |a| (QREFELT $ 10)) . #2#)
        (EXIT
         (COND
          ((EQL |mm| |nn|)
           (SEQ
            (COND
             ((EQL (SPADCALL |b| (QREFELT $ 9)) |mm|)
              (COND
               ((NULL (EQL (SPADCALL |b| (QREFELT $ 10)) |nn|))
                (EXIT
                 (|error| #3="power!: matrices of incompatible dimensions")))))
             (#4='T (EXIT (|error| #3#))))
            (COND
             ((EQL (SPADCALL |c| (QREFELT $ 9)) |mm|)
              (COND
               ((NULL (EQL (SPADCALL |c| (QREFELT $ 10)) |nn|))
                (EXIT
                 (|error| #5="power!: matrices of incompatible dimensions")))))
             (#4# (EXIT (|error| #5#))))
            (COND
             ((EQL (SPADCALL |m| (QREFELT $ 9)) |mm|)
              (COND
               ((NULL (EQL (SPADCALL |m| (QREFELT $ 10)) |nn|))
                (EXIT
                 (|error| #6="power!: matrices of incompatible dimensions")))))
             (#4# (EXIT (|error| #6#))))
            (LETT |flag| 'NIL . #2#) (SPADCALL |b| |m| (QREFELT $ 12))
            (EXIT
             (SEQ G190 NIL
                  (SEQ
                   (COND
                    ((ODDP |p|)
                     (COND
                      (|flag|
                       (SEQ (SPADCALL |c| |b| |a| (QREFELT $ 25))
                            (EXIT (SPADCALL |a| |c| (QREFELT $ 12)))))
                      ('T
                       (SEQ (LETT |flag| 'T . #2#)
                            (EXIT (SPADCALL |a| |b| (QREFELT $ 12))))))))
                   (EXIT
                    (COND ((EQL |p| 1) (PROGN (LETT #1# |a| . #2#) (GO #1#)))
                          ('T
                           (SEQ (LETT |p| (QUOTIENT2 |p| 2) . #2#)
                                (SPADCALL |c| |b| |b| (QREFELT $ 25))
                                (EXIT (SPADCALL |b| |c| (QREFELT $ 12))))))))
                  NIL (GO G190) G191 (EXIT NIL)))))
          (#4# (|error| "power!: matrix must be square"))))))
      #1# (EXIT #1#))))) 

(DEFUN |MATSTOR;^;MNniM;11| (|m| |n| $)
  (PROG (|c| |b| |a|)
    (RETURN
     (SEQ
      (COND
       ((NULL (SPADCALL |m| (QREFELT $ 28)))
        (|error| "^: matrix must be square"))
       ('T
        (SEQ
         (LETT |a| (SPADCALL |m| (QREFELT $ 29)) . #1=(|MATSTOR;^;MNniM;11|))
         (LETT |b| (SPADCALL |m| (QREFELT $ 29)) . #1#)
         (LETT |c| (SPADCALL |m| (QREFELT $ 29)) . #1#)
         (EXIT (SPADCALL |a| |b| |c| |m| |n| (QREFELT $ 26)))))))))) 

(DEFUN |StorageEfficientMatrixOperations| (#1=#:G779)
  (PROG ()
    (RETURN
     (PROG (#2=#:G780)
       (RETURN
        (COND
         ((LETT #2#
                (|lassocShiftWithFunction| (LIST (|devaluate| #1#))
                                           (HGET |$ConstructorCache|
                                                 '|StorageEfficientMatrixOperations|)
                                           '|domainEqualList|)
                . #3=(|StorageEfficientMatrixOperations|))
          (|CDRwithIncrement| #2#))
         ('T
          (UNWIND-PROTECT
              (PROG1 (|StorageEfficientMatrixOperations;| #1#)
                (LETT #2# T . #3#))
            (COND
             ((NOT #2#)
              (HREM |$ConstructorCache|
                    '|StorageEfficientMatrixOperations|))))))))))) 

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

(MAKEPROP '|StorageEfficientMatrixOperations| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) (|NonNegativeInteger|)
              (|Matrix| 6) (0 . |nrows|) (5 . |ncols|) (10 . |One|)
              |MATSTOR;copy!;3M;2| (14 . +) |MATSTOR;plus!;4M;3| (20 . -)
              |MATSTOR;minus!;3M;4| (25 . -) |MATSTOR;minus!;4M;5| (31 . *)
              |MATSTOR;leftScalarTimes!;MR2M;6|
              |MATSTOR;rightScalarTimes!;2MRM;7| (37 . |Zero|)
              (|PrimitiveArray| 6) (41 . |new|) |MATSTOR;times!;4M;9|
              |MATSTOR;power!;4MNniM;10| (|Boolean|) (47 . |square?|)
              (52 . |copy|) |MATSTOR;^;MNniM;11|)
           '#(|times!| 57 |rightScalarTimes!| 64 |power!| 71 |plus!| 80
              |minus!| 87 |leftScalarTimes!| 100 |copy!| 107 ^ 113)
           'NIL
           (CONS (|makeByteWordVec2| 1 'NIL)
                 (CONS '#()
                       (CONS '#()
                             (|makeByteWordVec2| 30
                                                 '(1 8 7 0 9 1 8 7 0 10 0 6 0
                                                   11 2 6 0 0 0 13 1 6 0 0 15 2
                                                   6 0 0 0 17 2 6 0 0 0 19 0 6
                                                   0 22 2 23 0 7 6 24 1 8 27 0
                                                   28 1 8 0 0 29 3 0 8 8 8 8 25
                                                   3 0 8 8 8 6 21 5 0 8 8 8 8 8
                                                   7 26 3 0 8 8 8 8 14 3 0 8 8
                                                   8 8 18 2 0 8 8 8 16 3 0 8 8
                                                   6 8 20 2 0 8 8 8 12 2 0 8 8
                                                   7 30)))))
           '|lookupComplete|)) 
