Skip to content

Commit 1cef615

Browse files
prasunanand9prady9
authored andcommitted
specify type for random engine
1 parent 892beb0 commit 1cef615

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

ext/mri/arrayfire.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static VALUE arf_norm(VALUE self, VALUE val);
223223
static VALUE arf_is_lapack_available(VALUE self);
224224

225225
// Random
226-
static VALUE arf_create_random_engine(VALUE self, VALUE seed_val);
226+
static VALUE arf_create_random_engine(VALUE self, VALUE type_val, VALUE seed_val);
227227
static VALUE arf_retain_random_engine(VALUE self, VALUE engine_val);
228228
static VALUE arf_random_engine_set_type(VALUE self, VALUE engine_val, VALUE type_val);
229229
static VALUE arf_random_engine_get_type(VALUE self, VALUE engine_val);
@@ -563,7 +563,7 @@ void Init_arrayfire() {
563563

564564
Random = rb_define_class_under(ArrayFire, "Random", rb_cObject);
565565
rb_define_alloc_func(Random, arf_engine_alloc);
566-
rb_define_singleton_method(Random, "create_random_engine", (METHOD)arf_create_random_engine, 1);
566+
rb_define_singleton_method(Random, "create_random_engine", (METHOD)arf_create_random_engine, 2);
567567
rb_define_singleton_method(Random, "retain_random_engine", (METHOD)arf_retain_random_engine, 1);
568568
rb_define_singleton_method(Random, "random_engine_set_type", (METHOD)arf_random_engine_set_type, 2);
569569
rb_define_singleton_method(Random, "random_engine_get_type", (METHOD)arf_random_engine_get_type, 1);

ext/mri/cmodules/random.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
static VALUE arf_create_random_engine(VALUE self, VALUE seed_val){
1+
static VALUE arf_create_random_engine(VALUE self, VALUE type_val, VALUE seed_val){
22
afrandomenginestruct* output = ALLOC(afrandomenginestruct);
3+
af_random_engine_type rtype = arf_randome_engine_type_from_rbsymbol(type_val);
4+
35
af_create_random_engine(&output->cengine, AF_RANDOM_ENGINE_DEFAULT, NUM2ULL(seed_val) ) ;
46

57
return Data_Wrap_Struct(Random, NULL, arf_engine_free, output);

0 commit comments

Comments
 (0)