【入門】CommonLispその2【質問よろず】
■ このスレッドは過去ログ倉庫に格納されています
0017デフォルトの名無しさん
2006/02/17(金) 01:00:12ていく様子なのですが、そういうもんなんでしょうか?
たとえば、arrayの中の与えられた要素の和を返す関数:
(defun foo1 (array positions)
(let ((sum 0.0))
(map nil #'(lambda (x) (setq sum (+ sum (aref array x)))) positions)
sum))
(compile 'foo1)
に対して float のarrayを以下のように作成します。
(setq sa1 (make-array 10 :element-type 'float
:initial-contents (loop for i from 1.0 to 10.0 by 1.0 collect i)))
すると、
(time (foo1 sa1 #(1 2 3 5 7)))
……
; space allocation:
; 3 cons cells, 80 other bytes, 0 static bytes
といった具合に「80 other bytes」が使われます。
これは定数ではなくアクセスする数が増えるに応じて16bytesずつ使われます。
一方で、integerの場合
(time (foo2 sa2 #(1 2 3 5 7)))
……
; 3 cons cells, 0 other bytes, 0 static bytes
となり 0 otehr bytes です。
大きなfloatのarrayを使いたいので何とかならないかなと思っているのですが…
処理系はAllegroを使っています。
どなたか情報お持ちの方教えてください。
■ このスレッドは過去ログ倉庫に格納されています