Skip to content

Commit

Permalink
Removed trailing whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpapp committed Apr 16, 2012
1 parent 41cac42 commit dfe457e
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/bins.lisp
Expand Up @@ -35,7 +35,7 @@
(interval left (+ left width))))

(defun pretty-bins (width n &key (min-step (default-min-step width))
(bias *pretty-bias*) (five-bias *pretty-five-bias*))
(bias *pretty-bias*) (five-bias *pretty-five-bias*))
"Bins with a pretty step size, calculated using PRETTY-STEP (see its
documentation)."
(even-bins (pretty-step width n :min-step min-step :bias bias
Expand Down
2 changes: 1 addition & 1 deletion src/data-frame.lisp
Expand Up @@ -56,7 +56,7 @@ Implementation notes:
(if (plusp index)
(length= (first* columns) length)
t))
() "Column length mismatch.")
() "Column length mismatch.")
(map nil (lambda (key)
(let+ (((&values nil present?) (gethash key table)))
(assert (not present?) () "Duplicate key ~A." key)
Expand Down
2 changes: 1 addition & 1 deletion src/differentiation.lisp
Expand Up @@ -34,6 +34,6 @@ DIFFERENTIATE for an explanation of the parameters."
"Return a function that calculates the elasticity numerically. See
DIFFERENTIATE for an explanation of the parameters."
(lambda (x)
(let+ (((&values df fx)
(let+ (((&values df fx)
(differentiate f x :n n :method method :h h)))
(* df (/ x fx)))))
6 changes: 2 additions & 4 deletions src/optimization.lisp
Expand Up @@ -43,7 +43,7 @@ to the left'', ie will keep picking smaller values."
(values m1 f1)
(values m2 f2))))
(if (<= f1 f2) ; change <= to maximize
(progn
(progn
;; new bracket is (a,m1,m2)
(shiftf b m2 m1 (golden-section-combination m1 a))
(shiftf f2 f1 (funcall f m1)))
Expand Down Expand Up @@ -100,7 +100,7 @@ to the left'', ie will keep picking smaller values."
;; ((minusp discriminant) alpha)
;; ;; positive b: take left root
;; ((plusp b) (/ (- gp0) (+ b (sqrt discriminant))))
;; ;; negative b: take right root
;; ;; negative b: take right root
;; (t (/ (- (sqrt discriminant) b) a 3d0))))))
;; ;; quadratic approximation
;; (- (/ (* gp0 (square alpha))
Expand All @@ -111,5 +111,3 @@ to the left'', ie will keep picking smaller values."
;; alpha-next)
;; (* alpha rel-max))))))
;; (error 'reached-max-iter)))


3 changes: 1 addition & 2 deletions src/pretty.lisp
Expand Up @@ -42,11 +42,10 @@ favors 5 over 2 as the first digit. When BIAS favors larger values."
(values (* correction (expt 10 exponent))
(max 0 (- (if (= correction 10) -1 0) exponent)))))

