On Wednesday, December 3, 2014 1:33:46 PM UTC-8, Jernej wrote: > > > for i in xrange(1, cur): > for j in xrange(i+1, cur): > iv = (cache[i]*vec2int[j].transpose())[0,0] >
It looks like you should rewrite this loop so that j is the out variable, so that you can pull vec2int[j].transpose() to the out loop. No need to cache it. In any case, your profiling data indicates: 1 85.572 85.572 113.024 113.024 <string>:9(constructGraph_fast) 3733128 10.413 0.000 10.413 0.000 matrix_space.py:145(__classcall__) 1604418 9.434 0.000 19.921 0.000 {method 'transpose' of 'sage.matrix.matrix_dense.Matrix_dense' objects} 1604418 3.186 0.000 4.174 0.000 {method '__copy__' of 'sage.matrix.matrix_generic_dense.Matrix_generic_dense' objects} so most time is spent in "constructGraph_fast", which I guess is your program itself. The transpose is a bit noticeable but hardly constitutes the majority of the time. The construction for the matrix spaces is incurred twice: both for the transpose and for computing the product. By pulling the transpose to the outside loop that should roughly be cut in half (and you'd only have the sqrt of the number of transposes). It looks like most time is getting lost in basic python interpretation and shuffling around elements. If you make a big matrix out of cache[i] vectors, you can eliminate the loop over i. The only thing left would be inspecting the elements, for which you can then write a simple cython routine (which should be lightning fast). -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.