Changeset 27421 in project


Ignore:
Timestamp:
09/14/12 08:11:12 (9 years ago)
Author:
Ivan Raikov
Message:

kd-tree: removed vestigial support for scaled distance functions

Location:
release/4/kd-tree/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/4/kd-tree/trunk/kd-tree.scm

    r27415 r27421  
    9292    dist2 ;; Point * Point -> Double
    9393
    94     ;; returns the scaled squared distance between two points.
    95     sdist2 ;; Point * Point * [Int] -> Double
    96 
    9794    ;; returns 0, negative or positive number depending on the
    9895    ;; distance between two points
     
    131128                (sum (list-tabulate (dimension a) diff2)))))
    132129
    133            (sdist2
    134             (lambda (factors)
    135               (let ((factors2 (map (lambda (n) (* n n)) factors)))
    136                 (lambda (a b)
    137                   (let ((diff2 (lambda (i) (let ((v (- (coord i a) (coord i b)))) (* v v)))))
    138                     (let ((v (sum (map * (list-tabulate (dimension a) diff2) factors2))))
    139                       v))))))
    140 
    141130           (compare-distance
    142131            (lambda (p a b . reltol)
     
    153142           
    154143    (make-<Point>
    155      dimension coord compare-coord dist2 sdist2 compare-distance)
     144     dimension coord compare-coord dist2 compare-distance)
    156145    ))
    157146
     
    573562                       ))
    574563              ))
    575       (lambda (t radius probe #!key (factors #f) (with-distance? #f))
    576         (let* ((dist-fn (if factors (sdist2 factors) dist2))
     564      (lambda (t radius probe #!key (with-distance? #f))
     565        (let* ((dist-fn dist2)
    577566               (filter-fn (if with-distance?
    578567                              (lambda (probe pp d2) (filter-map (lambda (p) (let ((pd (dist-fn probe p)))
     
    623612                       ))
    624613              ))
    625       (lambda (t radius probe #!key (factors #f) (with-distance? #f))
    626         (let* ((dist-fn (if factors (sdist2 factors) dist2))
     614      (lambda (t radius probe #!key (with-distance? #f))
     615        (let* ((dist-fn dist2)
    627616               (filter-fn (if with-distance?
    628617                              (lambda (probe pp ii vv r2)
  • release/4/kd-tree/trunk/kd-tree.setup

    r27352 r27421  
    1616 
    1717  ;; Assoc list with properties for your extension:
    18   '((version 4.1)
     18  '((version 4.2)
    1919    ))
  • release/4/kd-tree/trunk/tests/run.scm

    r27332 r27421  
    2828                    sorted-points)
    2929                  )))
    30 
    31 #|
    32     (define scale-factors '(1.0 0.5 1.0))
    33 
    34     (define (compare-scaled-distance p a b . reltol)
    35       (let ((dist2 (sdist2 scale-factors)))
    36         (let ((delta (- (dist2 p a) (dist2 p b))))
    37           (if (null? reltol)
    38               delta
    39               (if (<= delta (car reltol)) 0 delta)))))
    40 
    41     (define (sort-scaled-points pts)
    42       (sort pts (lambda (a b) (negative? (compare-scaled-distance x a b)))))
    43    
    44     (define srnn (let ((r2 (* r r))  (dist2 (sdist2 scale-factors)))
    45                    (sort-scaled-points
    46                     (filter
    47                      (lambda (y) (<= (dist2 x y) r2))
    48                      (sort-scaled-points sorted-points))
    49                     )))
    50 |#
    5130   
    5231    (test-group
     
    8463           (sort-points (kd-tree-near-neighbors t r x)))
    8564
    86 #|
    87      (test "near-neighbors scaled"
    88            srnn
    89            (sort-scaled-points (kd-tree-near-neighbors t r x factors: scale-factors)))
    90 |#
    9165     (test "slice"
    9266           sliced-points
Note: See TracChangeset for help on using the changeset viewer.