Description
;; Create a random matrice 4 x 6 of "density" 0.3 with |terms| <= 10:
(setf mtrx (mat-aleat 4 6 0.3 10))
========== MATRIX 4 row(s) + 6 column(s) =====
R1=[C1=1]
R2=[C1=-3][C5=9]
R3=
R4=[C2=4][C3=3][C4=-8][C5=-7]
========== END-MATRIX
;; Only & non-null term on the row 1, namely a 1 in column 1.
;; Two non-null terms in row 2, 4 in row 4, the row 3 is null.
;; Travelling in a matrix is conveniently done by P-DISP.
;; Going to the first fake-term of LEFTCOL :
CL-USER(6): (disp-p (setf p (aref (leftcol mtrx) 1)))
((1 0 NIL) (1 1 1) (0 0 NIL))
;; means it is a term in position 1-0, it is fake (nil).
;; the "lefthand" term is in position 1-1, its value is 1:
;; the above term is in position 0-0, it is fake.
;; going to the term in position 1-1:
(disp-p (setf p (left p)))
((1 1 1) (1 0 NIL) (0 1 NIL))
;; the term is in position 1-1, its lefthand term is the
;; starting point in position 1-0, the above term is
;; in position 0-1, it is fake.
;; Running through the row 4 :
(disp-p (setf p (aref (leftcol mtrx) 4)))
((4 0 NIL) (4 5 -7) (3 0 NIL))
(disp-p (setf p (left p)))
((4 5 -7) (4 4 -8) (2 5 9))
(disp-p (setf p (left p)))
((4 4 -8) (4 3 3) (0 4 NIL))
(disp-p (setf p (left p)))
((4 3 3) (4 2 4) (0 3 NIL))
(disp-p (setf p (left p)))
((4 2 4) (4 0 NIL) (0 2 NIL))
(disp-p (setf p (left p)))
((4 0 NIL) (4 5 -7) (3 0 NIL))
;; We are back to the fake term in position 4-0
;; Running through the column 5:
(disp-p (setf p (aref (uplig mtrx) 5)))
((0 5 NIL) (0 4 NIL) (4 5 -7))
(disp-p (setf p (up p)))
((4 5 -7) (4 4 -8) (2 5 9))
(disp-p (setf p (up p)))
((2 5 9) (2 1 -3) (0 5 NIL))
(disp-p (setf p (up p)))
((0 5 NIL) (0 4 NIL) (4 5 -7))
;; "Both" terms in position 0-0 are the same and are fake.
(eq (aref (leftcol mtrx) 0) (aref (uplig mtrx) 0))
T
(disp-p (aref (leftcol mtrx) 0))
((0 0 NIL) (0 6 NIL) (4 0 NIL))
;; it's one of the standard structures to implement
;; sparse matrices.