|
152 | 152 |
|
153 | 153 | ;; To debug, delete the comments around PRINT and BREAK statements. |
154 | 154 |
|
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)) |
157 | 157 |
|
158 | | -(defun tfgeli1 (ax n m) |
| 158 | +(defun tfgeli1 (ax *n* *m*) |
159 | 159 | (prog (k l delta variableorder inconsistentrows |
160 | 160 | dependentrows nrow nvar rank permsign result) |
161 | 161 | (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)) |
165 | 165 | ;; (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*)))) |
168 | 168 | (do ((i 1 (1+ i))) |
169 | | - ((> i n)) |
| 169 | + ((> i *n*)) |
170 | 170 | (setf (aref *row* i) i)) |
171 | 171 | (do ((i 1 (1+ i))) |
172 | | - ((> i m)) |
| 172 | + ((> i *m*)) |
173 | 173 | (setf (aref *col* i) i) (setf (aref *colinv* i) i)) |
174 | 174 | (setq result |
175 | 175 | (cond (*rank* (forward t) rank) |
176 | 176 | (*det* (forward t) |
177 | | - (cond ((= nrow n) (cond (permsign (pminus delta)) |
| 177 | + (cond ((= nrow *n*) (cond (permsign (pminus delta)) |
178 | 178 | (t delta))) |
179 | 179 | (t 0))) |
180 | 180 | (*inv* (forward t) (backward) (recoverorder1)) |
|
191 | 191 | (setq delta 1) ;DELTA HOLDS THE CURRENT DETERMINANT |
192 | 192 | (do ((k 1 (1+ k)) |
193 | 193 | (nvar nvar) ;PROTECTS AGAINST TEMPORARAY RESETS DONE IN PIVOT |
194 | | - (m m)) |
| 194 | + (*m* *m*)) |
195 | 195 | ((or (> k nrow) (> k nvar))) |
196 | 196 | (cond ((pivot ax k *cpivot) (return nil))) |
197 | 197 | ;; PIVOT IS T IF THERE IS NO MORE NON-ZERO ROW LEFT. THEN GET OUT OF THE LOOP |
198 | 198 | (do ((i (1+ k) (1+ i))) |
199 | 199 | ((> i nrow)) |
200 | 200 | (do ((j (1+ k) (1+ j))) |
201 | | - ((> j m)) |
| 201 | + ((> j *m*)) |
202 | 202 | (setf (aref ax (aref *row* i) (aref *col* j)) |
203 | 203 | (pquotient (pdifference (ptimes (aref ax (aref *row* k) (aref *col* k)) |
204 | 204 | (aref ax (aref *row* i) (aref *col* j))) |
|
210 | 210 | (setf (aref ax (aref *row* i) (aref *col* k)) 0)) |
211 | 211 | (setq delta (aref ax (aref *row* k) (aref *col* k)))) |
212 | 212 | ;; 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))) |
214 | 214 | (setq rank (min nrow nvar))) |
215 | 215 |
|
216 | 216 | ;; BACKWARD SUBSTITUTION |
217 | 217 | (defun backward () |
218 | | - (declare(special ax delta m rank)) |
| 218 | + (declare(special ax delta *m* rank)) |
219 | 219 | (do ((i (1- rank) (1- i))) |
220 | 220 | ((< i 1)) |
221 | 221 | (do ((l (1+ rank) (1+ l))) |
222 | | - ((> l m)) |
| 222 | + ((> l *m*)) |
223 | 223 | (setf (aref ax (aref *row* i) (aref *col* l)) |
224 | 224 | (let ((mess1 (pdifference |
225 | 225 | (ptimes (aref ax (aref *row* i) (aref *col* l)) |
|
253 | 253 | ((= i 0)) |
254 | 254 | (setq variableorder (cons i variableorder))) |
255 | 255 | (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) |
258 | 258 | (setq dependentrows (cons (aref *row* i) dependentrows))) |
259 | 259 | (t (setq inconsistentrows (cons (aref *row* i) inconsistentrows))))) |
260 | 260 | (do ((i 1 (1+ i))) |
261 | | - ((> i n)) |
| 261 | + ((> i *n*)) |
262 | 262 | (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) |
265 | 265 | (setq l i) |
266 | 266 | loop |
267 | 267 | (setq k (aref *row* (aref *colinv* l))) |
268 | 268 | (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) |
271 | 271 | (setq l k) |
272 | 272 | (go loop)))))))) |
273 | 273 |
|
|
276 | 276 | ((= i 0)) |
277 | 277 | (setq variableorder (cons (aref *col* i) variableorder))) |
278 | 278 | (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) |
281 | 281 | (setq dependentrows (cons (aref *row* i) dependentrows))) |
282 | 282 | (t (setq inconsistentrows (cons (aref *row* i) inconsistentrows))))) |
283 | 283 | (do ((i 1 (1+ i))) |
284 | | - ((> i n)) |
| 284 | + ((> i *n*)) |
285 | 285 | (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) |
288 | 288 | (setq l i) |
289 | 289 | loop |
290 | 290 | (setq k (aref *row* l)) |
291 | 291 | (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) |
294 | 294 | (setq l k) |
295 | 295 | (go loop))))))) |
296 | 296 | (do ((i 1 (1+ i))) |
297 | 297 | ((> i nvar)) |
298 | 298 | (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) |
301 | 301 | (setq l i) |
302 | 302 | loop2 |
303 | 303 | (setq k (aref *col* l)) |
304 | 304 | (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) |
307 | 307 | (setq l k) |
308 | 308 | (go loop2)))))))) |
309 | 309 |
|
310 | 310 | ;;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*)) |
313 | 313 | (setf (aref ax j k) (aref ax i k)))) |
314 | 314 |
|
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*)) |
317 | 317 | (setf (aref ax k j) (aref ax k i)))) |
318 | 318 |
|
319 | 319 | ;;COMPLEXITY IS DEFINED AS FOLLOWS |
|
368 | 368 | ((> i nrow)) |
369 | 369 | (cond ((or *cpivot (not (equal (aref ax (aref *row* i) (aref *col* k)) 0))) |
370 | 370 | (cond ((> complexity/i/min |
371 | | - (setq complexity/i (complexity/row ax i k m))) |
| 371 | + (setq complexity/i (complexity/row ax i k *m*))) |
372 | 372 | (setq row/optimal i complexity/i/min complexity/i)))))) |
373 | 373 | ;; EXCHANGE THE ROWS K AND ROW/OPTIMAL |
374 | 374 | (exchangerow k row/optimal) |
|
381 | 381 | (return nil)) |
382 | 382 | (t (do ((i k (1+ i))) ((= i nvar)) |
383 | 383 | (setf (aref *col* i) (aref *col* (1+ i)))) |
384 | | - (setq nvar (1- nvar) m (1- m)) |
| 384 | + (setq nvar (1- nvar) *m* (1- *m*)) |
385 | 385 | (go findrow))))) |
386 | 386 |
|
387 | 387 | ;;STEP3 ... FIND THE OPTIMAL COLUMN |
|
397 | 397 | (complexity (aref ax (aref *row* k) (aref *col* j))))) |
398 | 398 | (setq col/optimal j |
399 | 399 | 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*))) |
401 | 401 | ((equal complexity/det/min complexity/det) |
402 | 402 | (cond ((> complexity/j/min |
403 | 403 | (setq complexity/j |
404 | | - (complexity/col ax j (1+ k) n))) |
| 404 | + (complexity/col ax j (1+ k) *n*))) |
405 | 405 | (setq col/optimal j |
406 | 406 | complexity/det/min complexity/det |
407 | 407 | complexity/j/min complexity/j)))))))) |
|
456 | 456 | (t (putprop *linelabel* t 'nodisp))) |
457 | 457 | *linelabel*)) |
458 | 458 |
|
459 | | -(declare-top (unspecial permsign rank delta nrow nvar n m variableorder |
| 459 | +(declare-top (unspecial permsign rank delta nrow nvar *n* *m* variableorder |
460 | 460 | dependentrows inconsistentrows)) |
0 commit comments