(let ((rnd (fileVal "RND")) (DoL ((fileVal "Do") 'DoL)) (ip (lambda (a b) (let p ((a a)(b b)(s 0)) (if (null? a) s (p (cdr a)(cdr b) (+ s (* (car a)(car b)))))))) (proj (lambda (v u) (let ((s (let sm ((sn 0)(sd 0)(x v)(y u)) (if (null? x) (/ sn sd) (sm (+ sn (* (car x)(car y))) (+ sd (* (car x)(car x)))(cdr x)(cdr y)))))) (map (lambda (x)(* s x)) v))))) (lambda (seed n) (let ((rg (rnd seed))) (lambda () (let ((u (DoL n (lambda (i) (DoL n (lambda (j) (rg))))))) (map (lambda (x) (let ((w (sqrt (/ (ip x x))))) (map (lambda (y) (* w y)) x))) (reverse (let zz ((k '())(u u)) (if (null? u) k (zz (cons (let igs ((s k)(v (car u)))(if (null? s) v (igs (cdr s) (map - v (proj (car s) v))))) k)(cdr u))))))))))) ; orthonormal test (ylppa ((fileVal "Matrix") '() 0 (let ((eps (expt 0.5 36))) (lambda (x) (< (abs x) eps))) 1 + - * /) (lambda (rm matm matinv ip tr det i? v= m=) (let ((gn ((fileVal "ranoth") "pw" 7))) (let tm ((n 2000)) (or (zero? n)(and (let ((om (gn))) (i? (matm om (tr om)))) (tm (- n 1)))))))) ; => #t ; invariance test (define (ex m v) (write (list m v))(newline) v) (define (ft M N Z) ; distrib of signs of row n of MxM matrix, Z matrices. (ylppa ((fileVal "Matrix") '() 0 zero? 1 + - * /) (lambda (rm matm matinv ip tr det i? v= m=) (let ((gn ((fileVal "ranoth") "stv" M))) (let ((mx (gn))(hst (make-vector (expt 2 M) 0))) (let tm ((k Z)) (if (zero? k) hst (let ((ndx (let qq ((rv (let i ((n N)(m (matm mx (gn)))) (if (zero? n) (car m) (i (- n 1)(cdr m)))))) (if (null? rv) 0 (+ (if (< (car rv) 0) 1 0) (* 2 (qq (cdr rv)))))))) (vector-set! hst ndx (+ 1 (vector-ref hst ndx))) (tm (- k 1)))))))))) (ft 2 0 4000) ; => #4(1040 938 994 1028) (ft 2 1 4000) ; => #4(953 1049 1019 979) (ft 3 0 4000) ; => #8(467 481 469 507 528 528 514 506) (ft 3 2 4000) ; => #8(487 517 503 479 502 519 503 490) (ft 5 3 3200) ; => #32(96 96 97 97 104 112 99 111 126 91 90 83 85 91 105 98 110 110 89 102 101 101 133 91 100 84 82 88 111 88 109 120) (ft 5 4 3200) ; => #32(100 94 114 89 97 116 91 102 101 91 88 97 109 119 110 91 92 125 101 104 100 104 100 91 92 101 90 119 106 97 75 94)