Changes between Initial Version and Version 1 of Ticket #16116


Ignore:
Timestamp:
04/10/14 09:20:00 (4 years ago)
Author:
jipilab
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #16116

    • Property Cc was added
  • Ticket #16116 – Description

    initial v1  
    1818    100 loops, best of 3: 8.13 ms per loop
    1919
    20     sage: CFC.<F>=CyclotomicField(2*5*7)
     20    sage: CF.<F>=CyclotomicField(2*5*7)
    2121    sage: af=(F^7+~F^7)/2 #same value as a
    2222    sage: bf=(F^5+~F^5)/2 #same value as b
    23     sage: m2=matrix(CFC,[[-1, 1, 2*af],[-4*af*bf - 1, 4*af*bf + 4*bf^2, 4*af*bf + 2*af],[-2*af, 2*af + 2*bf, 2*af]])
     23    sage: m2=matrix(CF,[[-1, 1, 2*af],[-4*af*bf - 1, 4*af*bf + 4*bf^2, 4*af*bf + 2*af],[-2*af, 2*af + 2*bf, 2*af]])
    2424    sage: %timeit m2^2
    2525    100 loops, best of 3: 4.99 ms per loop
     
    2727
    2828The three matrices elmt, m and m2 are the same encoded into 3 different base rings. It would be natural to think that the cyclotomic field be the optimal field to do computations, but it does not seem to be the case in practice.
     29
     30Here is a univariate example where I disactivated the verification on cyclotomic fields on line 962 of the file /src/sage/matrix/matrix_space.py to get a matrix_generic_dense instead of matrix_cyclo_dense.
     31
     32{{{
     33    sage: PR=PolynomialRing(QQ,[x])
     34    sage: I=Ideal(x^2 - 1/2*x - 1/4)
     35    sage: Q=PR.quotient(I)
     36    sage: elmt_uni=matrix(Q,[[-2*x, 1, 6*x + 2],[-2*x, 2*x, 4*x + 1],[0,0,1]])
     37    sage: %timeit elmt_uni*elmt_uni
     38    1000 loops, best of 3: 1.46 ms per loop
     39
     40    sage: CF.<F>=CyclotomicField(2*5)
     41    sage: f5=(F+~F)/2
     42    sage: m=matrix(CF,[[-2*f5, 1, 6*f5 + 2],[-2*f5, 2*f5, 4*f5 + 1],[0,0,1]])
     43    sage: m.parent()
     44    Full MatrixSpace of 3 by 3 dense matrices over Cyclotomic Field of order 10 and degree 4
     45    sage: type(m)
     46    <type 'sage.matrix.matrix_generic_dense.Matrix_generic_dense'>
     47    sage: %timeit m*m
     48    1000 loops, best of 3: 251 µs per loop
     49}}}
     50
     51The gain is significant. Is there a known use cases where the specialized implementation is faster than the generic one? If yes, should we make some threshold test to choose between the two implementations?