On Sun, Nov 16, 2014 at 4:08 PM, Vincent Delecroix
<20100.delecr...@gmail.com> wrote:
> 2014-11-16 5:42 UTC−07:00, Fredrik  Johansson <fredrik.johans...@gmail.com>:
>>
>>
>> On Sunday, November 16, 2014 5:45:01 AM UTC+1, vdelecroix wrote:
>>>
>>> Hello,
>>>
>>> We currently have two much implementation of 2x2 matrices. I found at
>>> least three that leads to distinct element classes
>>>
>>> sage: M1 = SL2Z
>>> sage: M2 = MatrixSpace(ZZ,2)
>>> sage: from sage.matrix.matrix_integer_2x2 import MatrixSpace_ZZ_2x2
>>> sage: M3 = MatrixSpace_ZZ_2x2()
>>>
>>> sage: m1 = M1([2,1,1,1])
>>> sage: m2 = M2([2,1,1,1])
>>> sage: m3 = M3([2,1,1,1])
>>>
>>> SL2Z is mostly used in code related to modular forms. And I found only
>>> one place where MatrixSpace_ZZ_2x2 is used. I would like to:
>>>  - try to remove the special class we have for SL2Z (or at least
>>> inherit from the generic 2x2 integer which is faster and interacts
>>> nicely with the rest of matrix code)
>>>  - make the MatrixSpace_ZZ_2x2 be the default when we call
>>> "MatrixSpace(ZZ,2)".
>>>
>>> I wanted to ask about opinions before starting.
>>>
>>> Vincent
>>>
>>> PS: benchmark
>>>
>>> sage: %timeit m1**1001
>>> 1000 loops, best of 3: 237 µs per loop
>>> sage: %timeit m1*m1
>>> 100000 loops, best of 3: 14.8 µs per loop
>>>
>>> sage: %timeit m2**1001
>>> 10000 loops, best of 3: 74.4 µs per loop
>>> sage: %timeit m2*m2
>>> 100000 loops, best of 3: 4.4 µs per loop
>>>
>>> sage: %timeit m3**1001
>>> 10000 loops, best of 3: 19.3 µs per loop
>>> sage: %timeit m3*m3
>>> 1000000 loops, best of 3: 847 ns per loop
>>>
>>
>> Is this with or without http://trac.sagemath.org/ticket/16803 ?
>>
>> In C, m**1001 takes 6 µs and m*m takes < 200 ns for me with flint.
>
> Hello Frederik,
>
> I did the benchmark on sage-6.4 in which #16803 is already merged.
> What do you mean by "in C"?

I mean just calling the flint functions directly in a C program.

I'm surprised that there is so much overhead (4 µs) on the Sage side
for multiplying two matrices, particularly considering that there
seems to be less than 1 µs overhead for multiplying two
MatrixSpace_ZZ_2x2.

I guess exponentiation doesn't call fmpz_mat_pow at all and just does
binary exponentiation on Sage objects.

Fredrik

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to