[oct-cvs] Oct commit: oct qd-complex.lisp qd-methods.lisp qd-package.lisp

rtoy rtoy at common-lisp.net
Sun Aug 26 14:37:48 UTC 2007


Update of /project/oct/cvsroot/oct
In directory clnet:/tmp/cvs-serv32505

Modified Files:
	qd-complex.lisp qd-methods.lisp qd-package.lisp 
Log Message:
qd-methods.lisp:
o Oops.  Move COERCE to qd-complex.lisp because we use the #q reader
  macro.  (This needs to be reorganized better.)
o Add RANDOM methods so we can generate quad-double random numbers.

qd-package.lisp:
o Shadow RANDOM so we can add our own RANDOM to generate quad-doubles.

qd-complex.lisp:
o COERCE moved here.


--- /project/oct/cvsroot/oct/qd-complex.lisp	2007/08/25 17:08:48	1.27
+++ /project/oct/cvsroot/oct/qd-complex.lisp	2007/08/26 14:37:48	1.28
@@ -209,6 +209,22 @@
 (defmethod unary-divide ((a qd-complex))
   (two-arg-/ #q1 a))
 
+(defmethod coerce ((obj t) (type t))
+  (cl:coerce obj type))
+
+(defmethod coerce ((number cl:real) (type (eql 'qd-real)))
+  (float number #q0))
+
+(defmethod coerce ((number qd-real) (type (eql 'qd-real)))
+  number)
+
+(defmethod coerce ((number cl:number) (type (eql 'qd-complex)))
+  (complex (float (realpart number) #q0)
+	   (float (imagpart number) #q0)))
+
+(defmethod coerce ((number qd-complex) (type (eql 'qd-complex)))
+  number)
+
 (declaim (inline square))
 (defun square (x)
   (declare (type qd-real x))
--- /project/oct/cvsroot/oct/qd-methods.lisp	2007/08/25 21:17:03	1.47
+++ /project/oct/cvsroot/oct/qd-methods.lisp	2007/08/26 14:37:48	1.48
@@ -800,22 +800,12 @@
 	  (if (plusp number) 1 -1)
 	  (/ number (abs number)))))
 
-(defmethod coerce ((obj t) (type t))
-  (cl:coerce obj type))
-
-(defmethod coerce ((number cl:real) (type (eql 'qd-real)))
-  (float number #q0))
-
-(defmethod coerce ((number qd-real) (type (eql 'qd-real)))
-  number)
-
-(defmethod coerce ((number cl:number) (type (eql 'qd-complex)))
-  (complex (float (realpart number) #q0)
-	   (float (imagpart number) #q0)))
-
-(defmethod coerce ((number qd-complex) (type (eql 'qd-complex)))
-  number)
+(defmethod random ((x cl:real) &optional (state *random-state*))
+  (cl:random x state))
 
+(defmethod random ((x qd-real) &optional (state *random-state*))
+  (* x (make-instance 'qd-real
+		      :value (qdi:random-qd state))))
 
 (define-compiler-macro + (&whole form &rest args)
   (if (null args)
--- /project/oct/cvsroot/oct/qd-package.lisp	2007/08/25 17:08:48	1.32
+++ /project/oct/cvsroot/oct/qd-package.lisp	2007/08/26 14:37:48	1.33
@@ -88,6 +88,7 @@
 	   #:decode-float-qd
 	   #:scale-float-qd
 	   #:ffloor-qd
+	   #:random-qd
 	   )
   #+cmu
   (:import-from #:c
@@ -155,6 +156,7 @@
 	   #:phase
 	   #:signum
 	   #:coerce
+	   #:random
 	   )
   (:export #:+
 	   #:-
@@ -212,6 +214,7 @@
 	   #:phase
 	   #:signum
 	   #:coerce
+	   #:random
 	   )
   ;; Constants
   (:export #:+pi+)




More information about the oct-cvs mailing list