
(/VERSIONCHECK 2) 

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

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

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

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

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

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

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

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

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

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

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

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

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

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