jl4rb 0.2.6 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 994b5475b648747803c998adf29256d8142e40197a0a2880b2f5c2ef309045f6
4
- data.tar.gz: 73a77f6ccc7a6c5ffa2bf86179ddf4efaa3c8d5b30abde28c0563b59a0fee1df
3
+ metadata.gz: b5dfcf11641758e08d73345c51fce1f7f34286746cc0559566b2344479169ea4
4
+ data.tar.gz: 917e248ff6e0444a15c4307f44a9b7299455d0776927ecadeeea5887c5cd11a5
5
5
  SHA512:
6
- metadata.gz: 21394963d68c946891f10d9eb71613f170f0e5c78130126ad7fafcc98fe8e3558d787e39f7f451136e11d5c85a0635ea7531361a126f50eafbf73849120e4d6e
7
- data.tar.gz: 2924a03b95e4860482d6227565dbc83e88e33ce17318c33221d3b47d3bfaa860a7a2f851d25fcddc9d27a8fa6ebb2b4a13ac53092c4e5313848e022e57d95d96
6
+ metadata.gz: bc9bcbd2c1fdef4421a6ec44bcc12f6139dda57784a12574f2396aba1419e77751be7f2fe77e678ea0ce391df9351adfefa983fc98ed95fbe730f987761ef455
7
+ data.tar.gz: 9dcb4bda5973938c76161d1a25613be1ebbfe9354745741bb14c12759915e50e8538af07039bc4f3927339fe2f12f9a6ae4ffd1e4ced65e8849e0e042e823959
data/Rakefile CHANGED
@@ -62,8 +62,8 @@ end
62
62
  ## clean task
63
63
  desc "Remove #{File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION+'.gem')}"
64
64
  task :clean do |t|
65
- rm File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION+'.gem') if File.exists? File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION+'.gem')
66
- rm_rf File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION) if File.exists? File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION)
65
+ rm File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION+'.gem') if File.exist? File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION+'.gem')
66
+ rm_rf File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION) if File.exist? File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION)
67
67
  end
68
68
 
69
69
 
@@ -77,13 +77,13 @@ end
77
77
  desc "Quick install #{File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION+'.gem')}"
78
78
  task :install do |t|
79
79
  `gem install #{File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION+'.gem')} --local --no-rdoc --no-ri`
80
- rm_rf File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION) if File.exists? File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION)
80
+ rm_rf File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION) if File.exist? File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION)
81
81
  end
82
82
 
83
83
  desc "Docker install #{File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION+'.gem')}"
84
84
  task :docker => :package do |t|
85
85
  `gem install #{File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION+'.gem')} --local --no-rdoc --no-ri`
86
- rm_rf File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION) if File.exists? File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION)
86
+ rm_rf File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION) if File.exist? File.join(PKGDIR,PKG_NAME+'-'+PKG_VERSION)
87
87
  end
88
88
 
89
89
 
data/ext/jl4rb/extconf.rb CHANGED
@@ -5,11 +5,11 @@ $prefix_include,$prefix_lib=[],[]
5
5
  $prefix= File.dirname(`julia -e 'print(Sys.BINDIR)'`)
6
6
 
7
7
  [$prefix+"/include/julia",$prefix+"/usr/include",$prefix+"/src",$prefix+"/src/support"].each do |incl|
8
- $prefix_include << incl if File.exists? incl
8
+ $prefix_include << incl if File.exist? incl
9
9
  end
10
10
 
11
11
  ([$prefix+"/lib/julia",$prefix+"/usr/lib",$prefix+"/lib"]+(RUBY_PLATFORM=~/(?:mingw|msys)/ ? [$prefix+"/bin"] : [])).each do |lib|
12
- $prefix_lib << lib if File.exists? lib
12
+ $prefix_lib << lib if File.exist? lib
13
13
  end
14
14
 
15
15
  def jl4rb_makefile(incs,libs)
data/ext/jl4rb/jl4rb.c CHANGED
@@ -23,7 +23,7 @@
23
23
  #undef NOINLINE
24
24
  #include "julia.h"
25
25
 
26
- #define length(a) jl_array_size(a,0)
26
+ #define length(a) jl_array_dim(a,0)
27
27
 
28
28
  /************* INIT *********************/
29
29
 
