[H5r-commits] r41 - R src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Apr 12 18:51:25 CEST 2011


Author: extemporaneousb
Date: 2011-04-12 18:51:25 +0200 (Tue, 12 Apr 2011)
New Revision: 41

Modified:
   R/h5R.R
   src/h5_wrap.c
Log:

Added a read1DSlabs function that moves to C the reading of slabs of data - essentially I move a loop to C.




Modified: R/h5R.R
===================================================================
--- R/h5R.R	2011-03-17 23:47:58 UTC (rev 40)
+++ R/h5R.R	2011-04-12 16:51:25 UTC (rev 41)
@@ -385,6 +385,10 @@
   if (! is.null(dim(h5Dataset))) aperm(d) else d
 }
 
+read1DSlabs <- function(h5Dataset, offsets, dims) {
+  .Call("h5R_read_1d_slabs", .ePtr(h5Dataset), as.integer(offsets - 1), as.integer(dims))
+}
+
 readSlab <- function(h5Dataset, offsets, dims) {
   if (! all((offsets + dims - 1) <= dim(h5Dataset)))
     stop("error invalid slice specification in readSlab.")

Modified: src/h5_wrap.c
===================================================================
--- src/h5_wrap.c	2011-03-17 23:47:58 UTC (rev 40)
+++ src/h5_wrap.c	2011-04-12 16:51:25 UTC (rev 41)
@@ -259,6 +259,7 @@
     return(dta);
 }
 
+
 SEXP h5R_read_slab(SEXP h5_dataset, SEXP _offsets, SEXP _counts) {
     int __ERROR__ = 0;
     SEXP dta = R_NilValue;
@@ -338,6 +339,23 @@
     return dta;
 }
 
+SEXP h5R_read_1d_slabs(SEXP h5_dataset, SEXP _offsets, SEXP _counts) {
+    int rlen = length(_counts);
+    SEXP r_lst; 
+    int i;
+    int* counts = INTEGER(_counts);
+    int* offsets = INTEGER(_offsets);
+    
+    PROTECT(r_lst = allocVector(VECSXP, rlen));
+    
+    for (i = 0; i < rlen; i++) {
+	SET_VECTOR_ELT(r_lst, i, h5R_read_slab(h5_dataset, ScalarInteger(offsets[i]), ScalarInteger(counts[i])));
+    }
+
+    UNPROTECT(1);
+    return(r_lst);
+}
+
   
 SEXP h5R_read_attr(SEXP h5_attr) {
     SEXP dta = R_NilValue;



More information about the H5r-commits mailing list