| 345 | | (assq (car a) math-decls-cache)))) |
|---|
| 346 | | (memq 'vector (nth 1 decl)))))) |
|---|
| 347 | | |
|---|
| | 359 | (assq (car a) math-decls-cache))) |
|---|
| | 360 | val) |
|---|
| | 361 | (cond |
|---|
| | 362 | ((memq 'matrix (nth 1 decl)) |
|---|
| | 363 | t) |
|---|
| | 364 | ((and (eq (car a) 'var) |
|---|
| | 365 | (boundp (nth 2 a)) |
|---|
| | 366 | (setq val (symbol-value (nth 2 a)))) |
|---|
| | 367 | (math-check-known-matrixp val)) |
|---|
| | 368 | (t |
|---|
| | 369 | nil)))))) |
|---|
| | 370 | |
|---|
| | 371 | ;;; Given that A is a matrix, try to prove that it is a square matrix. |
|---|
| | 372 | (defun math-check-known-square-matrixp (a) |
|---|
| | 373 | (cond ((math-square-matrixp a) |
|---|
| | 374 | t) |
|---|
| | 375 | ((eq (car-safe a) '^) |
|---|
| | 376 | (math-check-known-square-matrixp (nth 1 a))) |
|---|
| | 377 | (t |
|---|
| | 378 | (let ((decl (if (eq (car a) 'var) |
|---|
| | 379 | (or (assq (nth 2 a) math-decls-cache) |
|---|
| | 380 | math-decls-all) |
|---|
| | 381 | (assq (car a) math-decls-cache))) |
|---|
| | 382 | val) |
|---|
| | 383 | (cond |
|---|
| | 384 | ((memq 'sqmatrix (nth 1 decl)) |
|---|
| | 385 | t) |
|---|
| | 386 | ((and (eq (car a) 'var) |
|---|
| | 387 | (boundp (nth 2 a)) |
|---|
| | 388 | (setq val (symbol-value (nth 2 a)))) |
|---|
| | 389 | (math-check-known-square-matrixp val)) |
|---|
| | 390 | ((and (or |
|---|
| | 391 | (integerp calc-matrix-mode) |
|---|
| | 392 | (eq calc-matrix-mode 'sqmatrix)) |
|---|
| | 393 | (eq (car-safe a) 'var)) |
|---|
| | 394 | t) |
|---|
| | 395 | ((memq 'matrix (nth 1 decl)) |
|---|
| | 396 | nil) |
|---|
| | 397 | (t |
|---|
| | 398 | nil)))))) |
|---|
| | 1431 | (and (math-identity-matrix-p a t) |
|---|
| | 1432 | (or (and (eq (car-safe b) 'calcFunc-idn) |
|---|
| | 1433 | (= (length b) 2) |
|---|
| | 1434 | (list 'calcFunc-idn (math-mul |
|---|
| | 1435 | (nth 1 (nth 1 a)) |
|---|
| | 1436 | (nth 1 b)) |
|---|
| | 1437 | (1- (length a)))) |
|---|
| | 1438 | (and (math-known-scalarp b) |
|---|
| | 1439 | (list 'calcFunc-idn (math-mul |
|---|
| | 1440 | (nth 1 (nth 1 a)) b) |
|---|
| | 1441 | (1- (length a)))) |
|---|
| | 1442 | (and (math-known-matrixp b) |
|---|
| | 1443 | (math-mul (nth 1 (nth 1 a)) b)))) |
|---|
| | 1444 | (and (math-identity-matrix-p b t) |
|---|
| | 1445 | (or (and (eq (car-safe a) 'calcFunc-idn) |
|---|
| | 1446 | (= (length a) 2) |
|---|
| | 1447 | (list 'calcFunc-idn (math-mul (nth 1 a) |
|---|
| | 1448 | (nth 1 (nth 1 b))) |
|---|
| | 1449 | (1- (length b)))) |
|---|
| | 1450 | (and (math-known-scalarp a) |
|---|
| | 1451 | (list 'calcFunc-idn (math-mul a (nth 1 (nth 1 b))) |
|---|
| | 1452 | (1- (length b)))) |
|---|
| | 1453 | (and (math-known-matrixp a) |
|---|
| | 1454 | (math-mul a (nth 1 (nth 1 b)))))) |
|---|
| | 1950 | ((and (eq (car-safe a) '*) |
|---|
| | 1951 | (or |
|---|
| | 1952 | (and |
|---|
| | 1953 | (math-known-matrixp (nth 1 a)) |
|---|
| | 1954 | (math-known-matrixp (nth 2 a))) |
|---|
| | 1955 | (and |
|---|
| | 1956 | calc-matrix-mode |
|---|
| | 1957 | (not (eq calc-matrix-mode 'scalar)) |
|---|
| | 1958 | (and (not (math-known-scalarp (nth 1 a))) |
|---|
| | 1959 | (not (math-known-scalarp (nth 2 a))))))) |
|---|
| | 1960 | (if (and (= b -1) |
|---|
| | 1961 | (math-known-square-matrixp (nth 1 a)) |
|---|
| | 1962 | (math-known-square-matrixp (nth 2 a))) |
|---|
| | 1963 | (list '* (list '^ (nth 2 a) -1) (list '^ (nth 1 a) -1)) |
|---|
| | 1964 | (list '^ a b))) |
|---|