Dataspace dimensions vs MATLAB R2006b

I thought I could know all about a dataset in one go.
Thanks a lot,
Dominik

···

On Friday 28 December 2007 16.28:30 Pedro Vicente Nunes wrote:

Hello

At 07:01 AM 12/28/2007, Dominik Szczerba wrote:
>Hi,
>1) Is it possible to know the rank of the dataset by a single call to
>H5LTget_dataset_info? I know this is possible with
> h5ltget_dataset_ndims_f, but I believe it should is also possible without
> it (otherwise it is returning a pointer to array of unknown size?)

the corresponding C function is H5LTget_dataset_ndims.
check out the manual page at

http://www.hdfgroup.uiuc.edu/HDF5/doc_1.8pre/doc/HL/RM_H5LT.html

>2) is hsize_t* dims allocated by H5LTget_dataset_info or should be
>preallocated? (this is a general remark, this kind of information is
> missing on many manual pages).
>thanks a lot and best regards,

it should be preallocated.

the typical usage is to get the rank with H5LTget_dataset_ndims, allocate a
buffer with the rank and then call H5LTget_dataset_info

for example

int rank;
hsize_t *dims;

H5LTget_dataset_ndims (dset_id, "dset_name", &rank );

dims = malloc( rank );

H5LTget_dataset_info(file_id, "dset_name" ,dims,NULL,NULL);

free ( dims );

Pedro

>--
>Dominik Szczerba, Ph.D.
>Computer Vision Lab CH-8092 Zurich
>http://www.vision.ee.ethz.ch/~domi

Pedro Vicente Nunes
--------------------------------------------------------------
http://hdfgroup.org/
HDF5 tools main developer
phone: (217)-265-0311
pvn@hdfgroup.org

--
Dominik Szczerba, Ph.D.
Computer Vision Lab CH-8092 Zurich
http://www.vision.ee.ethz.ch/~domi

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

I thought I could know all about a dataset in one go.

no, unfortunately we have to know the space to allocate in order to get the dimensions.
we thought of making H5LTget_dataset_info return the rank in the function, like

rank = H5LTget_dataset_info(file_id, "dset_name" ,NULL,NULL,NULL);

passing NULL in the dimensions parameter and then call H5LTget_dataset_info again, with the allocated dimensions, an approach that is followed elsewhere in the library

H5LTget_dataset_info(file_id, "dset_name" ,dims,NULL,NULL);

But we would have had to call 2 functions anyway, so we opted for making a separate function only to getting the rank

You're right though that this information is not present in the manual pages and also in the example code. We'll add those.

Thanks a lot,

you're welcome
Pedro

Dominik

> Hello
>
> >Hi,
> >1) Is it possible to know the rank of the dataset by a single call to
> >H5LTget_dataset_info? I know this is possible with
> > h5ltget_dataset_ndims_f, but I believe it should is also possible without
> > it (otherwise it is returning a pointer to array of unknown size?)
>
> the corresponding C function is H5LTget_dataset_ndims.
> check out the manual page at
>
> http://www.hdfgroup.uiuc.edu/HDF5/doc_1.8pre/doc/HL/RM_H5LT.html
>
> >2) is hsize_t* dims allocated by H5LTget_dataset_info or should be
> >preallocated? (this is a general remark, this kind of information is
> > missing on many manual pages).
> >thanks a lot and best regards,
>
> it should be preallocated.
>
> the typical usage is to get the rank with H5LTget_dataset_ndims, allocate a
> buffer with the rank and then call H5LTget_dataset_info
>
> for example
>
> int rank;
> hsize_t *dims;
>
> H5LTget_dataset_ndims (dset_id, "dset_name", &rank );
>
> dims = malloc( rank );
>
> H5LTget_dataset_info(file_id, "dset_name" ,dims,NULL,NULL);
>
> free ( dims );
>
> Pedro
>
> >--
> >Dominik Szczerba, Ph.D.
> >Computer Vision Lab CH-8092 Zurich
> >http://www.vision.ee.ethz.ch/~domi
>
> Pedro Vicente Nunes
> --------------------------------------------------------------
> http://hdfgroup.org/
> HDF5 tools main developer
> phone: (217)-265-0311
> pvn@hdfgroup.org

--
Dominik Szczerba, Ph.D.
Computer Vision Lab CH-8092 Zurich
http://www.vision.ee.ethz.ch/~domi

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

