Changeset: c1d63c67c6bb for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c1d63c67c6bb
Modified Files:
monetdb5/modules/mal/sample.c
monetdb5/modules/mal/sample.h
monetdb5/modules/mal/sample.mal
Branch: Jan2014
Log Message:
added missing subuniform_dbl code
diffs (50 lines):
diff --git a/monetdb5/modules/mal/sample.c b/monetdb5/modules/mal/sample.c
--- a/monetdb5/modules/mal/sample.c
+++ b/monetdb5/modules/mal/sample.c
@@ -132,3 +132,24 @@ SAMPLEuniform_dbl(bat *r, bat *b, dbl *p
BBPunfix(bb->batCacheid);
return SAMPLEuniform(r, b, &s);
}
+
+str
+SAMPLEsubuniform_dbl(bat *r, bat *b, dbl *p) {
+ BAT *bb;
+ double pr = *p;
+ wrd s;
+
+ if ( pr < 0.0 || pr > 1.0 ) {
+ throw(MAL, "sample.subuniform", ILLEGAL_ARGUMENT
+ " p should be between 0 and 1.0" );
+ } else if (pr == 0) {/* special case */
+ s = 0;
+ return SAMPLEsubuniform(r, b, &s);
+ }
+ if ((bb = BATdescriptor(*b)) == NULL) {
+ throw(MAL, "sample.uniform", INTERNAL_BAT_ACCESS);
+ }
+ s = (wrd) (pr*(double)BATcount(bb));
+ BBPunfix(bb->batCacheid);
+ return SAMPLEsubuniform(r, b, &s);
+}
diff --git a/monetdb5/modules/mal/sample.h b/monetdb5/modules/mal/sample.h
--- a/monetdb5/modules/mal/sample.h
+++ b/monetdb5/modules/mal/sample.h
@@ -47,4 +47,7 @@ SAMPLEsubuniform(bat *r, bat *b, wrd *s)
sample_export str
SAMPLEuniform_dbl(bat *r, bat *b, dbl *p);
+sample_export str
+SAMPLEsubuniform_dbl(bat *r, bat *b, dbl *p);
+
#endif
diff --git a/monetdb5/modules/mal/sample.mal b/monetdb5/modules/mal/sample.mal
--- a/monetdb5/modules/mal/sample.mal
+++ b/monetdb5/modules/mal/sample.mal
@@ -34,3 +34,7 @@ comment "Returns the oids of a uniform s
command uniform(b:bat[:oid,:any],p:dbl):bat[:oid,:any]
address SAMPLEuniform_dbl
comment "Returns a uniform sample of size = (p x count(b)), where 0 <= p <=
1.0"
+
+command subuniform(b:bat[:oid,:any],p:dbl):bat[:oid,:oid]
+address SAMPLEsubuniform_dbl
+comment "Returns the oids of a uniform sample of size = (p x count(b)), where
0 <= p <= 1.0";
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list