summaryrefslogtreecommitdiffstats
path: root/src/H5V.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1999-06-24 02:16:13 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1999-06-24 02:16:13 (GMT)
commitc4c6318e6ab92d8204226923e8e9302e2779aaf4 (patch)
treeeb925287f4f0ac500619d9259ffbbe8fb9342acc /src/H5V.c
parentace37763c377153217564e4dd08c2fcc385e83c4 (diff)
downloadhdf5-c4c6318e6ab92d8204226923e8e9302e2779aaf4.zip
hdf5-c4c6318e6ab92d8204226923e8e9302e2779aaf4.tar.gz
hdf5-c4c6318e6ab92d8204226923e8e9302e2779aaf4.tar.bz2
[svn-r1374] Added in code to support the H5Diterate function, which I've got to add tests
for now. Also, I revised some of the code for hyperslab I/O, which should provide a modest speedup in situations with lots of hyperslabs.
Diffstat (limited to 'src/H5V.c')
-rw-r--r--src/H5V.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/H5V.c b/src/H5V.c
index 15cf867..dc61b22 100644
--- a/src/H5V.c
+++ b/src/H5V.c
@@ -679,3 +679,49 @@ H5V_array_fill(void *_dst, const void *src, size_t size, size_t count)
FUNC_LEAVE(SUCCEED);
} /* H5V_array_fill() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5V_array_offset
+ *
+ * Purpose: Given a coordinate description of a location in an array, this
+ * function returns the byte offset of the coordinate.
+ *
+ * The dimensionality of the whole array, the hyperslab, and the
+ * returned stride array is N. The whole array dimensions are
+ * TOTAL_SIZE and the coordinate is at offset OFFSET.
+ *
+ * Return: Success: Byte offset from beginning of array to start
+ * of striding.
+ *
+ * Failure: abort() -- should never fail
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, June 22, 1999
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hsize_t
+H5V_array_offset(intn n, const hsize_t *total_size, const hssize_t *offset)
+{
+ hsize_t skip; /*starting point byte offset */
+ hsize_t acc; /*accumulator */
+ int i; /*counter */
+
+ FUNC_ENTER(H5V_array_stride, (HDabort(), 0));
+
+ assert(n >= 0 && n <= H5V_HYPER_NDIMS);
+ assert(total_size);
+ assert(offset);
+
+ /* others */
+ for (i=n-1, acc=1, skip=0; i>=0; --i) {
+ skip += acc * offset[i];
+ acc *= total_size[i];
+ }
+
+ FUNC_LEAVE(skip);
+}
+