Skip to content

Commit

Permalink
remove non-float specializations and reduce declares
Browse files Browse the repository at this point in the history
  • Loading branch information
YarinHeffes authored and stylewarning committed Feb 13, 2025
1 parent c6e8015 commit 1befb28
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions library/math/complex.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -194,71 +194,59 @@ below.")
(declare ,conj (Complex ,type -> Complex ,type))
(define (,conj a)
(lisp (Complex ,type) (a)
(cl:declare (cl:type (cl:or ,repr (cl:complex ,repr)) a))
(cl:declare (cl:type (cl:complex ,repr) a))
(cl:conjugate a)))

(specialize complex-equal ,equal (Complex ,type -> Complex ,type -> Boolean))
(inline)
(declare ,equal (Complex ,type -> Complex ,type -> Boolean))
(define (,equal a b)
(lisp Boolean (a b)
(cl:declare (cl:type (cl:or ,repr (cl:complex ,repr)) a b))
(cl:declare (cl:type (cl:complex ,repr) a b))
(cl:= a b)))

(specialize complex-plus ,plus (Complex ,type -> Complex ,type -> Complex ,type))
(inline)
(declare ,plus (Complex ,type -> Complex ,type -> Complex ,type))
(define (,plus a b)
(lisp (Complex ,type) (a b)
(cl:declare (cl:type (cl:or ,repr (cl:complex ,repr)) a b))
(cl:declare (cl:type (cl:complex ,repr) a b))
(cl:+ a b)))

(specialize complex-minus ,minus (Complex ,type -> Complex ,type -> Complex ,type))
(inline)
(declare ,minus (Complex ,type -> Complex ,type -> Complex ,type))
(define (,minus a b)
(lisp (Complex ,type) (a b)
(cl:declare (cl:type (cl:or ,repr (cl:complex ,repr)) a b))
(cl:declare (cl:type (cl:complex ,repr) a b))
(cl:- a b)))

(specialize complex-times ,times (Complex ,type -> Complex ,type -> Complex ,type))
(inline)
(declare ,times (Complex ,type -> Complex ,type -> Complex ,type))
(define (,times a b)
(lisp (Complex ,type) (a b)
(cl:declare (cl:type (cl:or ,repr (cl:complex ,repr)) a b))
(cl:declare (cl:type (cl:complex ,repr) a b))
(cl:* a b)))

(specialize complex-divide ,divide (Complex ,type -> Complex ,type -> Complex ,type))
(inline)
(declare ,divide (Complex ,type -> Complex ,type -> Complex ,type))
(define (,divide a b)
(lisp (Complex ,type) (a b)
(cl:declare (cl:type (cl:or ,repr (cl:complex ,repr)) a b))
(cl:declare (cl:type (cl:complex ,repr) a b))
(cl:/ a b)))

(specialize complex-reciprocal ,recip (Complex ,type -> Complex ,type))
(inline)
(declare ,recip (Complex ,type -> Complex ,type))
(define (,recip a)
(lisp (Complex ,type) (a)
(cl:declare (cl:type (cl:or ,repr (cl:complex ,repr)) a))
(cl:declare (cl:type (cl:complex ,repr) a))
(cl:/ a)))))))

(%define-native-complex-instances U8 (cl:unsigned-byte 8))
(%define-native-complex-instances U16 (cl:unsigned-byte 16))
(%define-native-complex-instances U32 (cl:unsigned-byte 32))
(%define-native-complex-instances U64 (cl:unsigned-byte 64))
(%define-native-complex-instances UFix (cl:unsigned-byte #.coalton-library/math/num::+unsigned-fixnum-bits+))
(%define-native-complex-instances I8 (cl:signed-byte 8))
(%define-native-complex-instances I16 (cl:signed-byte 12))
(%define-native-complex-instances I32 (cl:signed-byte 32))
(%define-native-complex-instances I64 (cl:signed-byte 64))
(%define-native-complex-instances IFix (cl:signed-byte #.coalton-library/math/num::+fixnum-bits+))
(%define-native-complex-instances Integer cl:integer)
(%define-native-complex-instances Single-Float cl:single-float)
(%define-native-complex-instances Double-Float cl:double-float)
(%define-native-complex-instances Fraction cl:rational)

(cl:defmacro %define-standard-complex-instances (type)
`(coalton-toplevel
Expand Down

0 comments on commit 1befb28

Please sign in to comment.