4 ;;; taken from KMR's clsql package
5 (declaim (inline delistify
))
6 (defun delistify (list)
7 "Some MOPs, like openmcl 0.14.2, cons attribute values in a list."
8 (if (and (listp list
) (null (cdr list
)))
12 (defmacro defmatrixclass
(type direct-superclasses
&key
18 (unless direct-superclasses
(setf direct-superclasses
'(matrix)))
20 (defclass ,type
,direct-superclasses
21 ((initial-element :accessor initial-element
22 :initarg
:initial-element
:initform
,initial-element
))
23 (:metaclass standard-matrix-class
)
24 ,@(when element-type
`((:element-type
,(delistify element-type
))))
25 ,@(when accumulator-type
`((:accumulator-type
,(delistify accumulator-type
))))
26 ,@(when val-format
`((:val-format
,(delistify val-format
))))
27 ,@(when minval
`((:minval
,(if (symbolp minval
) (symbol-value minval
) minval
))))
28 ,@(when maxval
`((:maxval
,(if (symbolp maxval
) (symbol-value minval
) maxval
)))))))
30 (defmatrixclass t-matrix
()
34 (defmatrixclass number-matrix
(t-matrix)
36 :accumulator-type number
)
38 (defmatrixclass real-matrix
(number-matrix)
40 :accumulator-type real
)
42 (defmatrixclass complex-matrix
(number-matrix)
44 :accumulator-type complex
)
46 (defmatrixclass float-matrix
(real-matrix)
48 :accumulator-type float
51 (defmatrixclass integer-matrix
(real-matrix)
53 :accumulator-type integer
56 (defmatrixclass unsigned-byte-matrix
(integer-matrix)
57 :element-type
(unsigned-byte *)
58 :accumulator-type
(unsigned-byte *)
61 (defmatrixclass bit-matrix
(integer-matrix) :element-type
(unsigned-byte 1)
62 :accumulator-type
(signed-byte 32)
67 (defmatrixclass ub8-matrix
(unsigned-byte-matrix)
68 :element-type
(unsigned-byte 8)
69 :accumulator-type
(unsigned-byte 32)
71 :maxval
#.
(- (expt 2 8) 1))
73 (defmatrixclass ub16-matrix
(unsigned-byte-matrix)
74 :element-type
(unsigned-byte 16)
75 :accumulator-type
(unsigned-byte 32)
77 :maxval
#.
(- (expt 2 16) 1))
79 (defmatrixclass ub32-matrix
(unsigned-byte-matrix)
80 :element-type
(unsigned-byte 32)
81 :accumulator-type
(unsigned-byte 32)
83 :maxval
#.
(- (expt 2 32) 1))
85 (defmatrixclass sb8-matrix
(integer-matrix)
86 :element-type
(signed-byte 8)
87 :accumulator-type
(signed-byte 32)
88 :minval
#.
(- (expt 2 7))
89 :maxval
#.
(- (expt 2 7) 1))
91 (defmatrixclass sb16-matrix
(integer-matrix)
92 :element-type
(signed-byte 16)
93 :accumulator-type
(signed-byte 32)
94 :minval
#.
(- (expt 2 15))
95 :maxval
#.
(- (expt 2 15) 1))
97 (defmatrixclass sb32-matrix
(integer-matrix)
98 :element-type
(signed-byte 32)
99 :accumulator-type
(signed-byte 32)
100 :minval
#.
(- (expt 2 31))
101 :maxval
#.
(- (expt 2 31) 1))
103 (defmatrixclass fixnum-matrix
(integer-matrix)
105 :accumulator-type
(unsigned-byte 32)
106 :minval most-negative-fixnum
107 :maxval most-positive-fixnum
)
109 (defmatrixclass single-float-matrix
(float-matrix)
110 :element-type single-float
111 :accumulator-type single-float
113 :minval most-negative-single-float
114 :maxval most-positive-single-float
)
116 (defmatrixclass double-float-matrix
(float-matrix)
117 :element-type double-float
118 :accumulator-type double-float
120 :minval most-negative-double-float
121 :maxval most-positive-double-float
)