From 078a252f3be347745f753703ce124c70afa42dc6 Mon Sep 17 00:00:00 2001 From: tony Date: Fri, 9 May 2008 14:22:26 +0200 Subject: [PATCH] data structures still damaged. put the flatten part in the right place -- the call, not the receiver. We don't want to dummy-proof the reciever yet! --- compound.lsp | 14 ++++++++------ regression.lsp | 19 ++++++++++++++----- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/compound.lsp b/compound.lsp index cadea82..188f557 100644 --- a/compound.lsp +++ b/compound.lsp @@ -450,8 +450,7 @@ nil : set_values : and it's poorly documented." - (let ((local-indexlist (flatten-list indexlist)) - (indices nil) + (let ((indices nil) (index) (dim) (vdim) @@ -465,12 +464,15 @@ and it's poorly documented." (declare (fixnum rank n)) (if (or (sequencep a) - (not (arrayp a))) (error "not an array - ~a" a)) - (if (not (listp local-indexlist)) (error "bad index list - ~a" indices)) ;; ??? - (if (/= (length local-indexlist) (array-rank a)) + (not (arrayp a))) + (error "not an array - ~a" a)) + (if (not (listp indexlist)) + (error "bad index list - ~a" indexlist)) ;; ?indices? + (if (/= (length indexlist) + (array-rank a)) (error "wrong number of indices")) - (setf indices (coerce local-indexlist 'vector)) + (setf indices (coerce indexlist 'vector)) (setf olddim (coerce (array-dimensions a) 'vector)) ;; compute the result dimension vector and fix up the indices diff --git a/regression.lsp b/regression.lsp index 73379c8..a5b569c 100644 --- a/regression.lsp +++ b/regression.lsp @@ -261,7 +261,9 @@ Returns the residual sum of squares for the model." (defmeth regression-model-proto :basis () "Message args: () -Returns the indices of the variables used in fitting the model, in a sequence." + +Returns the indices of the variables used in fitting the model, in a +sequence." (if (send self :needs-computing) (send self :compute)) (if (typep (slot-value 'basis) 'sequence) @@ -279,7 +281,11 @@ Returns the swept sweep matrix. For internal use" (defmeth regression-model-proto :included (&optional new-included) "Message args: (&optional new-included) -With no argument, NIL means a case is not used in calculating estimates, and non-nil means it is used. NEW-INCLUDED is a sequence of length of y of nil and t to select cases. Estimates are recomputed." + +With no argument, NIL means a case is not used in calculating +estimates, and non-nil means it is used. NEW-INCLUDED is a sequence +of length of y of nil and t to select cases. Estimates are +recomputed." (when (and new-included (= (length new-included) (send self :num-cases))) (setf (slot-value 'included) (copy-seq new-included)) @@ -409,12 +415,15 @@ the regression." (defmeth regression-model-proto :coef-estimates () "Message args: () + Returns the OLS (ordinary least squares) estimates of the regression -coefficients. Entries beyond the intercept correspond to entries in basis." +coefficients. Entries beyond the intercept correspond to entries in +basis." (let ((n (array-dimension (send self :x) 1)) - (indices (if (send self :intercept) + (indices (flatten-list + (if (send self :intercept) (list 0 (+ 1 (send self :basis))) ;; was cons -- why? - (+ 1 (send self :basis)))) + (list (+ 1 (send self :basis)))))) (m (send self :sweep-matrix))) (coerce (compound-data-seq (select m (+ 1 n) indices)) 'list))) -- 2.11.4.GIT