From 3d1c148aeb9c7c141a849a1eb24c05f5c69ffeab Mon Sep 17 00:00:00 2001 From: pfdietz <pfdietz@localhost> Date: Sun, 8 Feb 2004 14:16:34 +0000 Subject: [PATCH] Change the distribution of sizes when producing random partitions. --- ansi-tests/random-int-form.lsp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ansi-tests/random-int-form.lsp b/ansi-tests/random-int-form.lsp index b0e884ef..57467f2d 100644 --- a/ansi-tests/random-int-form.lsp +++ b/ansi-tests/random-int-form.lsp @@ -74,6 +74,8 @@ (defvar *maximum-random-int-bits* 45) +(defvar *random-vals-list-bound* 20) + (defvar *max-compile-time* 0) (defvar *max-compile-term* nil) @@ -137,7 +139,7 @@ ) (make-random-integer-form size))) (vals-list - (loop repeat 20 + (loop repeat *random-vals-list-bound* collect (mapcar #'(lambda (range) (let ((lo (car range)) @@ -153,6 +155,7 @@ :decls1 ,opt-decls-1 :decls2 ,opt-decls-2 :form ,form)) + (finish-output) ;; (cl-user::gc) ) (test-int-form form vars var-types vals-list opt-decls-1 opt-decls-2))) @@ -732,12 +735,32 @@ (defun random-partition (n p) "Partition n into p numbers, each >= 1. Return list of numbers." (assert (<= 1 p)) + #| (cond ((= p 1) (list n)) ((< n p) (make-list p :initial-element 1)) (t (let ((n1 (1+ (random (floor n p))))) (cons n1 (random-partition (- n n1) (1- p))))))) + |# + (cond + ((= p 1) (list n)) + ((= n 0) (make-list p :initial-element 0)) + (t (let* ((r (random p)) + (n1 (random (1+ n)))) + (cond + ((= r 0) + (cons n1 (random-partition (- n n1) (1- p)))) + ((= r (1- p)) + (append (random-partition (- n n1) (1- p)) (list n1))) + (t + (let* ((n2 (random (1+ (- n n1)))) + (n3 (- n n1 n2))) + (append (random-partition n2 r) + (list n1) + (random-partition n3 (- p 1 r)))))))))) + + (defun make-optimized-lambda-form (form vars var-types opt-decls) `(lambda ,vars -- GitLab