# [SciPy-User] How to efficiently do dot(dot( A.T, diag(d) ), A ) ?

Hugh Perkins hughperkins@gmail....
Tue Sep 11 21:26:57 CDT 2012

```Openblas does work tons better than atlas and reference.

I'm fairly sure that multicore is not really supported though? or
supported not very well.  On a 12-core machine, using openblas:

\$ python testmult.py
Elapsed time: 0.00923895835876
Elapsed time: 0.0242748260498
\$ python testmult.py
Elapsed time: 0.00923895835876
Elapsed time: 0.0255119800568
\$ python testmult.py
Elapsed time: 0.00781798362732
Elapsed time: 0.0324649810791

On the same machine, using matlab:
>> n = 10000;
>> k = 100;
>> a = spdiags(rand(n,1),0,n,n);
>> c = rand(k,n);
>> tic, d = c*a; toc
Elapsed time is 0.005955 seconds.
>> tic, d = d*c'; toc
Elapsed time is 0.006201 seconds.

(code for testmult.py:
from __future__ import division
from scipy import *
import scipy
import scipy.sparse as sparse
from tictoc import tic,toc

n = 10000;
k = 100;
a = sparse.spdiags( rand(n), 0, n, n )
c = rand(n,k);

tic(); d = c.T * a; toc()
tic(); e = dot( d, c ); toc()

tictoc.py:
import time

start = 0

def tic():
global start
start = time.time()

def toc():
global start
print "Elapsed time: " + str( time.time() - start )
start = time.time()
)
```