3 (if (= (mtrix-dimdom a
) (mtrix-dimcodom a
))
5 (throw 'over-ex
"Determinants only work with square matrices.")))
7 (defun over-r-ef (&rest args
)
8 (let ((a (apply #'over-cat args
)))
10 a
(r-ef (mtrix-elems a
)))))
12 (defun over-rr-ef (&rest args
)
13 (let ((a (apply #'over-cat args
)))
15 a
(rr-ef (mtrix-elems a
)))))
17 (defmethod over-multv-inverse ((a mtrix
))
18 (when (zerop (over-det a
))
19 (throw 'over-ex
"Determinant is zero, no inverse exists."))
21 a
(mtrix-inverse (mtrix-elems a
))))
23 ;V Raise matrix /a/ to exponent /b/.V
24 (defmethod expt2n ((a mtrix
) (b integer
))
25 ;V Matrix must be square.V
26 (unless (= (mtrix-dimdom a
)
28 (throw 'over-ex
"Only square matrices can be raised to exponents."))
29 ;V If negative power, raise inverse V
30 ;V of /a/ to negative /b/ power. V
32 (setq a
(over-multv-inverse a
)
34 ;V When /b/ is zero, return the identity matrix.V
37 :dimdom
(mtrix-dimdom a
)
38 :dimcodom
(mtrix-dimdom a
)
39 :elems
(mtrix-square-identity (mtrix-dimdom a
)))
41 :for c
= a
:then
(mult2n a c
)
42 :finally
(return c
))))