From abfe0e8abe34e37dad55e381796d9549e9dac699 Mon Sep 17 00:00:00 2001 From: AJ Rossini Date: Wed, 7 Nov 2007 12:51:50 +0100 Subject: [PATCH] Small error fixes, prep for new object instantiator. --- dists.lsp | 3 +-- linalg.lsp | 20 +++++++++++--------- lsobjects.lsp | 25 +++++++++++++++++++++++++ regression.lsp | 8 +++----- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/dists.lsp b/dists.lsp index 7651b5d..32a4664 100644 --- a/dists.lsp +++ b/dists.lsp @@ -44,8 +44,7 @@ (defun set-seed (x) "stupid dummy function, need to implement rng seeding tool." - 0) - + (values x)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; diff --git a/linalg.lsp b/linalg.lsp index f86ca5f..ba69274 100644 --- a/linalg.lsp +++ b/linalg.lsp @@ -643,12 +643,13 @@ U or B for Gaussian, triangular, uniform or bisquare. The default is B." (if (/= 0 error) (error "bad kernel density data"))))) - +#| (defun kernel-smooth-Cport (px py n width ;;wts wds ;; see above for mismatch? xs ys ns ktype) "Port of kernel_smooth (Lib/kernel.c) to Lisp. FIXME:kernel-smooth-Cport : This is broken. Until this is fixed, we are using Luke's C code and CFFI as glue." + (declare (ignore width xs)) (cond ((< n 1) 1.0) ((and (< n 2) (<= width 0)) 1.0) (t (let* ((xmin (min px)) @@ -660,14 +661,13 @@ Until this is fixed, we are using Luke's C code and CFFI as glue." (ysum 0.0)) (dotimes (j (- n 1)) ) ;;;possible nasty errors... -#| - (let* - ((lwidth (if wds (* width (aref wds j)) width)) - (lwt (* (kernel-Cport (aref xs i) (aref px j) lwidth ktype) ;; px? - (if wts (aref wts j) 1.0)))) - (setf wsum (+ wsum lwt)) - (setf ysum (if py (+ ysum (* lwt (aref py j)))))) ;; py? y? -|# +;; (let* +;; ((lwidth (if wds (* width (aref wds j)) width)) +;; (lwt (* (kernel-Cport (aref xs i) (aref px j) lwidth ktype) ;; px? +;; (if wts (aref wts j) 1.0)))) +;; (setf wsum (+ wsum lwt)) +;; (setf ysum (if py (+ ysum (* lwt (aref py j)))))) ;; py? y? +;; ;;; end of errors (if py (if (> wsum 0.0) @@ -675,6 +675,8 @@ Until this is fixed, we are using Luke's C code and CFFI as glue." 0.0) (/ wsum n))))) (values ys))))) +|# + (defun kernel-Cport (x y w ktype) "Port of kernel() (Lib/kernel.c) to Lisp. diff --git a/lsobjects.lsp b/lsobjects.lsp index 2a0d185..0427b9a 100644 --- a/lsobjects.lsp +++ b/lsobjects.lsp @@ -564,6 +564,7 @@ RETURNS: method-name." (add-documentation object 'proto doc)) (if set (setf (symbol-value name) object))) + (defmacro defproto (name &optional ivars cvars parents doc) "Syntax (defproto name &optional ivars cvars (parent *object*) doc) Makes a new object prototype with instance variables IVARS, 'class' @@ -583,6 +584,30 @@ a list of objects. IVARS and CVARS must be lists." ,namesym)))) +#| +(defmacro defproto (name &optional ivars cvars parents doc) + "Syntax (defproto name &optional ivars cvars (parent *object*) doc) +Makes a new object prototype with instance variables IVARS, 'class' +variables CVARS and parents PARENT. PARENT can be a single object or +a list of objects. IVARS and CVARS must be lists." + (if (boundp name) + (error "name is bound") ; fixme: use real error + (let ((obsym (gensym)) + (namesym (gensym)) + (parsym (gensym))) + `(progn + (let* ((,namesym ',name) + (,parsym ,parents) + (,obsym (make-basic-object (if (listp ,parsym) + ,parsym + (list ,parsym)) ;; should this be ,@parsym ? + nil))) + (make-prototype ,obsym ,namesym ,ivars ,cvars ,doc t) + ,namesym))))) +|# + + + ;; recall: ;; , => turn on evaluation again (not macro substitution) ;; ` => diff --git a/regression.lsp b/regression.lsp index 27cec43..fe3bcc8 100644 --- a/regression.lsp +++ b/regression.lsp @@ -429,6 +429,7 @@ Computes Cook's distances." (defun plot-points (x y &rest args) "FIXME!!" + (declare (ignore x y)) (error "Graphics not implemented yet.")) ;; Can not plot points yet!! @@ -458,10 +459,7 @@ Returns a plot object." (p (plot-points x-values r :title "Bayes Residual Plot" :point-labels (send self :case-labels)))) -;; AJR:FIXME -;; the lambda needs to be something that fits into list -;; (map 'list -;; #'(lambda (a b c d) (send p :plotline a b c d nil)) -;; x-values low x-values high) + (map 'list #'(lambda (a b c d) (send p :plotline a b c d nil)) + x-values low x-values high) (send p :adjust-to-data) p)) -- 2.11.4.GIT