(defun pretty-step (width n &key
(defun pretty-step (width n &key
(min-step (default-min-step width))
(bias *pretty-bias*) (five-bias *pretty-five-bias*))
"Return a `pretty' (meaning 1, 2, or 5*10^n) step size, and the number of
fractional digits as the second value. Uses PRETTY, but enforces a minimum.
When BIAS is 0,, STEP always divides WIDTH to at most N intervals."
(pretty (max (/ width (1+ n)) min-step) :bias bias :five-bias five-bias))

8 changes: 4 additions & 4 deletions src/quadrature.lisp
Expand Up @@ -39,7 +39,7 @@ The algorithm uses Richardson extrapolation, the required coefficient is q^k."

;;;; iterative quadrature: generic interface

(defstruct iterative-quadrature
(defstruct iterative-quadrature
(f nil :type (function (double-float) double-float))
(a nil :type double-float)
(b nil :type double-float)
Expand Down Expand Up @@ -67,13 +67,13 @@ The algorithm uses Richardson extrapolation, the required coefficient is q^k."
;; (declare (optimize speed))
(let+ (((&structure-r/o iterative-quadrature- a b f) quadrature)
((&structure iterative-quadrature- n h sum) quadrature))
(setf sum
(setf sum
(if (zerop n)
(* (+ (funcall f a) (funcall f b)) h 0.5d0)
(+ (/ sum 2)
(let* ((h h))
(* h
(loop
(loop
repeat (expt 2 (1- n))
for x from (+ a h) by (* 2 h)
summing (funcall f x)))))))
Expand All @@ -99,7 +99,7 @@ The algorithm uses Richardson extrapolation, the required coefficient is q^k."
;; (declare (optimize speed))
(let+ (((&structure-r/o iterative-quadrature- a b f) quadrature)
((&structure iterative-quadrature- n h sum) quadrature))
(setf sum
(setf sum
(if (zerop n)
(* h (+ (funcall f (/ (+ a b) 2))))
(+ (/ sum 3)
Expand Down
2 changes: 1 addition & 1 deletion src/rootfinding.lisp
Expand Up @@ -183,7 +183,7 @@ interval, otherwise they are undefined."
;; (assert (< 0 coefficient 1))
;; (lambda (x)
;; (+ (* (- x attractor) coefficient) attractor)))

;; (defun root-autobracket (f x negative-rule positive-rule
;; &key (maximum-iterations 100)
;; (rootfinder #'root-ridders)
Expand Down
16 changes: 8 additions & 8 deletions src/sub.lisp
Expand Up @@ -9,18 +9,18 @@
Available standard selections:
fixnum - select that coordinate, drop a dimension.
vector of fixnums - select those coordinates.
(cons start end) - coordinates i such that start <= i < end.
(seq start end &optional by strict-direction?) - arithmetic sequence, the
sign of BY is adjusted unless STRICT-DIRECTION.
(cat &rest ...) - concatenate selections
(rev ...) - reverse the order of elements
(sub ... sub-selection) - select indexes using selection
In all of the above, negative numbers count back from DIMENSION. Because of
Expand Down Expand Up @@ -177,7 +177,7 @@ dimension.")
by strict-direction?))))

;;; walking selections
;;;
;;;
;;; Recursive traversal of selections is implemented by closures chained
;;; together. Once the index reaches its last value, the next one is
;;; incremented. The cumulative sum is only partially calculated.
Expand Down Expand Up @@ -280,7 +280,7 @@ fixnum selections."
(map 'vector (lambda (s d) (sub-resolve-selection s d nil))
selections dimensions))

(defmacro with-indexing ((selections dimensions index next
(defmacro with-indexing ((selections dimensions index next
&key effective-dimensions)
&body body)
"Establish incrementation and index-calculation functions within BODY. The
Expand Down
4 changes: 2 additions & 2 deletions tests/quadrature.lisp
Expand Up @@ -9,7 +9,7 @@
(defmacro test-romberg (list &rest rest)
(with-unique-names (function a b value)
`(let+ (((,function ,a ,b ,value) ,list))
(ensure-same (romberg-quadrature ,function ,a ,b
(ensure-same (romberg-quadrature ,function ,a ,b
,@rest)
,value))))

Expand All @@ -24,5 +24,5 @@
(test-romberg q1 :open? t)
(test-romberg q2)
(test-romberg q2 :open? t)
(test-romberg q3 :epsilon 1d-9)
(test-romberg q3 :epsilon 1d-9)
(test-romberg q3 :epsilon 1d-9 :open? t)))
1 change: 0 additions & 1 deletion tests/sub.lisp
Expand Up @@ -66,4 +66,3 @@
(addtest (sub-tests)
test-asub
(ensure-same (asub (ia 10) (mask #'evenp it)) #(0 2 4 6 8)))

0 comments on commit dfe457e

Please sign in to comment.