// Retrieves sizes of array dimensions. // int H5Tget_array_dims2( hid_t adtype_id, hsize_t dims[] ) func (t *ArrayType) ArrayDims() []int { rank := t.NDims() dims := make([]int, rank) // fixme: int/hsize_t size! c_dims := (*C.hsize_t)(unsafe.Pointer(&dims[0])) c_rank := int(C.H5Tget_array_dims2(t.id, c_dims)) if c_rank == rank { return dims } return nil }
// ArrayDims returns the array dimensions. func (t *ArrayType) ArrayDims() []int { rank := t.NDims() dims := make([]int, rank) hdims := make([]C.hsize_t, rank) slice := (*reflect.SliceHeader)(unsafe.Pointer(&hdims)) c_dims := (*C.hsize_t)(unsafe.Pointer(slice.Data)) c_rank := int(C.H5Tget_array_dims2(t.id, c_dims)) if c_rank != rank { return nil } for i, n := range hdims { dims[i] = int(n) } return dims }
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 }