[Numpy-discussion] Antwort: Re: vector to tensor matrix speed up

Ferenc.Pintye at eu.decoma.com Ferenc.Pintye at eu.decoma.com
Fri Jul 21 06:35:52 CDT 2006





Hi Tim,

      many thanks for the tipps, i used the same way
with vectorized (chunk)  method on the indexing operation.
..
....
......
............    # out = zeros((size_mcf[0],sizes_smatrix[2]+5),Float32)
      #     size_mcf[0] ~ 240000
      eig = zeros((size_mcf[0],3,3),dtype=Float32)
      eigwert = zeros((size_mcf[0],3),dtype=Float64)
      #
      # here is speed up ~30
      #for j in arange(0,size_mcf[0]):
            #eig[0,0] = out[j,1]
            #eig[1,1] = out[j,2]
            #eig[2,2] = out[j,3]
            #
            #eig[0,1] = out[j,4]
            #eig[0,2] = out[j,6]
            #eig[1,0] = out[j,4]
            #eig[1,2] = out[j,5]
            #eig[2,0] = out[j,6]
            #eig[2,1] = out[j,5]
      #
      eig[:,0,0] = out[:,1]
      eig[:,1,1] = out[:,2]
      eig[:,2,2] = out[:,3]
      eig[:,1,0] = eig[:,0,1] = out[:,4]
      eig[:,2,0] = eig[:,0,2] = out[:,6]
      eig[:,2,1] = eig[:,1,2] = out[:,5]
      #
      for i in arange(size_mcf[0]):
            eigwert[i] = eigvals(eig[i,:,:])
      #
      out[:,7:10] = sort(eigwert[:,:].astype(float32))
      out[:,10] = abs(out[:,7]-out[:,9])

speedup factor ~30 !

f.






More information about the Numpy-discussion mailing list