Class: Julia::Vector
- Inherits:
-
Object
- Object
- Julia::Vector
- Defined in:
- lib/jl4rb/jl2rb_eval.rb,
ext/jl4rb/jl4rb.c
Instance Attribute Summary collapse
-
#name ⇒ Object
rb_define_method(cJuliaVect,“[]”,JuliaVect_aref,1);.
- #type ⇒ Object
Class Method Summary collapse
Instance Method Summary collapse
- #<<(name) ⇒ Object
- #>(arr) ⇒ Object
- #[](key) ⇒ Object
- #[]=(key, val) ⇒ Object
- #arg=(arg) ⇒ Object
- #get ⇒ Object (also: #to_a, #value)
-
#get_with_arg ⇒ Object
(also: #value_with_arg)
method “arg=” defined in eval.rb!! @arg initialized in method “initialize”.
- #initialize(name) ⇒ Object constructor
- #length ⇒ Object
-
#set(arr) ⇒ Object
(also: #<, #value=)
}.
-
#set_arg(arg) ⇒ Object
this method is the same as the previous one but return self! Let us notice that even by adding return self in the previous one I could not manage to execute (rvect.arg=““).value_with_arg but fortunately rvect.set_arg(“”).value_with_arg is working!.
- #set_with_arg(arr) ⇒ Object (also: #value_with_arg=)
- #valid? ⇒ Boolean
Constructor Details
#initialize(name) ⇒ Object
340 341 342 343 344 345 346 |
# File 'ext/jl4rb/jl4rb.c', line 340 VALUE JuliaVect_initialize(VALUE self, VALUE name) { rb_iv_set(self,"@name",name); rb_iv_set(self,"@type",rb_str_new2("var")); rb_iv_set(self,"@arg",rb_str_new2("")); return self; } |
Instance Attribute Details
#name ⇒ Object
rb_define_method(cJuliaVect,“[]”,JuliaVect_aref,1);
#type ⇒ Object
Class Method Details
.assign(name, arr) ⇒ Object
476 477 478 479 480 481 482 483 484 485 486 487 |
# File 'ext/jl4rb/jl4rb.c', line 476 VALUE JuliaVect_assign(VALUE obj, VALUE name,VALUE arr) { jl_value_t* ans; char *tmp; ans=util_VALUE_to_jl_value(arr); tmp = StringValuePtr(name); jl_set_global(jl_main_module, jl_symbol(tmp),ans); return Qnil; } |
Instance Method Details
#<<(name) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/jl4rb/jl2rb_eval.rb', line 53 def <<(name) if name.is_a? Symbol @name=name.to_s @type="var" else @name=name @type="expr" end return self end |
#>(arr) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/jl4rb/jl2rb_eval.rb', line 85 def >(arr) res=self.get #puts "res";p @name;p res if res #puts "arr.class:";p arr.class #puts "res.class";p res.class res=[res] unless res.is_a? Array arr.replace(res) else arr.clear end return self end |
#[](key) ⇒ Object
75 76 77 78 |
# File 'lib/jl4rb/jl2rb_eval.rb', line 75 def [](key) set_arg("["+(key+1).to_s+"]") get_with_arg end |
#[]=(key, val) ⇒ Object
80 81 82 83 |
# File 'lib/jl4rb/jl2rb_eval.rb', line 80 def []=(key,val) set_arg("["+(key+1).to_s+"]") set_with_arg(val) end |
#arg=(arg) ⇒ Object
64 65 66 |
# File 'lib/jl4rb/jl2rb_eval.rb', line 64 def arg=(arg) @arg=arg end |
#get ⇒ Object Also known as: to_a, value
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'ext/jl4rb/jl4rb.c', line 380 VALUE JuliaVect_get(VALUE self) { jl_value_t* ans; VALUE res; char *name; int n,i; VALUE res2; ans = util_getVar(self); if(ans==NULL) { //printf("Sortie de get avec nil\n"); return Qnil; } res=util_jl_value_to_VALUE(ans); if(length(ans)==1) res=rb_ary_entry(res,0); return res; } |
#get_with_arg ⇒ Object Also known as: value_with_arg
method “arg=” defined in eval.rb!! @arg initialized in method “initialize”
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
# File 'ext/jl4rb/jl4rb.c', line 400 VALUE JuliaVect_get_with_arg(VALUE self) { jl_value_t* ans; VALUE res; char *name; int n,i; VALUE res2; ans = util_getExpr_with_arg(self); if(ans==NULL) { //printf("Sortie de get avec nil\n"); return Qnil; } res=util_jl_value_to_VALUE(ans); //printf("JuliaVect_get_with_arg: length(ans)=%d\n",length(ans)); if (length(ans)==1) res=rb_ary_entry(res,0); return res; } |
#length ⇒ Object
365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'ext/jl4rb/jl4rb.c', line 365 VALUE JuliaVect_length(VALUE self) { jl_value_t* ans; char *name; ans = util_getVar(self); if(ans==NULL) { //printf("Sortie de length avec nil\n"); return Qnil; } return INT2NUM(length(ans)); } |
#set(arr) ⇒ Object Also known as: <, value=
}
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
# File 'ext/jl4rb/jl4rb.c', line 458 VALUE JuliaVect_set(VALUE self,VALUE arr) { VALUE tmp; char *cmd; // defineVar(install(".rubyExport"),util_VALUE2jl_value_t*(arr),R_GlobalEnv); // tmp=rb_iv_get(self,"@arg"); // util_eval1string(rb_str_cat2(rb_str_cat2(rb_str_dup(rb_iv_get(self,"@name")),StringValuePtr(tmp)),"<-.rubyExport")); jl_set_global(jl_main_module, jl_symbol("_ruby_export_"),util_VALUE_to_jl_value(arr)); tmp=rb_str_dup(rb_iv_get(self,"@name")); tmp=rb_str_cat2(tmp,"=_ruby_export_"); cmd=StringValuePtr(tmp); // printf("cmd=%s\n",cmd); // jl_eval_string("show(_ruby_export_)"); // printf("cmd->done\n"); jl_eval_string(cmd); return self; } |
#set_arg(arg) ⇒ Object
this method is the same as the previous one but return self! Let us notice that even by adding return self in the previous one I could not manage to execute (rvect.arg=““).value_with_arg but fortunately rvect.set_arg(“”).value_with_arg is working!
70 71 72 73 |
# File 'lib/jl4rb/jl2rb_eval.rb', line 70 def set_arg(arg) @arg=arg return self end |
#set_with_arg(arr) ⇒ Object Also known as: value_with_arg=
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 |
# File 'ext/jl4rb/jl4rb.c', line 489 VALUE JuliaVect_set_with_arg(VALUE self,VALUE arr) { VALUE tmp; char *cmd; // defineVar(install(".rubyExport"),util_VALUE2jl_value_t*(arr),R_GlobalEnv); // tmp=rb_iv_get(self,"@arg"); // util_eval1string(rb_str_cat2(rb_str_cat2(rb_str_dup(rb_iv_get(self,"@name")),StringValuePtr(tmp)),"<-.rubyExport")); jl_set_global(jl_main_module, jl_symbol("_ruby_export_"),util_VALUE_to_jl_value(arr)); tmp=rb_str_dup(rb_iv_get(self,"@arg")); tmp=rb_str_cat2(rb_str_dup(rb_iv_get(self,"@name")),StringValuePtr(tmp)); tmp=rb_str_cat2(tmp,"=_ruby_export_"); cmd=StringValuePtr(tmp); jl_eval_string(cmd); return self; } |
#valid? ⇒ Boolean
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
# File 'ext/jl4rb/jl4rb.c', line 348 VALUE JuliaVect_isValid(VALUE self) { jl_value_t* ans; char *name; ans = util_getVar(self); if(!util_isVector(ans)) { VALUE tmp; tmp=rb_iv_get(self,"@name"); name = StringValuePtr(tmp); rb_warn("%s is not a R vector !!!",name); return Qfalse; } return Qtrue; } |