[oct-cvs] Oct commit: oct qd-complex.lisp
rtoy
rtoy at common-lisp.net
Thu Aug 30 23:42:24 UTC 2007
Update of /project/oct/cvsroot/oct
In directory clnet:/tmp/cvs-serv12895
Modified Files:
qd-complex.lisp
Log Message:
Add methods to handle QD-REAL and CL:COMPLEX and vice-versa for the
four basic arithmetic operations.
--- /project/oct/cvsroot/oct/qd-complex.lisp 2007/08/28 16:01:08 1.32
+++ /project/oct/cvsroot/oct/qd-complex.lisp 2007/08/30 23:42:24 1.33
@@ -213,6 +213,39 @@
(complex (/ (+ (* rx r) ix) dn)
(/ (- (* ix r) rx) dn))))))
+(defmethod two-arg-+ ((a qd-real) (b cl:complex))
+ (complex (+ a (realpart b))
+ (imagpart b)))
+
+(defmethod two-arg-+ ((a cl:complex) (b qd-real))
+ (complex (+ (realpart a) b)
+ (imagpart a)))
+
+(defmethod two-arg-- ((a qd-real) (b cl:complex))
+ (complex (- a (realpart b))
+ (- (imagpart b))))
+
+(defmethod two-arg-- ((a cl:complex) (b qd-real))
+ (complex (- (realpart a) b)
+ (imagpart a)))
+
+(defmethod two-arg-* ((a qd-real) (b cl:complex))
+ (complex (* a (realpart b))
+ (* a (imagpart b))))
+
+(defmethod two-arg-* ((a cl:complex) (b qd-real))
+ (complex (* (realpart a) b)
+ (* (imagpart a) b)))
+
+
+(defmethod two-arg-/ ((a qd-real) (b cl:complex))
+ (two-arg-/ a (coerce b 'qd-complex)))
+
+(defmethod two-arg-/ ((a cl:complex) (b qd-real))
+ (complex (/ (realpart a) b)
+ (/ (imagpart a) b)))
+
+
(defmethod unary-divide ((a qd-complex))
(two-arg-/ #q1 a))
More information about the oct-cvs
mailing list