jl4rb 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/jl4rb/jl4rb.c +35 -11
- data/jl4rb.gemspec +2 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5dfcf11641758e08d73345c51fce1f7f34286746cc0559566b2344479169ea4
|
4
|
+
data.tar.gz: 917e248ff6e0444a15c4307f44a9b7299455d0776927ecadeeea5887c5cd11a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc9bcbd2c1fdef4421a6ec44bcc12f6139dda57784a12574f2396aba1419e77751be7f2fe77e678ea0ce391df9351adfefa983fc98ed95fbe730f987761ef455
|
7
|
+
data.tar.gz: 9dcb4bda5973938c76161d1a25613be1ebbfe9354745741bb14c12759915e50e8538af07039bc4f3927339fe2f12f9a6ae4ffd1e4ced65e8849e0e042e823959
|
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)
|
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 =
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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'
|
25
|
+
s.licenses = ['MIT']
|
26
26
|
s.description = <<-EOF
|
27
27
|
R is embedded in ruby with some communication support .
|
28
28
|
EOF
|
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.
|
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:
|
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.
|
54
|
+
rubygems_version: 3.5.20
|
56
55
|
signing_key:
|
57
56
|
specification_version: 4
|
58
57
|
summary: Julia for ruby
|