1 (in-package :cl-tuples
)
3 ;; float that fits within range of x86 hardware register minus tag (rather sbcl oriented)
5 #+sbcl
`(single-float (#.
(- (expt 2f0
63))) (#.
(expt 2f0
63)))
9 #.
(coerce pi
'fast-float
))
11 ;; TO DO -- possibly can be replaced by alexandria::symbolicate -- must check
12 (defun make-adorned-symbol (name &key prefix suffix asterisk package
)
13 "Construct symbol for use as a function name, prefixed or suffixed
14 with some string, and optionally an added asterisk"
15 (check-type name
(or string symbol
))
16 (check-type prefix
(or symbol string null
))
17 (check-type suffix
(or symbol string null
))
18 (intern (concatenate 'string
29 (if package package
*package
*)))
31 (defun last-char (str)
32 (char str
(1- (length str
))))
34 (defun symbol-to-string (sym)
35 "If the argument is a symbol or string, return it as a string."
36 (check-type sym
(or symbol string
))
43 (defun is-asterisk-symbol (s)
45 ((ss (symbol-to-string s
)))
46 (eql (aref ss
(1- (length ss
))) #\
*)))
49 (defmacro multiply-arguments
(operator factor arguments
)
50 `(,operator
,@(mapcar (lambda (argument) `(* ,factor
,argument
)) arguments
)))
52 (defun matrix-symbol (i j
&optional
(prefix '#:e
))
53 "Construct a symbol that will represent an elemnet of a matrix."
54 (find-symbol (format NIL
"~A~D~D" prefix i j
) #.
(find-package '#:cl-tuples
)))
56 (defun matrix-minor (x y length
&optional
(prefix '#:e
))
57 (let ((symbol-prefix (format NIL
"~A~D~:*~D" '#:matrix
(1- length
))))
58 `(,(find-symbol (concatenate 'string symbol-prefix
#.
(string '#:-determinant
*)) #.
(find-package '#:cl-tuples
))
59 (,(find-symbol (concatenate 'string symbol-prefix
#.
(string '#:-values
*)) #.
(find-package '#:cl-tuples
))
61 (for i from
1 to length
)
63 (for j from
1 to length
)
64 (unless (or (eql i x
) (eql j y
))
65 (in values
(collect (matrix-symbol (1- i
) (1- j
) prefix
))))))))))
67 (defun matrix-cofactors (length)
69 (for i from
1 to length
)
71 (for j from
1 to length
)
72 (for value
= (matrix-minor i j length
))
74 (collect (if (oddp (+ i j
))