[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: speed up for array ops
- To: firstname.lastname@example.org (Espen J. Vestre)
- Subject: Re: speed up for array ops
- From: email@example.com (Bill St. Clair)
- Date: Mon, 7 Dec 1992 16:25:35 -0600
- Cc: info-mcl
>I discovered that converting the whole array to a list was worth the
>(defun a-to-list (a)
> "makes a list out of any array"
> (make-array (array-total-size a)
> :displaced-to a
> :element-type (array-element-type a))
>(defun listlim (numlist)
> "Returns the maximum and minimum values of a list of complex numbers."
> (let* ((amax (abs (first numlist)))
> (amin amax))
> (mapc #'(lambda (z)
> (setq z (abs z))
> (cond ((> z amax) (setq amax z))
> ((< z amin) (setq amin z))))
> `((min ,amin)(max ,amax))))
>Does this mean that MCLs AREF is slower than it ought to be?
No. It means that (coerce x 'list) is faster than (dotimes (...) (aref ...)).
AREF needs to do type and bounds checking on each reference. COERCE can
do it once outside the loop. My example showed how to get a simple vector
that was amenable to an in-line non-bounds-checked AREF.