[Numpy-discussion] vector to tensor matrix speed up

2006-07-20 Thread Ferenc . Pintye




Hi users,

  i have some problem in Numpy with indexing speed for array to tensor
matrix transport.
With 20 cycles it's 9sec ! (without sort(eigvals() - functions)

Many thanks
f.


# stress values/matrix in array form for 20 points
out = zeros((20,11),Float32)
#
#.out = filling matrix ...etc...
#
# stress tensor matrix
eig = zeros((3,3),Float32)
#
#output for eigvalues
eigwert = array([0,0,0])
#
for j in arange(0,20):
  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]
  #
  eigwert = sort(eigvals(eig))
  out[j,7] = eigwert[2]
  out[j,8] = eigwert[1]
  out[j,9] = eigwert[0]
  out[j,10] = abs(eigwert[0]-eigwert[2])
#


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-07-22 Thread Ferenc . Pintye




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] ~ 24
  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.



-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion