On Mon, Feb 13, 2012 at 11:07 AM, Jason Grout
<jason-s...@creativetrax.com> wrote:
> On 2/13/12 12:41 PM, William Stein wrote:
>>
>> On Mon, Feb 13, 2012 at 10:29 AM, Robert Bradshaw
>> <rober...@math.washington.edu>  wrote:
>>>
>>> On Mon, Feb 13, 2012 at 10:06 AM, William Stein<wst...@gmail.com>  wrote:
>>>>
>>>> On Mon, Feb 13, 2012 at 9:59 AM, Pierre<pierre.guil...@gmail.com>
>>>>  wrote:
>>>>>
>>>>> I see. Well I *do* have hundreds of 2x2 matrices to multiply out so
>>>>> i'm better off storing them as numpy matrices throughout... thanks for
>>>>> your explanations though.
>>>>>
>>>>> Pierre
>>>>
>>>>
>>>> You might consider using Cython and writing a custom 2x2 matrix class.
>>>>  It wouldn't be difficult... so I'll write one right now and respond
>>>> with the benchmarks.
>>
>>
>> Here it is:  http://480.sagenb.org/home/pub/97/
>>
>> I ended up using GSL's complex matrix data type and the BLAS level 3
>> routine to do the multiplication.    I did not add any other
>> convenience functions to the class, so some more will probably be
>> needed for your application.
>
>
> I'm curious why you didn't just store the 4 complex numbers in C.

I was concerned about "numerical stability" and figured BLAS would
deal with that.  But maybe that doesn't matter.

Most importantly, I forgot about Cython's complex type, which I now
remember Robert Bradshaw wrote for his thesis work.   I wasn't looking
forward to writing your line:

res.m00=self.m00*right.m00+self.m01*right.m10

but against the gsl library.  But using the cython type in complex,
you get the above at C speed with easy notation, which is pretty
awesome.

>  I tried
> it and got a much bigger speedup: 17x faster than numpy and 150x faster than
> Sage.  See http://sagenb.org/home/pub/4303/

Nice.

>
> Thanks,
>
> Jason
>
>
> --
> To post to this group, send email to sage-support@googlegroups.com
> To unsubscribe from this group, send email to
> sage-support+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/sage-support
> URL: http://www.sagemath.org



-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to