Subject: make-array with initial-contents in gcl is slow
From: Camm Maguire
Date: Wed, 18 Jan 2012 13:09:39 -0500
Greetings! P.S. you need this ahead of the defun replace in 2.6.8pre:
(deftype seqind nil `(integer 0 ,array-dimension-limit))
Take care,
John Lapeyre <lapeyre.math122a at gmail.com> writes:
> In gcl make-array with :initial-contents from a list
> is poorly implemented in that the copying is O(n^2).
> A test on one machine shows that initializing a
> list of length of 5 10^4 takes 1 minute in gcl and a few ms in sbcl.
>
> This potentially affects some code in the share directory.
>
> The relevant part of the gcl code in make-array is:
>
> ((= (length dimensions) 1)
> (let ((x (si:make-vector element-type (car dimensions)
> adjustable fill-pointer
> displaced-to displaced-index-offset
> static initial-element)))
> (when initial-contents-supplied-p
> (do ((n (car dimensions))
> (i 0 (1+ i)))
> ((>= i n))
> (declare (fixnum n i))
> (si:aset x i (elt initial-contents i))))
> x))
>
> The following passed a quick test:
>
> ((= (length dimensions) 1)
> (let ((x (si:make-vector element-type (car dimensions)
> adjustable fill-pointer
> displaced-to displaced-index-offset
> static initial-element)))
> (when initial-contents-supplied-p
> (if (listp initial-contents)
> (do ( (e initial-contents (cdr e))
> (i 0 (1+ i)))
> ((null e))
> (declare (fixnum i))
> (si:aset x i (car e)))
> (do ((n (car dimensions))
> (i 0 (1+ i)))
> ((>= i n))
> (declare (fixnum n i))
> (si:aset x i (elt initial-contents i)))))
> x))
>
> -- John Lapeyre
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
>
>
--
Camm Maguire camm at maguirefamily.org
==========================================================================
"The earth is but one country, and mankind its citizens." -- Baha'u'llah