Example #1
0
File: get.go Project: postfix/hdf5
func computeArrayLength(tid C.hid_t) (C.hsize_t, error) {
	nd := C.H5Tget_array_ndims(tid)
	if nd < 0 {
		return 0, errors.New("cannot get the dimensionality of an array")
	}

	dimensions := make([]C.hsize_t, nd)
	if C.H5Tget_array_dims2(tid, (*C.hsize_t)(unsafe.Pointer(&dimensions[0]))) != nd {
		return 0, errors.New("cannot get the dimensions of an array")
	}

	length := C.hsize_t(1)
	for i := range dimensions {
		length *= dimensions[i]
	}

	return length, nil
}
Example #2
0
// Returns the rank of an array datatype.
// int H5Tget_array_ndims( hid_t adtype_id )
func (t *ArrayType) NDims() int {
	return int(C.H5Tget_array_ndims(t.id))
}