@@ -42,13 +42,29 @@ VALUE Julia_exit(VALUE obj, VALUE exitcode) {
42
42
  return Qtrue;
43
43
  }
44
44
 
45
+ // int Rulia_subtype(jl_value_t *jlv, char* typ) {
46
+ // jl_value_t *jl_typ=NULL;
47
+ // int res;
48
+
49
+ // JL_GC_PUSH1(&jl_typ);
50
+ // jl_typ = jl_eval_string(typ);
51
+ // res = jl_subtype(jlv,jl_typ);
52
+ // JL_GC_POP();
53
+ // return res;
54
+ // }
55
+
45
56
  //Maybe try to use cpp stuff to get the output inside julia system (ccall,cgen and cgutils)
46
57
  //-| TODO: after adding in the jlapi.c jl_is_<C_type> functions replace the strcmp!
47
58
  VALUE jl_value_to_VALUE(jl_value_t *res) {
48
59
  size_t i=0,k,nd,d;
49
60
  VALUE resRb;
50
- jl_value_t *tmp;
51
- jl_function_t *call;
61
+ jl_value_t *tmp, *res_elt;
62
+ jl_function_t *call, *getindex;
63
+ // double* xDataD;
64
+ // int* xDataL;
65
+ // uint8_t* xDataB;
66
+ // jl_value_t** xData;
67
+
52
68
 
53
69
  if(res!=NULL) { //=> get a result
54
70
  //printf("typeof=%s\n",jl_typeof_str(res));
@@ -117,14 +133,17 @@ VALUE jl_value_to_VALUE(jl_value_t *res) {
117
133
  if(strcmp(jl_typeof_str(res),"Array")==0 )
118
134
  //if(jl_is_array(res))
119
135
  {
136
+ getindex = jl_get_function(jl_main_module, "getindex");
120
137
  nd = jl_array_rank(res);
121
138
  //printf("array_ndims=%d\n",(int)nd);
122
139
  if(nd==1) {//Vector
123
- d = jl_array_size(res, 0);
140
+ d = jl_array_dim(res, 0);
124
141
  //printf("array_dim[1]=%d\n",(int)d);
125
142
  resRb = rb_ary_new2(d);
126
143
  for(i=0;i<d;i++) {
127
- rb_ary_store(resRb,i,jl_value_to_VALUE(jl_arrayref((jl_array_t *)res,i)));
144
+ res_elt = jl_call2(getindex, res, jl_box_long(i+1));
145
+ rb_ary_store(resRb,i,jl_value_to_VALUE(res_elt));
146
+ // rb_ary_store(resRb,i,jl_value_to_VALUE(jl_arrayref((jl_array_t *)res,i)));
128
147
  }
129
148
  return resRb;
130
149
  }
@@ -285,6 +304,7 @@ jl_value_t* util_VALUE_to_jl_value(VALUE arr)
285
304
  jl_value_t *ans,*elt,*array_type;
286
305
  VALUE res,class,tmp;
287
306
  int i,n=0,vect=1;
307
+ jl_function_t *setindex;
288
308
 
289
309
  if(!rb_obj_is_kind_of(arr,rb_cArray)) {
290
310
  n=1;
@@ -297,14 +317,15 @@ jl_value_t* util_VALUE_to_jl_value(VALUE arr)
297
317
  }
298
318
 
299
319
  class=rb_class_of(rb_ary_entry(arr,0));
300
-
320
+ setindex = jl_get_function(jl_main_module, "setindex!");
301
321
  if(class==rb_cFloat) {
302
322
  //-| This is maybe faster and can be developped in julia-api as jl_vector_float64(n) for example.
303
323
  array_type=jl_apply_array_type((jl_value_t*)jl_float64_type, 1);
304
324
  ans=(jl_value_t*)jl_alloc_array_1d(array_type,n);
305
325
  for(i=0;i<n;i++) {
306
326
  elt=jl_box_float64(NUM2DBL(rb_ary_entry(arr,i)));
307
- jl_arrayset((jl_array_t*)ans,elt,i);
327
+ jl_call3(setindex, ans, elt, jl_box_long(i+1));
328
+ //jl_arrayset((jl_array_t*)ans,elt,i);
308
329
  }
309
330
  #if RUBY_API_VERSION_CODE >= 20400
310
331
  } else if(class==rb_cInteger) {
@@ -315,14 +336,16 @@ jl_value_t* util_VALUE_to_jl_value(VALUE arr)
315
336
  ans=(jl_value_t*)jl_alloc_array_1d(array_type,n);
316
337
  for(i=0;i<n;i++) {
317
338
  elt=jl_box_long(NUM2INT(rb_ary_entry(arr,i)));
318
- jl_arrayset((jl_array_t*)ans,elt,i);
339
+ jl_call3(setindex, ans, elt, jl_box_long(i+1));
340
+ //jl_arrayset((jl_array_t*)ans,elt,i);
319
341
  }
320
342
  } else if(class==rb_cTrueClass || class==rb_cFalseClass) {
321
343
  array_type=jl_apply_array_type((jl_value_t*)jl_bool_type, 1);
322
344
  ans=(jl_value_t*)jl_alloc_array_1d(array_type,n);
323
345
  for(i=0;i<n;i++) {
324
346
  elt=jl_box_bool(rb_class_of(rb_ary_entry(arr,i))==rb_cFalseClass ? 0 : 1);
325
- jl_arrayset((jl_array_t*)ans,elt,i);
347
+ jl_call3(setindex, ans, elt, jl_box_long(i+1));
348
+ //jl_arrayset((jl_array_t*)ans,elt,i);
326
349
  }
327
350
  } else if(class==rb_cString) {
328
351
  array_type=jl_apply_array_type((jl_value_t*)jl_string_type, 1);
@@ -330,10 +353,11 @@ jl_value_t* util_VALUE_to_jl_value(VALUE arr)
330
353
  for(i=0;i<n;i++) {
331
354
  tmp=rb_ary_entry(arr,i);
332
355
  elt=jl_cstr_to_string(StringValuePtr(tmp));
333
- jl_arrayset((jl_array_t*)ans,elt,i);
356
+ jl_call3(setindex, ans, elt, jl_box_long(i+1));
357
+ //jl_arrayset((jl_array_t*)ans,elt,i);
334
358
  }
335
359
  } else ans=NULL;
336
- if(!vect && ans) ans=jl_arrayref((jl_array_t*)ans,0);
360
+ if(!vect && ans) ans=NULL;//jl_arrayref((jl_array_t*)ans,0);
337
361
  return ans;
338
362
  }
339
363
 
data/jl4rb.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rubygems/package_task'
3
3
 
4
4
  PKG_NAME='jl4rb'
5
- PKG_VERSION='0.2.6'
5
+ PKG_VERSION='0.3.0'
6
6
  PKG_FILES=FileList[
7
7
  'Rakefile','jl4rb.gemspec',
8
8
  'ext/jl4rb/*.c',
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.require_paths = ["lib","ext/jl4rb"]
23
23
  s.files = PKG_FILES.to_a
24
24
  s.extensions = ["ext/jl4rb/extconf.rb"]
25
- s.licenses = ['MIT', 'GPL-2.0']
25
+ s.licenses = ['MIT']
26
26
  s.description = <<-EOF
27
27
  R is embedded in ruby with some communication support .
28
28
  EOF
data/lib/jl4rb.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'jl4rb.bundle' if File.exists? File.join(File.dirname(__FILE__),'jl4rb.bundle')
2
- require 'jl4rb.so' if File.exists? File.join(File.dirname(__FILE__),'jl4rb.so')
1
+ require 'jl4rb.bundle' if File.exist? File.join(File.dirname(__FILE__),'jl4rb.bundle')
2
+ require 'jl4rb.so' if File.exist? File.join(File.dirname(__FILE__),'jl4rb.so')
3
3
 
4
4
  p [:dl, "jl4rb.DLL loaded" ]
5
5
  # loading ruby files
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jl4rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CQLS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-29 00:00:00.000000000 Z
11
+ date: 2024-10-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'R is embedded in ruby with some communication support .
14
14
 
@@ -33,7 +33,6 @@ files:
33
33
  homepage: http://cqls.upmf-grenoble.fr
34
34
  licenses:
35
35
  - MIT
36
- - GPL-2.0
37
36
  metadata: {}
38
37
  post_install_message:
39
38
  rdoc_options: []
@@ -52,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
51
  version: '0'
53
52
  requirements:
54
53
  - none
55
- rubygems_version: 3.3.11
54
+ rubygems_version: 3.5.20
56
55
  signing_key:
57
56
  specification_version: 4
58
57
  summary: Julia for ruby