A Monday 13 December 2010 12:51:39 Dominik Szczerba escrigué:
> One thing that I need is to access columns of my matrix with the same
> efficiency as I would access them using rows, e.g.
> 
> for col in tetrahedrons:
>   # get indices of one element
> 
> For the moment I implement the above like:
> 
> for i in range(NCELL):
>   col = tetrahedrons[:,i] # get the element vertices in a
> fortran/matlab matrix
> 
> I used to assume this to be efficient as the data in file is oriented
> column-wise, but am no longer sure, maybe you can clarify.

As we know, HDF5 is ignorant on how the data in file is ordered.  So, if 
you have created the dataset using a Fortran program, then clearly the 
data is ordered column-wise on disk.  But, as you are reading the file 
by using a C-based app, then columns and rows will appear to be 
*transposed*.

So, if what you want is to read column i *of your original Fortran 
array*, then the correct way to do this in PyTables should be:

for i in range(NCELL):
  col = tetrahedrons[i,:]

i.e. read a row.  This is, in fact, basically equivalent to:

for col in tetrahedrons:
  # get indices of one element

So, I'd say that you can use both methods and get similar performance.

Hope this makes sense,

-- 
Francesc Alted

------------------------------------------------------------------------------
Oracle to DB2 Conversion Guide: Learn learn about native support for PL/SQL,
new data types, scalar functions, improved concurrency, built-in packages, 
OCI, SQL*Plus, data movement tools, best practices and more.
http://p.sf.net/sfu/oracle-sfdev2dev 
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to