Subject: code for the transpose of a list of lists.
From: Richard Hennessy
Date: Tue, 29 Jun 2010 15:19:37 -0400
--------------------------------------------------
From: "Barton Willis" <willisb at unk.edu>
Sent: Tuesday, June 29, 2010 8:01 AM
To: "Richard Fateman" <fateman at cs.berkeley.edu>
Cc: "Maxima List" <maxima at math.utexas.edu>
Subject: Re: [Maxima] code for the transpose of a list of lists.
> Using Clozure Common Lisp, your array based transpose seems to be fast:
>
> (%i6) m : genmatrix(lambda([i,j],i), 600,600)$
>
> (%i8) transpose(m)$
> Evaluation took 0.1100 seconds (0.1090 elapsed)
>
> (%i9) mtrans(m)$
> Evaluation took 0.0780 seconds (0.0780 elapsed)
>
> But as you observed, the array based transpose is slow under GCL:
>
> (%i12) transpose(m)$
> Evaluation took 0.3900 seconds (0.3900 elapsed)
>
> (%i13) mtrans(m)$
> Evaluation took 1.4700 seconds (1.4700 elapsed)
>
> By the way: Matrix multiplication requires a transpose for a list of
> lists. I tried a few
> experiments at speeding up matrix multiplication, but didn't get anywhere.
> Maybe somebody
> else would like to try. An array method might be fast for non-GCL Maxima.
> Also, adding the
> members of an inner product en masse might some be faster for some
> non-numeric matrices.
>
> --Barton
>
> -----maxima-bounces at math.utexas.edu wrote: -----
>
>>To: Barton Willis <willisb at unk.edu>, Maxima List <maxima at math.utexas.edu>
>>From: Richard Fateman <fateman at cs.berkeley.edu>
>>Sent by: maxima-bounces at math.utexas.edu
>>Date: 06/28/2010 11:37PM
>>Subject: Re: [Maxima] code for the transpose of a list of lists.
>>
>> Here's another program to time...
>>
>>(defun $mtrans(r) ;; r must be a maxima matrix
>>
>> (let* ((j (1- (length r)))
>> (k (1- (length (cadr r))))
>> (M (make-array (list j k) :initial-contents
>> (mapcar #'cdr (cdr r)))))
>> (cons '($matrix simp)
>> (loop for ind2 fixnum from 0 below k collect
>> (cons '(mlist simp)
>> (loop for ind1 fixnum from 0 below j collect
>> (aref M ind1 ind2)))))))
>>
>>It appears to be slow on GCL, but may be much faster on some other lisps.
>>
>>I also don't know about optimization settings for GCL etc.
>>
>>_______________________________________________
>>Maxima mailing list
>>Maxima at math.utexas.edu
>>http://www.math.utexas.edu/mailman/listinfo/maxima
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
I read that Clozure CL has multithreading. Matrix multiplication might be a
good candidate for a multithreaded algorithm, maybe the first in Maxima.
Rich