Skip to content

Commit de14fda

Browse files
TomasRikerrtoy
authored andcommitted
mat.lisp: rename special variables N/M to *N*/*M*
They are really being used in a special, non-lexical way.
1 parent 353b811 commit de14fda

1 file changed

Lines changed: 43 additions & 43 deletions

File tree

src/mat.lisp

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -152,29 +152,29 @@
152152

153153
;; To debug, delete the comments around PRINT and BREAK statements.
154154

155-
(declare-top (special permsign rank delta nrow nvar n m variableorder
156-
dependentrows inconsistentrows k))
155+
(declare-top (special permsign rank delta nrow nvar *n* *m* variableorder
156+
dependentrows inconsistentrows))
157157

158-
(defun tfgeli1 (ax n m)
158+
(defun tfgeli1 (ax *n* *m*)
159159
(prog (k l delta variableorder inconsistentrows
160160
dependentrows nrow nvar rank permsign result)
161161
(setq ax (get-array-pointer ax))
162-
(setq *col* (make-array (1+ m) :initial-element 0))
163-
(setq *row* (make-array (1+ n) :initial-element 0))
164-
(setq *colinv* (make-array (1+ m) :initial-element 0))
162+
(setq *col* (make-array (1+ *m*) :initial-element 0))
163+
(setq *row* (make-array (1+ *n*) :initial-element 0))
164+
(setq *colinv* (make-array (1+ *m*) :initial-element 0))
165165
;; (PRINT 'ONESTEP-LIPSON-WITH-PIVOTING)
166-
(setq nrow n)
167-
(setq nvar (cond (*rank* m) (*det* m) (*inv* n) (*ech* m) (*tri* m) (t (1- m))))
166+
(setq nrow *n*)
167+
(setq nvar (cond (*rank* *m*) (*det* *m*) (*inv* *n*) (*ech* *m*) (*tri* *m*) (t (1- *m*))))
168168
(do ((i 1 (1+ i)))
169-
((> i n))
169+
((> i *n*))
170170
(setf (aref *row* i) i))
171171
(do ((i 1 (1+ i)))
172-
((> i m))
172+
((> i *m*))
173173
(setf (aref *col* i) i) (setf (aref *colinv* i) i))
174174
(setq result
175175
(cond (*rank* (forward t) rank)
176176
(*det* (forward t)
177-
(cond ((= nrow n) (cond (permsign (pminus delta))
177+
(cond ((= nrow *n*) (cond (permsign (pminus delta))
178178
(t delta)))
179179
(t 0)))
180180
(*inv* (forward t) (backward) (recoverorder1))
@@ -191,14 +191,14 @@
191191
(setq delta 1) ;DELTA HOLDS THE CURRENT DETERMINANT
192192
(do ((k 1 (1+ k))
193193
(nvar nvar) ;PROTECTS AGAINST TEMPORARAY RESETS DONE IN PIVOT
194-
(m m))
194+
(*m* *m*))
195195
((or (> k nrow) (> k nvar)))
196196
(cond ((pivot ax k *cpivot) (return nil)))
197197
;; PIVOT IS T IF THERE IS NO MORE NON-ZERO ROW LEFT. THEN GET OUT OF THE LOOP
198198
(do ((i (1+ k) (1+ i)))
199199
((> i nrow))
200200
(do ((j (1+ k) (1+ j)))
201-
((> j m))
201+
((> j *m*))
202202
(setf (aref ax (aref *row* i) (aref *col* j))
203203
(pquotient (pdifference (ptimes (aref ax (aref *row* k) (aref *col* k))
204204
(aref ax (aref *row* i) (aref *col* j)))
@@ -210,16 +210,16 @@
210210
(setf (aref ax (aref *row* i) (aref *col* k)) 0))
211211
(setq delta (aref ax (aref *row* k) (aref *col* k))))
212212
;; UNDOES COLUMN HACK IN PIVOT.
213-
(or *cpivot (do ((i 1 (1+ i))) ((> i m)) (setf (aref *col* i) i)))
213+
(or *cpivot (do ((i 1 (1+ i))) ((> i *m*)) (setf (aref *col* i) i)))
214214
(setq rank (min nrow nvar)))
215215

216216
;; BACKWARD SUBSTITUTION
217217
(defun backward ()
218-
(declare(special ax delta m rank))
218+
(declare(special ax delta *m* rank))
219219
(do ((i (1- rank) (1- i)))
220220
((< i 1))
221221
(do ((l (1+ rank) (1+ l)))
222-
((> l m))
222+
((> l *m*))
223223
(setf (aref ax (aref *row* i) (aref *col* l))
224224
(let ((mess1 (pdifference
225225
(ptimes (aref ax (aref *row* i) (aref *col* l))
@@ -253,21 +253,21 @@
253253
((= i 0))
254254
(setq variableorder (cons i variableorder)))
255255
(do ((i (1+ rank) (1+ i)))
256-
((> i n))
257-
(cond ((equal (aref ax (aref *row* i) (aref *col* m)) 0)
256+
((> i *n*))
257+
(cond ((equal (aref ax (aref *row* i) (aref *col* *m*)) 0)
258258
(setq dependentrows (cons (aref *row* i) dependentrows)))
259259
(t (setq inconsistentrows (cons (aref *row* i) inconsistentrows)))))
260260
(do ((i 1 (1+ i)))
261-
((> i n))
261+
((> i *n*))
262262
(cond ((not (= (aref *row* (aref *colinv* i)) i))
263-
(prog (l)
264-
(moverow ax n m i 0)
263+
(prog (k l)
264+
(moverow ax *n* *m* i 0)
265265
(setq l i)
266266
loop
267267
(setq k (aref *row* (aref *colinv* l)))
268268
(setf (aref *row* (aref *colinv* l)) l)
269-
(cond ((= k i) (moverow ax n m 0 l))
270-
(t (moverow ax n m k l)
269+
(cond ((= k i) (moverow ax *n* *m* 0 l))
270+
(t (moverow ax *n* *m* k l)
271271
(setq l k)
272272
(go loop))))))))
273273

@@ -276,44 +276,44 @@
276276
((= i 0))
277277
(setq variableorder (cons (aref *col* i) variableorder)))
278278
(do ((i (1+ rank) (1+ i)))
279-
((> i n))
280-
(cond ((equal (aref ax (aref *row* i) (aref *col* m)) 0)
279+
((> i *n*))
280+
(cond ((equal (aref ax (aref *row* i) (aref *col* *m*)) 0)
281281
(setq dependentrows (cons (aref *row* i) dependentrows)))
282282
(t (setq inconsistentrows (cons (aref *row* i) inconsistentrows)))))
283283
(do ((i 1 (1+ i)))
284-
((> i n))
284+
((> i *n*))
285285
(cond ((not (= (aref *row* i) i))
286-
(prog (l)
287-
(moverow ax n m i 0)
286+
(prog (k l)
287+
(moverow ax *n* *m* i 0)
288288
(setq l i)
289289
loop
290290
(setq k (aref *row* l))
291291
(setf (aref *row* l) l)
292-
(cond ((= k i) (moverow ax n m 0 l))
293-
(t (moverow ax n m k l)
292+
(cond ((= k i) (moverow ax *n* *m* 0 l))
293+
(t (moverow ax *n* *m* k l)
294294
(setq l k)
295295
(go loop)))))))
296296
(do ((i 1 (1+ i)))
297297
((> i nvar))
298298
(cond ((not (= (aref *col* i) i))
299-
(prog ()
300-
(movecol ax n m i 0)
299+
(prog (k l)
300+
(movecol ax *n* *m* i 0)
301301
(setq l i)
302302
loop2
303303
(setq k (aref *col* l))
304304
(setf (aref *col* l) l)
305-
(cond ((= k i) (movecol ax n m 0 l))
306-
(t (movecol ax n m k l)
305+
(cond ((= k i) (movecol ax *n* *m* 0 l))
306+
(t (movecol ax *n* *m* k l)
307307
(setq l k)
308308
(go loop2))))))))
309309

310310
;;THIS PROGRAM IS USED IN REARRANGEMENT
311-
(defun moverow (ax n m i j)
312-
(do ((k 1 (1+ k))) ((> k m))
311+
(defun moverow (ax *n* *m* i j)
312+
(do ((k 1 (1+ k))) ((> k *m*))
313313
(setf (aref ax j k) (aref ax i k))))
314314

315-
(defun movecol (ax n m i j)
316-
(do ((k 1 (1+ k))) ((> k n))
315+
(defun movecol (ax *n* *m* i j)
316+
(do ((k 1 (1+ k))) ((> k *n*))
317317
(setf (aref ax k j) (aref ax k i))))
318318

319319
;;COMPLEXITY IS DEFINED AS FOLLOWS
@@ -368,7 +368,7 @@
368368
((> i nrow))
369369
(cond ((or *cpivot (not (equal (aref ax (aref *row* i) (aref *col* k)) 0)))
370370
(cond ((> complexity/i/min
371-
(setq complexity/i (complexity/row ax i k m)))
371+
(setq complexity/i (complexity/row ax i k *m*)))
372372
(setq row/optimal i complexity/i/min complexity/i))))))
373373
;; EXCHANGE THE ROWS K AND ROW/OPTIMAL
374374
(exchangerow k row/optimal)
@@ -381,7 +381,7 @@
381381
(return nil))
382382
(t (do ((i k (1+ i))) ((= i nvar))
383383
(setf (aref *col* i) (aref *col* (1+ i))))
384-
(setq nvar (1- nvar) m (1- m))
384+
(setq nvar (1- nvar) *m* (1- *m*))
385385
(go findrow)))))
386386

387387
;;STEP3 ... FIND THE OPTIMAL COLUMN
@@ -397,11 +397,11 @@
397397
(complexity (aref ax (aref *row* k) (aref *col* j)))))
398398
(setq col/optimal j
399399
complexity/det/min complexity/det
400-
complexity/j/min (complexity/col ax j (1+ k) n)))
400+
complexity/j/min (complexity/col ax j (1+ k) *n*)))
401401
((equal complexity/det/min complexity/det)
402402
(cond ((> complexity/j/min
403403
(setq complexity/j
404-
(complexity/col ax j (1+ k) n)))
404+
(complexity/col ax j (1+ k) *n*)))
405405
(setq col/optimal j
406406
complexity/det/min complexity/det
407407
complexity/j/min complexity/j))))))))
@@ -456,5 +456,5 @@
456456
(t (putprop *linelabel* t 'nodisp)))
457457
*linelabel*))
458458

459-
(declare-top (unspecial permsign rank delta nrow nvar n m variableorder
459+
(declare-top (unspecial permsign rank delta nrow nvar *n* *m* variableorder
460460
dependentrows inconsistentrows))

0 commit comments

Comments
 (0)