2 (in-package :lineal.overload
)
5 (if (= (mtrix-dimdom a
) (mtrix-dimcodom a
))
7 (throw 'over-ex
"Determinants only work with square matrices.")))
9 (defun over-r-ef (&rest args
)
10 (let ((a (apply #'over-cat args
)))
12 a
(r-ef (mtrix-elems a
)))))
14 (defun over-rr-ef (&rest args
)
15 (let ((a (apply #'over-cat args
)))
17 a
(rr-ef (mtrix-elems a
)))))
19 (defmethod over-multv-inverse ((a mtrix
))
20 (when (zerop (over-det a
))
21 (throw 'over-ex
"Determinant is zero, no inverse exists."))
23 a
(mtrix-inverse (mtrix-elems a
))))
25 ;V Raise matrix /a/ to exponent /b/.V
26 (defmethod over-expt ((a mtrix
) (b integer
))
27 ;V Matrix must be square.V
28 (unless (= (mtrix-dimdom a
)
30 (throw 'over-ex
"Only square matrices can be raised to exponents."))
31 ;V If negative power, raise inverse V
32 ;V of /a/ to negative /b/ power. V
34 (setq a
(over-multv-inverse a
)
36 ;V When /b/ is zero, return the identity matrix.V
39 :dimdom
(mtrix-dimdom a
)
40 :dimcodom
(mtrix-dimdom a
)
41 :elems
(mtrix-square-identity (mtrix-dimdom a
)))
43 :for c
= a
:then
(mult2n a c
)
44 :finally
(return c
))))