gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gcl-devel] [Maxima] make-array with initial-contents in gcl is slow


From: Camm Maguire
Subject: Re: [Gcl-devel] [Maxima] make-array with initial-contents in gcl is slow
Date: Wed, 18 Jan 2012 13:09:39 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

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 <address@hidden> 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
> address@hidden
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
>
>

-- 
Camm Maguire                                        address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah



reply via email to

[Prev in Thread] Current Thread [Next in Thread]