Pedro Vicente Nunes

···

At 10:01 AM 12/28/2007, Dominik Szczerba wrote:

On Friday 28 December 2007 16.28:30 Pedro Vicente Nunes wrote:
> At 07:01 AM 12/28/2007, Dominik Szczerba wrote:

--------------------------------------------------------------


HDF5 tools main developer
phone: (217)-265-0311
pvn@hdfgroup.org

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

Hi,
An elegant solution would be using the std::vector or similar. That way you
can return the rank implicitly as dims.size(); It also will not matter if the
container is preallocated or not, you can always resize it.
regards,
Dominik

···

On Friday 28 December 2007 18.00:26 Pedro Vicente Nunes wrote:

At 10:01 AM 12/28/2007, Dominik Szczerba wrote:
>I thought I could know all about a dataset in one go.

no, unfortunately we have to know the space to allocate in order to get the
dimensions.
we thought of making H5LTget_dataset_info return the rank in the function,
like

rank = H5LTget_dataset_info(file_id, "dset_name" ,NULL,NULL,NULL);

passing NULL in the dimensions parameter and then call H5LTget_dataset_info
again, with the allocated dimensions, an approach that is followed
elsewhere in the library

H5LTget_dataset_info(file_id, "dset_name" ,dims,NULL,NULL);

But we would have had to call 2 functions anyway, so we opted for making a
separate function only to getting the rank

You're right though that this information is not present in the manual
pages and also in the example code. We'll add those.

>Thanks a lot,

you're welcome
Pedro

>Dominik
>
>On Friday 28 December 2007 16.28:30 Pedro Vicente Nunes wrote:
> > Hello
> >
> > At 07:01 AM 12/28/2007, Dominik Szczerba wrote:
> > >Hi,
> > >1) Is it possible to know the rank of the dataset by a single call to
> > >H5LTget_dataset_info? I know this is possible with
> > > h5ltget_dataset_ndims_f, but I believe it should is also possible
> > > without it (otherwise it is returning a pointer to array of unknown
> > > size?)
> >
> > the corresponding C function is H5LTget_dataset_ndims.
> > check out the manual page at
> >
> > http://www.hdfgroup.uiuc.edu/HDF5/doc_1.8pre/doc/HL/RM_H5LT.html
> >
> > >2) is hsize_t* dims allocated by H5LTget_dataset_info or should be
> > >preallocated? (this is a general remark, this kind of information is
> > > missing on many manual pages).
> > >thanks a lot and best regards,
> >
> > it should be preallocated.
> >
> > the typical usage is to get the rank with H5LTget_dataset_ndims,
> > allocate a buffer with the rank and then call H5LTget_dataset_info
> >
> > for example
> >
> > int rank;
> > hsize_t *dims;
> >
> > H5LTget_dataset_ndims (dset_id, "dset_name", &rank );
> >
> > dims = malloc( rank );
> >
> > H5LTget_dataset_info(file_id, "dset_name" ,dims,NULL,NULL);
> >
> > free ( dims );
> >
> >
> > Pedro
> >
> > >--
> > >Dominik Szczerba, Ph.D.
> > >Computer Vision Lab CH-8092 Zurich
> > >http://www.vision.ee.ethz.ch/~domi
> >
> > Pedro Vicente Nunes
> > --------------------------------------------------------------
> > http://hdfgroup.org/
> > HDF5 tools main developer
> > phone: (217)-265-0311
> > pvn@hdfgroup.org
>
>--
>Dominik Szczerba, Ph.D.
>Computer Vision Lab CH-8092 Zurich
>http://www.vision.ee.ethz.ch/~domi
>
>----------------------------------------------------------------------
>This mailing list is for HDF software users discussion.
>To subscribe to this list, send a message to
> hdf-forum-subscribe@hdfgroup.org. To unsubscribe, send a message to
> hdf-forum-unsubscribe@hdfgroup.org.

Pedro Vicente Nunes
--------------------------------------------------------------
http://hdfgroup.org/
HDF5 tools main developer
phone: (217)-265-0311
pvn@hdfgroup.org

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to
hdf-forum-subscribe@hdfgroup.org. To unsubscribe, send a message to
hdf-forum-unsubscribe@hdfgroup.org.

--
Dominik Szczerba, Ph.D.
Computer Vision Lab CH-8092 Zurich
http://www.vision.ee.ethz.ch/~domi